From e0654bbe073b1eff21becd4faa47008ddab6d1ad Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 2 Dec 2010 22:16:24 +0000 Subject: [PATCH] OPAC JS combation and compression enhancements Added ability to combine locale-independent common JS files (opac/common/js/) into a single JS file to reduce http back/forth from the browser. In the default skin, this combines 10 scripts into 1. The scripts to combine are parsed from js_common.xml (enclosed by START/END COMPRESSION comments). The combined file is created by autogen. Use of the combined file is enabled via new Apache configuration (off by default). When a JS compressor is configured in autogen, the JS file will be subsequently compressed. Also includes better IDL2js loader for My Account, which loads additional fieldmapper classes. TODO: Add ./configure param for setting a JS compressor at build time Options for providing compressed versions of other JS files git-svn-id: svn://svn.open-ils.org/ILS/trunk@18905 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/apache/eg_vhost.conf | 4 + Open-ILS/src/extras/autogen.sh | 31 +++- .../skin/default/xml/common/js_common.xml | 147 +++++++++--------- 3 files changed, 110 insertions(+), 72 deletions(-) diff --git a/Open-ILS/examples/apache/eg_vhost.conf b/Open-ILS/examples/apache/eg_vhost.conf index 89ae4163da..033504f590 100644 --- a/Open-ILS/examples/apache/eg_vhost.conf +++ b/Open-ILS/examples/apache/eg_vhost.conf @@ -123,6 +123,10 @@ RewriteRule . - [E=locale:%1] # authentication tokens. Left commented out for backwards compat for now. #SetEnv OILS_OPAC_FORCE_LOGIN_SSL 1 + + # If set, the skin uses the combined JS file at $SKINDIR/js/combined.js + #SetEnv OILS_OPAC_COMBINED_JS 1 + diff --git a/Open-ILS/src/extras/autogen.sh b/Open-ILS/src/extras/autogen.sh index 7a8171137a..e35eedd5ea 100755 --- a/Open-ILS/src/extras/autogen.sh +++ b/Open-ILS/src/extras/autogen.sh @@ -88,6 +88,10 @@ fi; JSDIR="LOCALSTATEDIR/web/opac/common/js/"; FMDOJODIR="LOCALSTATEDIR/web/js/dojo/fieldmapper/"; SLIMPACDIR="LOCALSTATEDIR/web/opac/extras/slimpac/"; +SKINDIR='LOCALSTATEDIR/web/opac/skin'; + +COMPRESSOR="" # TODO: set via ./configure +#COMPRESSOR="java -jar /opt/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar" echo "Updating Evergreen organization tree and IDL using '$CONFIG'" echo "" @@ -123,7 +127,32 @@ then perl org_tree_proximity.pl "$CONFIG"; fi -echo ""; +echo "Creating combined JS..." +cd $JSDIR; + +for skin in $(ls $SKINDIR); do + + files=$(sed -n -e "/<\!--START COMPRESSION-->/,/<\!--END COMPRESSION-->/ s/.*\?\/\([^']*\.js\)'.*/\1/p" $SKINDIR/$skin/xml/common/js_common.xml); + + if [ -n "$files" ]; then + + # add the selected files to one combined file + COMPRESS_FILE="$SKINDIR/$skin/js/combined.js" + cat $files > $COMPRESS_FILE + + # if a compressor is configured, compress and report the size savings + if [ -n "$COMPRESSOR" ]; then + + echo -n "before: "; du -h $COMPRESS_FILE; + + $COMPRESSOR $COMPRESS_FILE > $COMPRESS_FILE.t; + mv $COMPRESS_FILE.t $COMPRESS_FILE; + + echo -n "after: "; du -h $COMPRESS_FILE; + fi; + fi; +done; + echo "Done"; ) diff --git a/Open-ILS/web/opac/skin/default/xml/common/js_common.xml b/Open-ILS/web/opac/skin/default/xml/common/js_common.xml index a2fe07b035..fd7d5ad556 100644 --- a/Open-ILS/web/opac/skin/default/xml/common/js_common.xml +++ b/Open-ILS/web/opac/skin/default/xml/common/js_common.xml @@ -1,71 +1,76 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.43.2