Include version in CSS so that HTTP caches are not pointing to old versions
This commit is contained in:
parent
eda835f2f2
commit
c97111a594
3 changed files with 49 additions and 12 deletions
36
misc/versionize-css.py
Executable file
36
misc/versionize-css.py
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf8
|
||||
#
|
||||
# Updates the "?v=x" in docs/interface.css
|
||||
#
|
||||
from __future__ import print_function
|
||||
import os, sys, re
|
||||
from collections import OrderedDict
|
||||
from ConfigParser import RawConfigParser
|
||||
|
||||
|
||||
def main():
|
||||
rootDir = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
config = RawConfigParser(dict_type=OrderedDict)
|
||||
config.read(os.path.join(rootDir, 'src', 'fontbuild.cfg'))
|
||||
version = config.get('main', 'version')
|
||||
|
||||
regex = re.compile(r'(url\("[^"]+?v=)([^"]+)("\))')
|
||||
|
||||
cssFileName = os.path.join(rootDir, 'docs', 'interface.css')
|
||||
|
||||
s = ''
|
||||
with open(cssFileName, 'r') as f:
|
||||
s = f.read()
|
||||
|
||||
s = regex.sub(
|
||||
lambda m: '%s%s%s' % (m.group(1), version, m.group(3)),
|
||||
s
|
||||
)
|
||||
|
||||
with open(cssFileName, 'w') as f:
|
||||
f.write(s)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in a new issue