summaryrefslogtreecommitdiff
path: root/build_system
diff options
context:
space:
mode:
Diffstat (limited to 'build_system')
-rwxr-xr-xbuild_system/cmpcss125
-rwxr-xr-xbuild_system/get_jsfiles.sed25
-rwxr-xr-xbuild_system/make.gzip130
-rwxr-xr-xbuild_system/yui_compressor.jarbin0 -> 837686 bytes
4 files changed, 280 insertions, 0 deletions
diff --git a/build_system/cmpcss b/build_system/cmpcss
new file mode 100755
index 0000000..d347a63
--- /dev/null
+++ b/build_system/cmpcss
@@ -0,0 +1,125 @@
1#!/usr/bin/python
2###############
3# cmpcss
4# Compress a CSS file in prepration for production use.
5#
6# AUTHOR
7# Michael Crute (mcrute@gmail.com)
8# DATE
9# 16 June 2006
10# VERSION
11# 1.0
12# PURPOSE
13# An implementation of a CSS compressor in Python. Written to
14# prepare development CSS to production ready CSS. Does the
15# following:
16# * Removes spaces intelligently
17# * Removes charset declarations
18# * Removes extra semicolons
19# * Flattens the file (tabs and line breaks)
20# USAGE
21# cmpcss site_dev.css > site_prod.css
22# LICENSE
23# You may copy and redistribute this program as you see fit, with no
24# restrictions.
25# WARRANTY
26# This program comes with NO warranty, real or implied. If it eats
27# your CSS, it's not my problem, you should have kept a backup.
28###############
29
30import sys
31import re
32#import string
33
34# The chewy caramel center of the program
35# Don't bitch about the short variable names, it makes it easy to read
36def cleanline(theLine):
37 # Kills line breaks, tabs, and double spaces
38 p = re.compile('(\n|\r|\t|\f|\v)+')
39 m = p.sub('',theLine)
40
41 # Kills double spaces
42 p = re.compile('( )+')
43 m = p.sub(' ',m)
44
45 # Removes last semicolon before }
46 p = re.compile('(; }|;})+')
47 m = p.sub('}',m)
48
49 # Removes space before {
50 p = re.compile('({ )+')
51 m = p.sub('{',m)
52
53 # Removes all comments
54 p = re.compile('/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/')
55 m = p.sub('',m)
56
57 # Strip off the Charset
58 p = re.compile('@CHARSET .*;')
59 m = p.sub('',m)
60
61 # Strip spaces before the {
62 p = re.compile(' {')
63 m = p.sub('{',m)
64
65 # Strip space after :
66 p = re.compile(': ')
67 m = p.sub(':',m)
68
69 # Strip space after ,
70 p = re.compile(', ')
71 m = p.sub(',',m)
72
73 # Strip space after ;
74 p = re.compile('; ')
75 m = p.sub(';',m)
76
77# May return to add color code compression
78# not a huge space saver so also not high priority
79# p = re.compile('.*#[0-9A-F]{6}.*')
80# cc = p.match(m)
81
82# if cc:
83# cc = compcolor(m)
84
85 return m
86
87#def compcolor(m):
88
89# Boring usage info for people too dumb to use the program
90def printusage():
91 print ''
92 print 'SoftGroup CSS Compressor'
93 print ''
94 print 'This is a compressor for CSS files.'
95 print 'As far as I know it doesn\'t break the standards'
96 print 'compliance of the file. If you can find a way'
97 print 'to make it break a file please email me.'
98 print ''
99 print 'Usage: cmpcss <filename>'
100 sys.exit()
101
102# The main routine
103if ( __name__ == "__main__" ):
104 if (len(sys.argv) <= 1):
105 printusage()
106
107 # Open the file for reading
108 try:
109 theFile = file(sys.argv[1], "r")
110 except IOError:
111 print 'I couldn\'t open your file.'
112 sys.exit()
113
114 # Initialize temp so it's not scoped to the for loop
115 temp = ''
116
117 # Loop through the file line by line and clean it
118 for line in theFile:
119 temp = temp + cleanline(line)
120
121 # Once more, clean the entire file string
122 print cleanline(temp)
123
124 # Cleanup after ourselves
125 theFile.close()
diff --git a/build_system/get_jsfiles.sed b/build_system/get_jsfiles.sed
new file mode 100755
index 0000000..09e7a6d
--- /dev/null
+++ b/build_system/get_jsfiles.sed
@@ -0,0 +1,25 @@
1#!/bin/sed -f
2#
3# SED script for parsing out include file names from
4# the application.js file.
5#
6
7# Remove single line comments first
8/^\s+\/\//d
9
10# Remove multi-line comments
11/^\s+\/\*.+/d
12/\/\*/,/\*\// {
13 s/.*//g
14}
15
16# Replace the require lines with just their contents
17s/this\.require\(["']([^"']*)["']\);/\1/
18
19# Remove all lines that don't end in js
20# assumes we are getting all of our JS files
21/js$/!d
22
23# Remove the spaces before and after the filename
24# assumes there are no spaces in the filename iteself
25s/\s*//
diff --git a/build_system/make.gzip b/build_system/make.gzip
new file mode 100755
index 0000000..a95ed04
--- /dev/null
+++ b/build_system/make.gzip
@@ -0,0 +1,130 @@
1#!/bin/bash
2#
3# ExxonMobil Designer Site Build Script
4# by Mike Crute, EYEMG (mcrute@eyemg.com)
5#
6# This is a pretty simple build script just export a
7# tag or the trunk from SVN and run ./make, running
8# make (w/out the ./) will not work. You can then
9# take the generated tarball and explode it on the
10# production server w/out any further configuration.
11#
12
13cd docroot
14
15# Create the build directory and copy over the cgi-bin
16mkdir -p build/{docroot,cgi-bin}
17cp -R ../cgi-bin/* build/cgi-bin/
18
19# Create a build date file
20echo "Designer Site Built `date +'%Y-%m-%d %H:%M:%S'` EST" > build/docroot/build.date
21echo "Code Version: `grep 'releaseVersion' classes/sme.namespace.js | cut -d"'" -f 2 `" >> build/docroot/build.date
22echo "Subversion Revision: `svn info | grep 'Revision' | awk '{ print $2 }'`" >> build/docroot/build.date
23
24# Remove stuff from the cgi-bin that does not belong in
25# production.
26rm build/cgi-bin/*.sql
27
28# Also copy over any files that don't need special processing
29cp -R images \
30 blank.gif \
31 favicon.ico \
32 custom_content \
33build/docroot/
34
35# Prepare the .htaccess file for production
36#
37# We use a sparse layout in development where each class is
38# in its own separate file but in production we use a solid
39# layout that is also gzipped so we have to un-comment the
40# gzip headers in our htaccess file.
41
42sed '
43 /### PRODUCTION ###/,/### END PRODUCTION ###/ {
44 /^###.*/d
45 s/#//g
46 }
47' .htaccess > build/docroot/.htaccess
48
49# Minify the PNG Behavior
50sed '
51 /\/\*/,/\*\// {
52 /.*/d;
53 }
54' pngbehavior.htc > build/docroot/pngbehavior.htc
55
56# Concatenate the Javascript files into a single library file
57#
58# application.js loads all the javascript files in the development
59# environment. When we go to production we need to parse out the
60# actual script names being loaded and cat them, in order, into
61# the final output application.js file.
62
63# GNU sed uses the -r flag for extended regular expressions,
64# Darwin uses the -E flag for regular expressions. If neither
65# of these hold true we might as well fail.
66if [[ `uname` == 'Linux' ]]; then
67 MYFILES=`sed -r -f ../build_system/get_jsfiles.sed application.js`
68elif [[ `uname` == 'Darwin' ]]; then
69 MYFILES=`sed -E -f ../build_system/get_jsfiles.sed application.js`
70else
71 print 'No valid sed command could be determined.'
72 exit 1
73fi
74
75for item in $MYFILES; do
76 cat $item >> build/docroot/application.js.in
77done
78
79# Remove development code from the application code
80# and append it to the libraries files
81sed '/^;;;.*/d' build/docroot/application.js.in >> build/docroot/application.js.out
82sed '/^\/\*;;;.*/d' build/docroot/application.js.out >> build/docroot/application.js
83rm build/docroot/application.js.in build/docroot/application.js.out
84
85# Minify index.html by removing leading spaces on each line
86# as well as the ID comment, blank lines, and any script tags
87# that appear in the <head> of the document.
88sed 's/^[[:space:]]*//; /^$/d; s/\n$//; /<!--/,/-->/ { /.*/d; }' index.html > build/docroot/index.html
89sed 's/^[[:space:]]*//; /^$/d; s/\n$//; /<!--/,/-->/ { /.*/d; }' logged_out.html > build/docroot/logged_out.html
90
91# Minify the application Javascript using the YUI Compressor
92java -jar ../build_system/yui_compressor.jar -o application.o build/docroot/application.js > /dev/null 2>&1
93mv application.o build/docroot/application.js
94
95# Minify the JSON data files
96mkdir -p build/docroot/data
97for item in `ls data/`; do
98 java -jar ../build_system/yui_compressor.jar -o build/docroot/data/$item data/$item > /dev/null 2>&1
99done
100
101# Can't minimize JSON, the semicolon at the end breaks everything
102cat data/card_tables.js > build/docroot/data/card_tables.js
103
104# Minify the application CSS using our custom compressor
105../build_system/cmpcss application.css > build/docroot/application.css
106../build_system/cmpcss specialcases.css > build/docroot/specialcases.css
107
108# Gzip all that should be gzipped. This really should be done server-side
109# but for now we work around it by statically compressing them at build time
110# and serving it with the correct headers in the .htaccess file
111gzip build/docroot/application.js
112gzip build/docroot/application.css
113gzip build/docroot/index.html
114
115mv build/docroot/application.js.gz build/docroot/application.js
116mv build/docroot/application.css.gz build/docroot/application.css
117mv build/docroot/index.html.gz build/docroot/index.html
118
119# Tar it all up in a development dump
120mv build aes_designer
121cd aes_designer
122
123# Removing the date since its really not needed
124tar -cjvf ../../aes_designer.tbz2 * > /dev/null 2>&1
125#tar -cjvf ../../aes_designer-`date +%Y%m%d_%H%M%S`.tbz2 * > /dev/null 2>&1
126
127
128cd ..
129
130rm -rf aes_designer/
diff --git a/build_system/yui_compressor.jar b/build_system/yui_compressor.jar
new file mode 100755
index 0000000..4efe293
--- /dev/null
+++ b/build_system/yui_compressor.jar
Binary files differ