]> git.ipfire.org Git - ipfire.org.git/commitdiff
blog: Add page for authors
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Jul 2018 12:11:22 +0000 (13:11 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Jul 2018 12:11:22 +0000 (13:11 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/blog/author.html [new file with mode: 0644]
src/templates/blog/base.html
src/web/__init__.py
src/web/blog.py

index b52c7515f9226f5e29674fc2b31593a03ce05b81..f69cbcc4e67337941e9fd18e172fea148be648a5 100644 (file)
@@ -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 (file)
index 0000000..81792aa
--- /dev/null
@@ -0,0 +1,30 @@
+{% extends "base.html" %}
+
+{% block title %}{{ author.name }}{% end block %}
+
+{% block main %}
+       <div class="card">
+               <div class="card-body">
+                       <h5>{{ _("%s's posts") % author.name }}</h5>
+
+                       {% for post in posts %}
+                               <strong class="mb-0">
+                                       <a href="/post/{{ post.slug }}">{{ post.title }}</a>
+                               </strong>
+                               <p class="text-muted small">
+                                       {{ locale.format_date(post.published, shorter=True, relative=False) }}
+                               </p>
+                       {% end %}
+               </div>
+       </div>
+{% end block %}
+
+{% block right %}
+       <div class="col-md-3 text-center">
+               <img class="img-fluid rounded-circle mb-4" src="{{ author.gravatar_icon(160) }}" alt="{{ author.name }}" />
+
+               <p>{{ author.name }}</p>
+
+               <a href="mailto:{{ author.email }}">Email</a>
+       </div>
+{% end block %}
index 5c02aa5c738466f340ecd8578845ded7e425e4a3..53cfa450767cc930d5b121f1d54500032921a795 100644 (file)
@@ -33,5 +33,7 @@
                <div class="col">
                        {% block main %}{% end block %}
                </div>
+
+               {% block right %}{% end block %}
        </div>
 {% end block %}
index 94d31e38c59bcd2d9f73b5c72da76e1d7ed6ba00..63cd2b10e29225314d1a6c70efb20cf5d99b0bd3 100644 (file)
@@ -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),
                ])
 
index 90f8c86b555282c644ea9221dae26f77e492bbb5..59e9d845581314b79d5cdde37b711fad955e209b 100644 (file)
@@ -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)