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
|
||||
|
||||
#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
|
||||
max_job_workers = 3
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "This shell will minify the Javascript in Harbor project."
|
||||
echo "Usage: #jsminify [src] [dest]"
|
||||
@ -9,7 +9,8 @@ rm -rf $2 /tmp/harbor.app.temp.js
|
||||
BASEPATH=/go/bin
|
||||
#concat the js files from js include file
|
||||
echo "Concat js files..."
|
||||
cat $1 |while read LINE
|
||||
|
||||
cat $1 | while read LINE || [[ -n $LINE ]]
|
||||
do
|
||||
if [ -n "$LINE" ]
|
||||
then
|
||||
@ -21,14 +22,13 @@ done
|
||||
|
||||
#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 '/*'
|
||||
echo "Remove '//'and '/*' annotation..."
|
||||
sed '/^\/\//'d -i /tmp/harbor.app.temp.js
|
||||
sed '/\/\*/{/\*\//d;:a;N;/\*\//d;ba};s,//.*,,' -i /tmp/harbor.app.temp.js
|
||||
|
||||
|
||||
cat > $2 << EOF
|
||||
/*
|
||||
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
|
||||
|
@ -13,7 +13,7 @@ LDAP_URL=$ldap_url
|
||||
LDAP_BASE_DN=$ldap_basedn
|
||||
UI_SECRET=$ui_secret
|
||||
SELF_REGISTRATION=$self_registration
|
||||
PRODUCTION=$use_compressed_js
|
||||
USE_COMPRESSED_JS=$use_compressed_js
|
||||
LOG_LEVEL=debug
|
||||
GODEBUG=netdns=cgo
|
||||
EXT_ENDPOINT=$ui_url
|
||||
|
@ -21,7 +21,7 @@ type BaseController struct {
|
||||
SelfRegistration bool
|
||||
IsAdmin bool
|
||||
AuthMode string
|
||||
Production bool
|
||||
UseCompressedJS bool
|
||||
}
|
||||
|
||||
type langType struct {
|
||||
@ -99,13 +99,13 @@ func (b *BaseController) Prepare() {
|
||||
b.AuthMode = authMode
|
||||
b.Data["AuthMode"] = b.AuthMode
|
||||
|
||||
production := os.Getenv("PRODUCTION")
|
||||
if production == "on" {
|
||||
b.Production = true
|
||||
useCompressedJS := os.Getenv("USE_COMPRESSED_JS")
|
||||
if useCompressedJS == "on" {
|
||||
b.UseCompressedJS = true
|
||||
}
|
||||
|
||||
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["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")
|
||||
} else {
|
||||
b.LayoutSections["HeaderScriptInclude"] = filepath.Join(prefixNg, viewPath, "script-include.htm")
|
||||
|
Loading…
Reference in New Issue
Block a user