1
1
mirror of https://github.com/rsms/inter.git synced 2024-09-19 06:40:16 +03:00

website: preload vf files. Additionally, update misc/tools/versionize to also patch docs/_includes/preload-font-files.html

This commit is contained in:
Rasmus Andersson 2019-01-26 15:39:10 -08:00
parent e5971f76ea
commit 0ab4a4cb3b
5 changed files with 38 additions and 33 deletions

View File

@ -251,7 +251,7 @@ pre_dist:
dist: zip_dist
$(MAKE) -j docs
misc/tools/versionize-css.py
misc/tools/versionize.py
@echo "——————————————————————————————————————————————————————————————————"
@echo ""
@echo "Next steps:"

View File

@ -0,0 +1,3 @@
<link rel="preload" href="font-files/Inter-UI.var.woff2?v=3.2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="font-files/Inter-UI-upright.var.woff2?v=3.2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="font-files/Inter-UI-italic.var.woff2?v=3.2" as="font" type="font/woff2" crossorigin>

View File

@ -35,6 +35,7 @@ endfor
<link rel="stylesheet" href="{{url_root}}inter-ui.css?v={{ release_version }}">
<link rel="stylesheet" href="{{url_root}}res/base.css?v={{ base_css_v }}">
<link rel="icon" type="image/png" href="{{url_root}}res/favicon.png">
{% include preload-font-files.html %}
<meta name="format-detection" content="telephone=no">
<meta property="twitter:card" content="summary">
<meta property="twitter:site" content="@rsms">

View File

@ -1,32 +0,0 @@
#!/usr/bin/env python
# encoding: utf8
#
# Updates the "?v=x" in docs/inter-ui.css
#
import os, sys
from os.path import dirname, basename, abspath, relpath, join as pjoin
sys.path.append(abspath(pjoin(dirname(__file__), 'tools')))
from common import BASEDIR, getVersion
import re
def main():
version = getVersion()
regex = re.compile(r'(url\("[^"]+?v=)([^"]+)("\))')
cssFileName = pjoin(BASEDIR, 'docs', 'inter-ui.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()

33
misc/tools/versionize.py Executable file
View File

@ -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'))