mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-22 23:51:27 +01:00
Merge pull request #542 from wknet123/master
Update for JS minification.
This commit is contained in:
commit
48af6cbfb5
@ -36,7 +36,7 @@ db_password = root123
|
|||||||
self_registration = on
|
self_registration = on
|
||||||
|
|
||||||
#Turn on or off the options to control UI whether to use compressed js file
|
#Turn on or off the options to control UI whether to use compressed js file
|
||||||
use_compressed_js = off
|
use_compressed_js = on
|
||||||
|
|
||||||
#Number of job workers in job service, default is 3
|
#Number of job workers in job service, default is 3
|
||||||
max_job_workers = 3
|
max_job_workers = 3
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
echo "This shell will minify the Javascript in Harbor project."
|
echo "This shell will minify the Javascript in Harbor project."
|
||||||
echo "Usage: #jsminify [src] [dest]"
|
echo "Usage: #jsminify [src] [dest]"
|
||||||
@ -9,7 +9,8 @@ rm -rf $2 /tmp/harbor.app.temp.js
|
|||||||
BASEPATH=/go/bin
|
BASEPATH=/go/bin
|
||||||
#concat the js files from js include file
|
#concat the js files from js include file
|
||||||
echo "Concat js files..."
|
echo "Concat js files..."
|
||||||
cat $1 |while read LINE
|
|
||||||
|
cat $1 | while read LINE || [[ -n $LINE ]]
|
||||||
do
|
do
|
||||||
if [ -n "$LINE" ]
|
if [ -n "$LINE" ]
|
||||||
then
|
then
|
||||||
@ -21,14 +22,13 @@ done
|
|||||||
|
|
||||||
#remove space
|
#remove space
|
||||||
echo "Remove space.."
|
echo "Remove space.."
|
||||||
sed 's/ //g' -i /tmp/harbor.app.temp.js
|
sed 's/ \+/ /g' -i /tmp/harbor.app.temp.js
|
||||||
|
|
||||||
#remove '//' and '/*'
|
#remove '//' and '/*'
|
||||||
echo "Remove '//'and '/*' annotation..."
|
echo "Remove '//'and '/*' annotation..."
|
||||||
sed '/^\/\//'d -i /tmp/harbor.app.temp.js
|
sed '/^\/\//'d -i /tmp/harbor.app.temp.js
|
||||||
sed '/\/\*/{/\*\//d;:a;N;/\*\//d;ba};s,//.*,,' -i /tmp/harbor.app.temp.js
|
sed '/\/\*/{/\*\//d;:a;N;/\*\//d;ba};s,//.*,,' -i /tmp/harbor.app.temp.js
|
||||||
|
|
||||||
|
|
||||||
cat > $2 << EOF
|
cat > $2 << EOF
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
|
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
|
||||||
|
@ -13,7 +13,7 @@ LDAP_URL=$ldap_url
|
|||||||
LDAP_BASE_DN=$ldap_basedn
|
LDAP_BASE_DN=$ldap_basedn
|
||||||
UI_SECRET=$ui_secret
|
UI_SECRET=$ui_secret
|
||||||
SELF_REGISTRATION=$self_registration
|
SELF_REGISTRATION=$self_registration
|
||||||
PRODUCTION=$use_compressed_js
|
USE_COMPRESSED_JS=$use_compressed_js
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
GODEBUG=netdns=cgo
|
GODEBUG=netdns=cgo
|
||||||
EXT_ENDPOINT=$ui_url
|
EXT_ENDPOINT=$ui_url
|
||||||
|
@ -21,7 +21,7 @@ type BaseController struct {
|
|||||||
SelfRegistration bool
|
SelfRegistration bool
|
||||||
IsAdmin bool
|
IsAdmin bool
|
||||||
AuthMode string
|
AuthMode string
|
||||||
Production bool
|
UseCompressedJS bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type langType struct {
|
type langType struct {
|
||||||
@ -99,13 +99,13 @@ func (b *BaseController) Prepare() {
|
|||||||
b.AuthMode = authMode
|
b.AuthMode = authMode
|
||||||
b.Data["AuthMode"] = b.AuthMode
|
b.Data["AuthMode"] = b.AuthMode
|
||||||
|
|
||||||
production := os.Getenv("PRODUCTION")
|
useCompressedJS := os.Getenv("USE_COMPRESSED_JS")
|
||||||
if production == "on" {
|
if useCompressedJS == "on" {
|
||||||
b.Production = true
|
b.UseCompressedJS = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(filepath.Join("static", "resources", "js", "harbor.app.min.js")); os.IsNotExist(err) {
|
if _, err := os.Stat(filepath.Join("static", "resources", "js", "harbor.app.min.js")); os.IsNotExist(err) {
|
||||||
b.Production = false
|
b.UseCompressedJS = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ func (b *BaseController) Forward(title, templateName string) {
|
|||||||
b.LayoutSections = make(map[string]string)
|
b.LayoutSections = make(map[string]string)
|
||||||
b.LayoutSections["HeaderInclude"] = filepath.Join(prefixNg, viewPath, "header-include.htm")
|
b.LayoutSections["HeaderInclude"] = filepath.Join(prefixNg, viewPath, "header-include.htm")
|
||||||
|
|
||||||
if b.Production {
|
if b.UseCompressedJS {
|
||||||
b.LayoutSections["HeaderScriptInclude"] = filepath.Join(prefixNg, viewPath, "script-min-include.htm")
|
b.LayoutSections["HeaderScriptInclude"] = filepath.Join(prefixNg, viewPath, "script-min-include.htm")
|
||||||
} else {
|
} else {
|
||||||
b.LayoutSections["HeaderScriptInclude"] = filepath.Join(prefixNg, viewPath, "script-include.htm")
|
b.LayoutSections["HeaderScriptInclude"] = filepath.Join(prefixNg, viewPath, "script-include.htm")
|
||||||
|
Loading…
Reference in New Issue
Block a user