3 Used to combine the different parts of GreyBox.
6 - Dojo's JavaScript compressor (http://dojotoolkit.org/docs/compressor_system.html). Place it under compression_lib/custom_rhino.jar
9 from compression_lib import AJS_minify
12 if __name__ == '__main__':
18 python combiner.py [full|gallery|window]
20 python combiner.py full
21 The files will be store in greybox_dist/* depending on the dist. type
26 output_dir = 'greybox'
35 append = lambda l, x: l.append('greybox_source/%s' % x)
38 append(js, 'base/base.js')
39 append(js, 'auto_deco.js')
40 append(css, 'base/base.css')
41 append(static, 'base/indicator.gif')
42 append(static, 'base/loader_frame.html')
45 append(js, 'set/set.js')
46 append(css, 'set/set.css')
47 append(static, 'set/next.gif')
48 append(static, 'set/prev.gif')
51 append(js, 'gallery/gallery.js')
52 append(css, 'gallery/gallery.css')
53 append(static, 'gallery/g_close.gif')
56 append(js, 'window/window.js')
57 append(css, 'window/window.css')
58 append(static, 'window/header_bg.gif')
59 append(static, 'window/w_close.gif')
67 elif type == 'gallery':
70 elif type == 'window':
73 sys.exit('Uknown type')
75 print 'Follwoing styles are used:'
79 print 'Follwoing JavaScript is used:'
87 shutil.rmtree(output_dir)
92 def concatFiles(f_list):
95 data.append(open(f, 'r').read())
96 return '\n\n'.join(data)
98 def copyFiles(f_list):
100 shutil.copy(f, output_dir)
103 fp = open('%s/%s' % (output_dir, 'gb_styles.css'), 'w')
104 fp.write(concatFiles(css))
106 print 'Compressed styles in %s' % ('greybox/gb_styles.css')
111 fp = open('%s/%s' % (output_dir, 'gb_scripts_tmp.js'), 'w')
112 fp.write(concatFiles(js))
115 AJS_minify.AJS_SRC = 'greybox_source/base/AJS.js'
116 AJS_minify.AJS_MINI_SRC = 'greybox/AJS_tmp.js'
117 files = ['greybox/gb_scripts_tmp.js', 'greybox_source/base/AJS_fx.js', 'static_files/help.js']
118 code_analyzer = AJS_minify.ExternalCodeAnalyzer(files)
119 composer = AJS_minify.AjsComposer(code_analyzer.findFunctions())
120 composer.writeToOutput()
122 os.popen('java -jar compression_lib/custom_rhino.jar -c greybox/AJS_tmp.js > greybox/AJS.js')
123 os.remove('greybox/AJS_tmp.js')
124 os.popen('java -jar compression_lib/custom_rhino.jar -c greybox_source/base/AJS_fx.js > greybox/AJS_fx.js')
125 print 'Compressed AJS.js and AJS.js into greybox/'
127 os.popen('java -jar compression_lib/custom_rhino.jar -c greybox/gb_scripts_tmp.js > greybox/gb_scripts.js')
128 os.remove('greybox/gb_scripts_tmp.js')
129 print 'Compressed JavaScript in %s' % ('greybox/gb_scripts.css')
131 #Append script_loaded
132 open('greybox/AJS.js', 'a').write('\nscript_loaded=true;')
133 open('greybox/AJS_fx.js', 'a').write('\nscript_loaded=true;')
134 open('greybox/gb_scripts.js', 'a').write('\nscript_loaded=true;')