Render HTML version of DAG with pan-and-zoom

This commit is contained in:
Jack Grigg 2022-02-21 13:00:05 +00:00
parent 84d5b99258
commit 33aafd211f
3 changed files with 41 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
__pycache__
public/*.html
public/*.svg
github_schema.json

View File

@ -7,9 +7,9 @@
<h1>Zcash Developers Hub</h1>
<p>Eventually this will be a common resource for development teams working on Zcash.</p>
<p>Currently this is just hosting DAGs showing dependencies between issues and PRs, for several Zcash teams.</p>
<p><a href="zcash-core-dag.svg">ECC core team DAG</a></p>
<p><a href="zcash-wallet-dag.svg">ECC wallet team DAG</a></p>
<p><a href="zcash-zf-dag.svg">ZF DAG</a></p>
<p><a href="zcash-halo2-dag.svg">Halo2-focused DAG</a></p>
<p><a href="/zcash-core-dag">ECC core team DAG</a></p>
<p><a href="/zcash-wallet-dag">ECC wallet team DAG</a></p>
<p><a href="/zcash-zf-dag">ZF DAG</a></p>
<p><a href="/zcash-halo2-dag">Halo2-focused DAG</a></p>
</body>
</html>

View File

@ -276,6 +276,42 @@ def main():
os.makedirs('public', exist_ok=True)
ag.draw('public/zcash-%s-dag.svg' % DAG_VIEW)
# Render the HTML version!
with open('public/zcash-%s-dag.svg' % DAG_VIEW) as f:
svg_data = f.read()
svg_start = svg_data.find('<svg')
html_data = '''<!DOCTYPE html>
<html>
<head>
<title>Zcash %s DAG</title>
<!-- Pan/zoom SVGs -->
<script src="https://bumbu.me/svg-pan-zoom/dist/svg-pan-zoom.min.js"></script>
<link rel="stylesheet" href="zcash-dag.css">
<style>
@media (prefers-color-scheme: dark) {
body {
/* Material dark theme surface colour */
background-color: #121212;
}
}
</style>
</head>
<body>
<div id="dag">%s</div>
<script>
svgPanZoom('#dag > svg', {
zoomScaleSensitivity: 0.4
});
</script>
</body>
</html>
''' % (DAG_VIEW, svg_data[svg_start:])
with open('public/zcash-%s-dag.html' % DAG_VIEW, 'w') as f:
f.write(html_data)
if __name__ == '__main__':
if GITHUB_TOKEN and ZENHUB_TOKEN: