From: Michael Tremer Date: Tue, 17 Jul 2018 12:11:22 +0000 (+0100) Subject: blog: Add page for authors X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfc0823ac7d6bf23ebe12c8cd10f8e01e9b3d9d8;p=ipfire.org.git blog: Add page for authors Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index b52c7515..f69cbcc4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -111,6 +111,7 @@ templates_DATA = \ templatesdir = $(datadir)/templates templates_blog_DATA = \ + src/templates/blog/author.html \ src/templates/blog/base.html \ src/templates/blog/post.html diff --git a/src/templates/blog/author.html b/src/templates/blog/author.html new file mode 100644 index 00000000..81792aa7 --- /dev/null +++ b/src/templates/blog/author.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} + +{% block title %}{{ author.name }}{% end block %} + +{% block main %} +
+
+
{{ _("%s's posts") % author.name }}
+ + {% for post in posts %} + + {{ post.title }} + +

+ {{ locale.format_date(post.published, shorter=True, relative=False) }} +

+ {% end %} +
+
+{% end block %} + +{% block right %} +
+ {{ author.name }} + +

{{ author.name }}

+ + Email +
+{% end block %} diff --git a/src/templates/blog/base.html b/src/templates/blog/base.html index 5c02aa5c..53cfa450 100644 --- a/src/templates/blog/base.html +++ b/src/templates/blog/base.html @@ -33,5 +33,7 @@
{% block main %}{% end block %}
+ + {% block right %}{% end block %} {% end block %} diff --git a/src/web/__init__.py b/src/web/__init__.py index 94d31e38..63cd2b10 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -124,6 +124,7 @@ class Application(tornado.web.Application): # blog.ipfire.org self.add_handlers(r"blog(\.dev)?\.ipfire\.org", [ + (r"/authors/(\w+)", blog.AuthorHandler), (r"/post/(.*)", blog.PostHandler), ]) diff --git a/src/web/blog.py b/src/web/blog.py index 90f8c86b..59e9d845 100644 --- a/src/web/blog.py +++ b/src/web/blog.py @@ -6,6 +6,20 @@ import handlers_base as base from . import ui_modules +class AuthorHandler(base.BaseHandler): + def get(self, uid): + author = self.accounts.get_by_uid(uid) + if not author: + raise tornado.web.HTTPError(404, "User is unknown") + + # Get all posts from this author + posts = self.planet.get_entries_by_author(author.uid) + if not posts: + raise tornado.web.HTTPError(404, "User has no posts") + + self.render("blog/author.html", author=author, posts=posts) + + class PostHandler(base.BaseHandler): def get(self, slug): entry = self.planet.get_entry_by_slug(slug)