Skip to content

Commit

Permalink
Bring templating inhouse
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed Feb 26, 2024
1 parent a6a9175 commit 62f866f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ jobs:
- name: Install dependencies
run: make venv
- name: Rebuild website
run: . venv/bin/activate; python3 scripts/template.py
run: . venv/bin/activate; python3 -m notobuilder.ghpages
- name: Copy fonts to gh-pages dir
run: cp -r fonts out
- name: Deploy
Expand Down
18 changes: 17 additions & 1 deletion Lib/notobuilder/ghpages/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections import defaultdict
import os
import re
from glob import glob
Expand All @@ -11,6 +12,8 @@
from sh import git


DIFFBROWSERS_PROOF_RE = r"^(.*)-diffbrowsers_(.*).html$"

class FileTreeMaker(object):
def _recurse(self, parent_path, file_list, prefix, output_buf, level):
if len(file_list) == 0:
Expand Down Expand Up @@ -76,13 +79,26 @@ def main():
"path": result[4:],
}
)

proofs = defaultdict(list)
for result in glob(f"out/proof/{basename}/*html"):
if m := re.match(DIFFBROWSERS_PROOF_RE, os.path.basename(result)):
style, prooftype = m[1], m[2]
proofs[prooftype].append(
{
"name": style,
"path": result[4:],
}
)
# Sort by style
for k, v in proofs.items():
proofs[k] = list(sorted(v, key=lambda l: l["name"]))
families.append(
{
"name": fname,
"fonttree": fonttree,
"fontbakery": fontbakery,
"diffenator": diffenator,
"proofs": proofs,
}
)

Expand Down
16 changes: 12 additions & 4 deletions Lib/notobuilder/ghpages/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,28 @@ <h4>{{name}}</h4>
</li>
{{/diffenator}}
</ul>
{{/families}}

<h3>Proof sheets</h3>
<ul>
<li>
<a href="proof/glyphs.html">All glyphs</a>
Glyphs:
{{#proofs.glyphs}}<a href="{{path}}">{{name}}</a> {{/proofs.glyphs}}
</li>
<li>
Text:
{{#proofs.text}}<a href="{{path}}">{{name}}</a> {{/proofs.text}}
</li>
<li>
<a href="proof/text.html">Sample text</a>
Waterfall:
{{#proofs.waterfall}}<a href="{{path}}">{{name}}</a> {{/proofs.waterfall}}
</li>
<li>
<a href="proof/waterfall.html">Waterfall test</a>
Proofer:
{{#proofs.proofer}}<a href="{{path}}">{{name}}</a> {{/proofs.proofer}}
</li>
</ul>

{{/families}}
</div>
</div>
</body>
Expand Down

0 comments on commit 62f866f

Please sign in to comment.