templates_blog_DATA = \
src/templates/blog/author.html \
src/templates/blog/base.html \
+ src/templates/blog/index.html \
src/templates/blog/post.html
templates_blogdir = $(templatesdir)/blog
templates_blog_modules_DATA = \
- src/templates/blog/modules/post.html
+ src/templates/blog/modules/post.html \
+ src/templates/blog/modules/posts.html
templates_blog_modulesdir = $(templates_blogdir)/modules
--- /dev/null
+{% extends "base.html" %}
+
+{% block title %}{{ _("Welcome!") }}{% end block %}
+
+{% block main %}
+ <div class="card">
+ <div class="card-body">
+ {% module BlogPosts(posts) %}
+ </div>
+ </div>
+{% end block %}
--- /dev/null
+{% for i, post in enumerate(posts) %}
+ {% module BlogPost(post) %}
+
+ {% if i < (len(posts) - 1) %}
+ <div class="divider"></div>
+ {% end %}
+{% end %}
},
"ui_modules" : {
"BlogPost" : blog.PostModule,
+ "BlogPosts" : blog.PostsModule,
# Old modules
"Advertisement" : AdvertisementModule,
# blog.ipfire.org
self.add_handlers(r"blog(\.dev)?\.ipfire\.org", [
+ (r"/", blog.IndexHandler),
(r"/authors/(\w+)", blog.AuthorHandler),
(r"/post/(.*)", blog.PostHandler),
])
from . import ui_modules
+class IndexHandler(base.BaseHandler):
+ def get(self):
+ posts = self.planet.get_entries(limit=3)
+
+ self.render("blog/index.html", posts=posts)
+
+
class AuthorHandler(base.BaseHandler):
def get(self, uid):
author = self.accounts.get_by_uid(uid)
class PostModule(ui_modules.UIModule):
def render(self, post):
return self.render_string("blog/modules/post.html", post=post)
+
+
+class PostsModule(ui_modules.UIModule):
+ def render(self, posts):
+ return self.render_string("blog/modules/posts.html", posts=posts)