2019-01-27 02:39:10 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# encoding: utf8
|
|
|
|
#
|
2019-02-03 01:29:56 +03:00
|
|
|
# Updates the "?v=x" in files:
|
|
|
|
# - docs/inter.css
|
|
|
|
# - docs/inter-ui.css
|
|
|
|
# - docs/_includes/preload-font-files.html
|
2019-01-27 02:39:10 +03:00
|
|
|
#
|
|
|
|
import os, sys, re
|
|
|
|
from os.path import dirname, basename, abspath, relpath, join as pjoin
|
|
|
|
sys.path.append(abspath(pjoin(dirname(__file__), 'tools')))
|
|
|
|
from common import BASEDIR, getVersion
|
|
|
|
|
|
|
|
version = getVersion()
|
|
|
|
|
|
|
|
|
|
|
|
def updateCSSFile(filename):
|
|
|
|
regex = re.compile(r'(url\("[^"]+?v=)([^"]+)("\))')
|
|
|
|
with open(filename, 'r') as f:
|
|
|
|
s = f.read()
|
|
|
|
s = regex.sub(lambda m: '%s%s%s' % (m.group(1), version, m.group(3)), s)
|
|
|
|
with open(filename, 'w') as f:
|
|
|
|
f.write(s)
|
|
|
|
|
|
|
|
|
|
|
|
def updateHTMLFile(filename):
|
2020-08-20 21:18:18 +03:00
|
|
|
regex = re.compile(r'((?:href|src)="[^"]+?v=)([^"]+)(")')
|
2019-01-27 02:39:10 +03:00
|
|
|
with open(filename, 'r') as f:
|
|
|
|
s = f.read()
|
|
|
|
s = regex.sub(lambda m: '%s%s%s' % (m.group(1), version, m.group(3)), s)
|
|
|
|
with open(filename, 'w') as f:
|
|
|
|
f.write(s)
|
|
|
|
|
|
|
|
|
2019-10-22 22:34:20 +03:00
|
|
|
updateCSSFile(pjoin(BASEDIR, 'misc', 'dist', 'inter.css'))
|
2020-08-20 21:18:18 +03:00
|
|
|
# updateHTMLFile(pjoin(BASEDIR, 'docs', '_includes', 'preload-font-files.html'))
|
|
|
|
updateHTMLFile(pjoin(BASEDIR, 'docs', 'lab', 'index.html'))
|
2019-10-22 22:34:20 +03:00
|
|
|
|
|
|
|
# Note: The website CSS file uses Jekyll variables to add ?v= so don't need this anymore.
|
2019-02-04 06:14:59 +03:00
|
|
|
# updateCSSFile(pjoin(BASEDIR, 'docs', 'inter.css'))
|
|
|
|
# updateCSSFile(pjoin(BASEDIR, 'docs', 'inter-ui.css'))
|