diff --git a/README.md b/README.md
index 6a9f8a4..700f0fd 100644
--- a/README.md
+++ b/README.md
@@ -5,4 +5,3 @@ it's like pronouns.page but i made it
### todo
* social links
-* templating and embeds on /u/... pages
diff --git a/_server.py b/_server.py
index 32f3587..ec74860 100644
--- a/_server.py
+++ b/_server.py
@@ -10,6 +10,7 @@ import flask
import json
import os
+from DotIndex import DotIndex
from typing import Union, Callable
from flask import request, redirect
from werkzeug.middleware.proxy_fix import ProxyFix
@@ -120,6 +121,48 @@ def create_folder_serve(directory) -> Callable:
x.__name__ = directory
return x
+def get_template(json, username):
+ def add_to_output(starting, json, key, title):
+ starting += f'
{title}
'
+ for i in json[key]:
+ starting += f"""
{icons[i[1]]} {escape_html(i[0])}
"""
+ return starting + "
"
+
+ json = DotIndex(json)
+
+ icons = {
+ "1": '{escape_html(json.display_name)}
{escape_html(json.description)}
' # type: ignore
+
+ inner = add_to_output(inner, json, "names", "Names");
+ inner = add_to_output(inner, json, "pronouns", "Pronouns");
+ inner = add_to_output(inner, json, "honorifics", "Honorifics");
+ inner = add_to_output(inner, json, "compliments", "Compliments");
+ inner = add_to_output(inner, json, "relationship", "Relationship
Descriptions");
+
+ inner += "
"
+
+ return title, inner, styles, embed
+
+def get_user_page(user):
+ x = open(f"{CONTENT_DIRECTORY}user.html", "r").read()
+ try:
+ user_json = json.loads(open(f"{SAVING_DIRECTORY}{user}.json", "r").read())
+ except FileNotFoundError:
+ return x.replace("{{TEMPLATE}}", '
User not found!
Sign up -
Log in').replace("{{TITLE}}", "User not found - InfoPage")
+
+ title, inner, styles, embed = get_template(user_json, user)
+
+ return x.replace("")(create_file_serve("user.html"))
+app.route("/u/
")(get_user_page)
app.route("/home")(home)
app.route("/js/")(create_folder_serve("js"))
diff --git a/public/user.html b/public/user.html
index 68275af..b32d4af 100644
--- a/public/user.html
+++ b/public/user.html
@@ -2,7 +2,7 @@
- Loading user...
+ {{TITLE}}
@@ -11,6 +11,6 @@
-
+ {{TEMPLATE}}