diff options
author | raven <raven> | 2021-06-18 21:13:56 +0000 |
---|---|---|
committer | raven <raven> | 2021-06-18 21:13:56 +0000 |
commit | a1cc107b3c65ff110124576d3609043f593a67f4 (patch) | |
tree | bd46d2e0e145162c6a3eff6ee72154c3a58e0a1c | |
parent | 4bd4bcbccb9e7772da337f30d9b62147877bc3d9 (diff) |
actually add the files
-rw-r--r-- | apioforum/templates/view_user.html | 22 | ||||
-rw-r--r-- | apioforum/user.py | 19 |
2 files changed, 41 insertions, 0 deletions
diff --git a/apioforum/templates/view_user.html b/apioforum/templates/view_user.html new file mode 100644 index 0000000..c9d9c1c --- /dev/null +++ b/apioforum/templates/view_user.html @@ -0,0 +1,22 @@ +{% from 'common.html' import disp_post,ts %} +{% extends 'base.html' %} +{% block header %} +<h1>{%block title %}{{user.username|e}}{% endblock %}</h1> +{% endblock %} + +{%block content%} +<div class="user_info"> + <div class="user_bio_quote"> + <div class="user_bio">{{rendered_bio|safe}}</div> + <p class="user_bio_attribution">— {{user.username|e}}</p> + </div> + <dl> + <dt>joined</dt> + {% if user.joined %} + <dd>{{ts(user.joined)}}</dd> + {% else %} + <dd>a very long time ago</dd> + {% endif %} + </dl> +</div> +{% endblock %} diff --git a/apioforum/user.py b/apioforum/user.py new file mode 100644 index 0000000..cdf38d3 --- /dev/null +++ b/apioforum/user.py @@ -0,0 +1,19 @@ +# user pages + +from flask import ( + Blueprint, render_template, abort, g +) + +from .db import get_db +from .mdrender import render + +bp = Blueprint("user", __name__, url_prefix="/user") + +@bp.route("/<username>") +def view_user(username): + db = get_db() + user = db.execute("SELECT * FROM users WHERE username = ?;",(username,)).fetchone() + if user is None: + abort(404) + return render_template("view_user.html", + user=user, rendered_bio=render(user['bio'] or "hail GEORGE")) |