cache busting

This commit is contained in:
Marc Beninca 2023-07-06 12:50:14 +02:00
parent eb36f2d7b6
commit 6b3b978b61

View file

@ -12,26 +12,28 @@ def run(*args):
def main():
time = datetime.datetime.now()
time_id = time.strftime('%Y%m%d%H%M%S')
style = 'css'
script = 'js'
root = os.path.dirname(os.path.realpath(__file__))
input_directory = os.path.join(root, 'in')
out = os.path.join(root, 'out')
web = os.path.join(out, 'web')
css = os.path.join(web, style)
js = os.path.join(web, script)
gen = os.path.join(web, time_id)
css = os.path.join(gen, style)
js = os.path.join(gen, script)
#
run('rsync', '--archive', f'{input_directory}/', f'{web}/')
for directory in [css, js]:
os.makedirs(directory, exist_ok=True)
#
link_gv = os.path.join(root, 'link.gv')
link_svg = os.path.join(web, 'link.svg')
link_svg = os.path.join(gen, 'link.svg')
run('dot', link_gv, '-Tsvg', '-o', link_svg)
with open(link_svg, 'br') as f:
link_text = f.read().decode('u8')
page_file = os.path.join(web, 'index.html')
timestamp = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S')
page_text = f'''\
<!DOCTYPE html>
@ -41,8 +43,8 @@ def main():
<meta charset="UTF-8" />
<meta name="flattr:id" content="z3d26l" />
<meta name="viewport" content="initial-scale=1,width=device-width" />
<link rel="stylesheet" href="{style}/index.css" />
<script src="{script}/index.js"></script>
<link rel="stylesheet" href="{time_id}/{style}/index.css" />
<script src="{time_id}/{script}/index.js"></script>
<title>Marc Beninca</title>
</head>
@ -183,7 +185,7 @@ def main():
<footer>
<hr />
Last update: {timestamp}
Last update: {time.strftime('%Y/%m/%d %H:%M:%S')}
</footer>
</body>