From 0c694ce0b6d98703fd034929a0bf522ed864f28f Mon Sep 17 00:00:00 2001 From: kunw Date: Wed, 13 Jul 2016 17:23:43 +0800 Subject: [PATCH] add JS minification when building UI image. --- Deploy/docker-compose.yml | 2 - Deploy/harbor.cfg | 3 + Deploy/jsminify.sh | 59 ++++++++ Deploy/prepare | 4 +- Deploy/templates/ui/env | 2 + Dockerfile.ui | 4 +- controllers/base.go | 18 +++ views/layout.htm | 1 + views/sections/header-include.htm | 201 +------------------------- views/sections/script-include.htm | 194 +++++++++++++++++++++++++ views/sections/script-min-include.htm | 1 + 11 files changed, 286 insertions(+), 203 deletions(-) create mode 100755 Deploy/jsminify.sh create mode 100644 views/sections/script-include.htm create mode 100644 views/sections/script-min-include.htm diff --git a/Deploy/docker-compose.yml b/Deploy/docker-compose.yml index 4a648b486..aa34dde18 100644 --- a/Deploy/docker-compose.yml +++ b/Deploy/docker-compose.yml @@ -46,8 +46,6 @@ services: volumes: - ./config/ui/app.conf:/etc/ui/app.conf - ./config/ui/private_key.pem:/etc/ui/private_key.pem - - ../static:/go/bin/static - - ../views:/go/bin/views depends_on: - log logging: diff --git a/Deploy/harbor.cfg b/Deploy/harbor.cfg index e1acfa6aa..7f5469aea 100644 --- a/Deploy/harbor.cfg +++ b/Deploy/harbor.cfg @@ -35,6 +35,9 @@ db_password = root123 #Turn on or off the self-registration feature self_registration = on +#Turn on or off the options for production +production = on + #Number of job workers in job service, default is 3 max_job_workers = 3 diff --git a/Deploy/jsminify.sh b/Deploy/jsminify.sh new file mode 100755 index 000000000..177a3505d --- /dev/null +++ b/Deploy/jsminify.sh @@ -0,0 +1,59 @@ +#!/bin/sh +set -e +echo "This shell will minify the Javascript in Harbor project." +echo "Usage: #jsminify [src] [dest]" + +#prepare workspace +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 +do + if [ -n "$LINE" ] + then + TEMP="$BASEPATH""$LINE" + cat `echo "$TEMP" | sed 's/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -{{ if eq .Lang "zh-CN" }} +{{ if eq .Lang "zh-CN" }} -{{ else if eq .Lang "en-US"}} +{{ else if eq .Lang "en-US" }} {{ end }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/views/sections/script-include.htm b/views/sections/script-include.htm new file mode 100644 index 000000000..77ad5c2f6 --- /dev/null +++ b/views/sections/script-include.htm @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/views/sections/script-min-include.htm b/views/sections/script-min-include.htm new file mode 100644 index 000000000..64f9960d6 --- /dev/null +++ b/views/sections/script-min-include.htm @@ -0,0 +1 @@ + \ No newline at end of file