src/cm/scripts/compressjs.py
author Simon Descarpentries <sid@sopinspace.com>
Fri, 20 Sep 2013 16:28:40 +0200
changeset 536 0c625ce49a81
parent 0 40c8f766c9b8
permissions -rwxr-xr-x
- updating jQuery (1.3.2 -> 1.10.2), jQuery UI, jQuery modules - [text_view_frame.html] Add some JS driven CSS tricks for iPad - [text_view_frame.html] move throbber's hiding-call in nested text_view_comments iframe onload signal (so it works with jQuery 1.10.2 and the hiding timing is good) - [text_view_frame.html][base.html] factorize req_yui.html et req_jquery.html - [main_tabs][text_tabs][f_client-min.js] rewrite jQuery UI Tabs API calls select in active - [base.css] CSS fix grey frame appearence for all tabs - hg remove bgiframe -> not loaded in templates anymore - hg remove header_custom.html -> the file has been empty since 4 years - hg remove controls.html -> the file has been empty since 4 years

#!/usr/bin/python

import os
from time import time
import re

os.system("rm -rf temp")
os.system("mkdir temp")

timestamp = int(time())
for (prefix, destDir, destFile, containerFile) in [("c_", "../media/js/client/", "c_client-min.js","../../cm/templates/site/text_view_comments.html"),
                                                   ("f_", "../media/js/client/", "f_client-min.js", "../../cm/templates/site/text_view_frame.html")] :
    os.system("rm %s%s"%(destDir, destFile))
    os.system("touch %s%s"%(destDir, destFile))
    
    os.system("find ../media/js/client -name \"%s*.js\" > files"%prefix)
    os.system("find ../media/js/site -name \"%s*.js\" >> files"%prefix)
    
    f = open("files")    
    try:
        for fname in f :
            fullfilename = fname.replace('\n','')
            os.system("java -jar ../../cm/scripts/lib/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar --preserve-semi " + fullfilename + ">>" + destDir + destFile)
    finally: 
        f.close()
    os.system("rm files")
    
    # change reference to js to add datetimestamp int(time())
    # to prevent browser caching
    print ""
    print "setting timestamp %d in %s, commit the file" %(timestamp,containerFile)
    
    input = open(containerFile).read()
    p = re.compile('%s\?(\d*)"'%destFile)
    new_input = p.sub('%s?%d"' % (destFile,timestamp),input)
    ff = open(containerFile,'w')
    ff.write(new_input)
    ff.close()
    
os.system("rm -rf temp")