|
0
|
1 |
#!/usr/bin/python |
|
|
2 |
|
|
|
3 |
import os |
|
|
4 |
from time import time |
|
|
5 |
import re |
|
|
6 |
|
|
|
7 |
os.system("rm -rf temp") |
|
|
8 |
os.system("mkdir temp") |
|
|
9 |
|
|
|
10 |
timestamp = int(time()) |
|
|
11 |
for (prefix, destDir, destFile, containerFile) in [("c_", "../media/js/client/", "c_client-min.js","../../cm/templates/site/text_view_comments.html"), |
|
|
12 |
("f_", "../media/js/client/", "f_client-min.js", "../../cm/templates/site/text_view_frame.html")] : |
|
|
13 |
os.system("rm %s%s"%(destDir, destFile)) |
|
|
14 |
os.system("touch %s%s"%(destDir, destFile)) |
|
|
15 |
|
|
|
16 |
os.system("find ../media/js/client -name \"%s*.js\" > files"%prefix) |
|
|
17 |
os.system("find ../media/js/site -name \"%s*.js\" >> files"%prefix) |
|
|
18 |
|
|
|
19 |
f = open("files") |
|
|
20 |
try: |
|
|
21 |
for fname in f : |
|
|
22 |
fullfilename = fname.replace('\n','') |
|
|
23 |
os.system("java -jar ../../cm/scripts/lib/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar --preserve-semi " + fullfilename + ">>" + destDir + destFile) |
|
|
24 |
finally: |
|
|
25 |
f.close() |
|
|
26 |
os.system("rm files") |
|
|
27 |
|
|
|
28 |
# change reference to js to add datetimestamp int(time()) |
|
|
29 |
# to prevent browser caching |
|
|
30 |
print "" |
|
|
31 |
print "setting timestamp %d in %s, commit the file" %(timestamp,containerFile) |
|
|
32 |
|
|
|
33 |
input = open(containerFile).read() |
|
|
34 |
p = re.compile('%s\?(\d*)"'%destFile) |
|
|
35 |
new_input = p.sub('%s?%d"' % (destFile,timestamp),input) |
|
|
36 |
ff = open(containerFile,'w') |
|
|
37 |
ff.write(new_input) |
|
|
38 |
ff.close() |
|
|
39 |
|
|
|
40 |
os.system("rm -rf temp") |