contrib/tmplrewrite.py
author Alexander Plavin <alexander@plav.in>
Wed, 18 Sep 2013 22:44:12 +0400
changeset 19746 9ad7dd9574a9
parent 8432 94ef2c8ce683
permissions -rwxr-xr-x
hgweb: add ajaxScrollInit function, which does the ajax requests and processing This function should be correctly called on a page, otherwise there is no effect. When called, it makes ajax requests for the next portion of changesets when the user scrolls to the end. Also, when the monitor is high so that the default amount of changesets isn't enough to fill it, multiple portions are loaded if needed after the page load.

#!/usr/bin/python
import sys, os, re

IGNORE = ['.css', '.py']
oldre = re.compile('#([\w\|%]+)#')

def rewrite(fn):
    f = open(fn)
    new = open(fn + '.new', 'wb')
    for ln in f:
        new.write(oldre.sub('{\\1}', ln))
    new.close()
    f.close()
    os.rename(new.name, f.name)

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print 'usage: python tmplrewrite.py [file [file [file]]]'
    for fn in sys.argv[1:]:
        if os.path.splitext(fn) in IGNORE:
            continue
        print 'rewriting %s...' % fn
        rewrite(fn)