]> git.ipfire.org Git - ipfire.org.git/commitdiff
blog: Create module for posts
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Jul 2018 11:53:06 +0000 (12:53 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Jul 2018 11:53:06 +0000 (12:53 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/blog/modules/post.html [new file with mode: 0644]
src/templates/blog/post.html
src/web/__init__.py
src/web/blog.py

index ecf7f3ca6085339442ca642c4e30cfe6aef57af3..b52c7515f9226f5e29674fc2b31593a03ce05b81 100644 (file)
@@ -116,6 +116,11 @@ templates_blog_DATA = \
 
 templates_blogdir = $(templatesdir)/blog
 
+templates_blog_modules_DATA = \
+       src/templates/blog/modules/post.html
+
+templates_blog_modulesdir = $(templates_blogdir)/modules
+
 templates_modules_DATA = \
        src/templates/modules/menu.html
 
diff --git a/src/templates/blog/modules/post.html b/src/templates/blog/modules/post.html
new file mode 100644 (file)
index 0000000..c8ab8e6
--- /dev/null
@@ -0,0 +1,10 @@
+<div class="blog-post">
+       <h5 class="mb-0">{{ post.title }}</h5>
+
+       <p class="small text-muted">
+               {{ _("by") }} <a href="/authors/{{ post.author.uid }}">{{ post.author.name }}</a>,
+               {{ locale.format_date(post.published, shorter=True, relative=False) }}
+       </p>
+
+       {% raw post.text %}
+</div>
index 37053a793f5c78f777cd3c0c9779b07122cfd014..4532880e9320d960ed214a69a4d8bf6d768edd78 100644 (file)
@@ -4,15 +4,8 @@
 
 {% block main %}
        <div class="card">
-               <div class="card-body blog-post">
-                       <h5 class="mb-0">{{ post.title }}</h5>
-
-                       <p class="small text-muted">
-                               {{ _("by") }} <a href="/authors/{{ post.author.uid }}">{{ post.author.name }}</a>,
-                               {{ locale.format_date(post.published, shorter=True, relative=False) }}
-                       </p>
-
-                       {% raw post.text %}
+               <div class="card-body">
+                       {% module BlogPost(post) %}
                </div>
        </div>
 {% end block %}
index 6a1f9218c3429205c84bccd1157ac1d84de9b517..94d31e38c59bcd2d9f73b5c72da76e1d7ed6ba00 100644 (file)
@@ -39,6 +39,9 @@ class Application(tornado.web.Application):
                                "format_month_name" : self.format_month_name,
                        },
                        "ui_modules" : {
+                               "BlogPost"             : blog.PostModule,
+
+                               # Old modules
                                "Advertisement"        : AdvertisementModule,
                                "DonationBox"          : DonationBoxModule,
                                "DonationButton"       : DonationButtonModule,
index 06f8c2ef025963d8edc1711874f1e03b3f6981d9..90f8c86b555282c644ea9221dae26f77e492bbb5 100644 (file)
@@ -4,6 +4,8 @@ import tornado.web
 
 import handlers_base as base
 
+from . import ui_modules
+
 class PostHandler(base.BaseHandler):
        def get(self, slug):
                entry = self.planet.get_entry_by_slug(slug)
@@ -11,3 +13,8 @@ class PostHandler(base.BaseHandler):
                        raise tornado.web.HTTPError(404)
 
                self.render("blog/post.html", post=entry)
+
+
+class PostModule(ui_modules.UIModule):
+       def render(self, post):
+               return self.render_string("blog/modules/post.html", post=post)