summaryrefslogtreecommitdiff
path: root/misc/tools/versionize.py
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@figma.com>2019-01-27 02:39:10 +0300
committerRasmus Andersson <rasmus@figma.com>2019-01-27 02:39:10 +0300
commit0ab4a4cb3b3c1b261952971682bb9fe9d1e05ab0 (patch)
tree82de0504e0ad617dfcb27ed8dc26707a3d7004ad /misc/tools/versionize.py
parente5971f76eaf171518f9b7005a9faab9f090cc20f (diff)
downloadinter-0ab4a4cb3b3c1b261952971682bb9fe9d1e05ab0.tar.xz
website: preload vf files. Additionally, update misc/tools/versionize to also patch docs/_includes/preload-font-files.html
Diffstat (limited to 'misc/tools/versionize.py')
-rwxr-xr-xmisc/tools/versionize.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/misc/tools/versionize.py b/misc/tools/versionize.py
new file mode 100755
index 000000000..6064294e6
--- /dev/null
+++ b/misc/tools/versionize.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# encoding: utf8
+#
+# Updates the "?v=x" in docs/inter-ui.css
+#
+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):
+ regex = re.compile(r'(href="[^"]+?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)
+
+
+updateCSSFile(pjoin(BASEDIR, 'docs', 'inter-ui.css'))
+updateHTMLFile(pjoin(BASEDIR, 'docs', '_includes', 'preload-font-files.html'))