[+] Static page generation
This commit is contained in:
@@ -160,3 +160,4 @@ cython_debug/
|
|||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
config.toml
|
config.toml
|
||||||
|
public/index.html
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from hypy_utils import write
|
||||||
|
|
||||||
|
import bot
|
||||||
|
import db
|
||||||
|
import gentree
|
||||||
|
|
||||||
|
src = Path(__file__).parent
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# Delete dist if already exists, and copy public to dist
|
||||||
|
shutil.rmtree(src / "dist", ignore_errors=True)
|
||||||
|
shutil.copytree(src / "public", src / "dist")
|
||||||
|
|
||||||
|
# Pre-render all channel info
|
||||||
|
for channel in db.Channel.select():
|
||||||
|
html = bot.channel_info(channel.username)
|
||||||
|
write(src / f"dist/c/{channel.username}.html", html)
|
||||||
|
|
||||||
|
# Generate the full tree
|
||||||
|
gentree.gen_tree(src / "dist")
|
||||||
|
|
||||||
+2
-2
@@ -27,9 +27,9 @@ def dfs(channel: str):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def gen_tree():
|
def gen_tree(d: Path = src / "public"):
|
||||||
of = dfs("hykilp")
|
of = dfs("hykilp")
|
||||||
write(src / "public/index.html", (src / "public/layout-full-tree.html").read_text()
|
write(d / "index.html", (src / "public/layout-full-tree.html").read_text()
|
||||||
.replace("{{CONTENT}}", of))
|
.replace("{{CONTENT}}", of))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user