From: Michael Tremer Date: Tue, 17 Jul 2018 11:53:06 +0000 (+0100) Subject: blog: Create module for posts X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f91dfcc70ef2c01d766309211259693ff98bb505;p=ipfire.org.git blog: Create module for posts Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index ecf7f3ca..b52c7515 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 00000000..c8ab8e66 --- /dev/null +++ b/src/templates/blog/modules/post.html @@ -0,0 +1,10 @@ +
+
{{ post.title }}
+ +

+ {{ _("by") }} {{ post.author.name }}, + {{ locale.format_date(post.published, shorter=True, relative=False) }} +

+ + {% raw post.text %} +
diff --git a/src/templates/blog/post.html b/src/templates/blog/post.html index 37053a79..4532880e 100644 --- a/src/templates/blog/post.html +++ b/src/templates/blog/post.html @@ -4,15 +4,8 @@ {% block main %}
-
-
{{ post.title }}
- -

- {{ _("by") }} {{ post.author.name }}, - {{ locale.format_date(post.published, shorter=True, relative=False) }} -

- - {% raw post.text %} +
+ {% module BlogPost(post) %}
{% end block %} diff --git a/src/web/__init__.py b/src/web/__init__.py index 6a1f9218..94d31e38 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -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, diff --git a/src/web/blog.py b/src/web/blog.py index 06f8c2ef..90f8c86b 100644 --- a/src/web/blog.py +++ b/src/web/blog.py @@ -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)