This commit is contained in:
Tim Van Baak 2022-07-16 16:14:30 -07:00
parent 54e28c36d4
commit cab9495315
2 changed files with 38 additions and 3 deletions

View File

@ -435,13 +435,24 @@ def build_all(path_prefix, lexicon_name):
os.remove(pathto("article", filename)) os.remove(pathto("article", filename))
print("Writing article pages...") print("Writing article pages...")
l = len(articles) l = len(articles)
from jinja2 import Environment, FileSystemLoader, select_autoescape
env = Environment(loader=FileSystemLoader('lexipython/templates'), autoescape=select_autoescape(['html']))
template = env.get_template("page-skeleton.html")
for idx in range(l): for idx in range(l):
article = articles[idx] article = articles[idx]
with open(pathto("article", article.title_filesafe + ".html"), "w", encoding="utf-8", newline='') as f: with open(pathto("article", article.title_filesafe + ".html"), "w", encoding="utf-8", newline='') as f:
content = article.build_default_content() content = article.build_default_content()
article_html = page.format( #article_html = page.format(
title = article.title, # title = article.title,
content = content) # content = content)
tmp = {
"lexicon": "lexicon",
"prompt": "prompt",
"title": "title",
"sidebar_rows": ["hello", "world"],
"contentblocks": ["<h1>hello</h1>", "world"],
}
article_html = template.render(**tmp)
f.write(article_html) f.write(article_html)
print(" Wrote " + article.title) print(" Wrote " + article.title)

View File

@ -0,0 +1,24 @@
<html>
<head>
<title>{{title}} | {{lexicon}}</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../lexicon.css">
</head>
<body>
<div id="wrapper">
<div id="header">
<h2 id="title">{{lexicon}}</h2>
<p>{{prompt}}</p>
</div>
<div id="sidebar">
<table>{% for row in sidebar_rows %}
<tr><td>{{row}}</td></tr>{% endfor %}
</table>
</div>
<div id="content">{% for contentblock in contentblocks %}
<div class="contentblock">{{contentblock}}</div>{% endfor %}
</div>
</div>
</body>
</html>