]> git.ipfire.org Git - ipfire.org.git/commitdiff
Add new blog post design
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Jul 2018 11:43:05 +0000 (12:43 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Jul 2018 11:43:05 +0000 (12:43 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/scss/_variables.scss
src/scss/style.scss
src/templates/base.html
src/templates/blog/base.html [new file with mode: 0644]
src/templates/blog/post.html [new file with mode: 0644]
src/web/__init__.py
src/web/blog.py [new file with mode: 0644]

index 4cc5dfb4f3f2911b257b6ecfae80d2b217380667..ecf7f3ca6085339442ca642c4e30cfe6aef57af3 100644 (file)
@@ -76,6 +76,7 @@ backenddir = $(pythondir)/ipfire
 
 web_PYTHON = \
        src/web/__init__.py \
+       src/web/blog.py \
        src/web/handlers.py \
        src/web/handlers_accounts.py \
        src/web/handlers_admin.py \
@@ -109,6 +110,12 @@ templates_DATA = \
 
 templatesdir = $(datadir)/templates
 
+templates_blog_DATA = \
+       src/templates/blog/base.html \
+       src/templates/blog/post.html
+
+templates_blogdir = $(templatesdir)/blog
+
 templates_modules_DATA = \
        src/templates/modules/menu.html
 
index 368405466cbb18347876825aa656defc32f88fd2..f20da77035916e0a131b625f4a2912b568634ee1 100644 (file)
@@ -69,7 +69,7 @@ $lead-font-size:                      1.5rem;
 $small-font-size:                      87.5%;
 
 // Headings
-$headings-font-weight:         400;
+$headings-font-weight:         500;
 $headings-line-height:         1.5;
 $headings-margin-bottom:       1.5rem;
 $headings-color:                       $blue-grey-900;
index 5d4ba335f487cf9acc06e25fa40dab94bcfbcdd6..13bac62f2a2a616759a81f6e5af3ee9a16ea1160 100644 (file)
@@ -219,6 +219,10 @@ footer {
        }
 }
 
+.blog-post {
+       // Custom CSS for blog posts goes here
+}
+
 // Sidebar navigation
 
 #sidebar .nav {
index 1fbc93e5e17eb9080bd06f3912dadecc2b5beae6..826f2395435da5435b6cd02b9afabcfb7e1d0dbc 100644 (file)
@@ -27,7 +27,7 @@
 
                                <a class="navbar-brand mx-auto text-dark" href="/">
                                        <img src="{{ static_url("img/ipfire-tux.png") }}" alt="IPFire" height="32px" />
-                                       IP<strong>Fire</strong>
+                                       IP<strong>Fire</strong> {% block subtitle %}{% end block %}
                                </a>
 
                                <div class="collapse navbar-collapse" id="navbar">
@@ -46,6 +46,7 @@
                {% block container %}
                        <div class="container">
                                {% block body %}{% end block %}
+                               {% block content %}{% end block %}
                        </div>
                {% end block %}
 
diff --git a/src/templates/blog/base.html b/src/templates/blog/base.html
new file mode 100644 (file)
index 0000000..5c02aa5
--- /dev/null
@@ -0,0 +1,37 @@
+{% extends "../base.html" %}
+
+{% block subtitle %}{{ _("Blog") }}{% end block %}
+
+{% block menu %}{% end block %}
+
+{% block content %}
+       <div class="row">
+               <div class="col-12 col-md-3">
+                       <nav class="mb-5">
+                               <ul class="nav flex-column">
+                                       <li class="nav-item">
+                                               <a class="nav-link {% if request.path == "/" %}active{% end %}" href="/">
+                                                       {{ _("Newest") }}
+                                               </a>
+                                       </li>
+
+                                       <li class="nav-item">
+                                               <a class="nav-link {% if request.path == "/featured" %}active{% end %}" href="/featured">
+                                                       {{ _("Featured") }}
+                                               </a>
+                                       </li>
+
+                                       <li class="nav-item">
+                                               <a class="nav-link {% if request.path == "/tags/lightning-wire-labs" %}active{% end %}" href="/tags/lightning-wire-labs">
+                                                       {{ _("Lightning Wire Labs") }}
+                                               </a>
+                                       </li>
+                               </ul>
+                       </nav>
+               </div>
+
+               <div class="col">
+                       {% block main %}{% end block %}
+               </div>
+       </div>
+{% end block %}
diff --git a/src/templates/blog/post.html b/src/templates/blog/post.html
new file mode 100644 (file)
index 0000000..37053a7
--- /dev/null
@@ -0,0 +1,18 @@
+{% extends "base.html" %}
+
+{% block title %}{{ post.title }}{% end block %}
+
+{% 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>
+       </div>
+{% end block %}
index e35322c894523d5ad44d2bec94448321fda5337d..6a1f9218c3429205c84bccd1157ac1d84de9b517 100644 (file)
@@ -11,6 +11,8 @@ import ipfire
 from handlers import *
 from ui_modules import *
 
+from . import blog
+
 BASEDIR = os.path.join(os.path.dirname(__file__), "..")
 
 class Application(tornado.web.Application):
@@ -117,6 +119,11 @@ class Application(tornado.web.Application):
                        (r"/(de|en)/(.*)", LangCompatHandler),
                ])
 
+               # blog.ipfire.org
+               self.add_handlers(r"blog(\.dev)?\.ipfire\.org", [
+                       (r"/post/(.*)", blog.PostHandler),
+               ])
+
                # downloads.ipfire.org
                self.add_handlers(r"downloads?(\.dev)?\.ipfire\.org", [
                        (r"/", DownloadsIndexHandler),
diff --git a/src/web/blog.py b/src/web/blog.py
new file mode 100644 (file)
index 0000000..06f8c2e
--- /dev/null
@@ -0,0 +1,13 @@
+#!/usr/bin/python
+
+import tornado.web
+
+import handlers_base as base
+
+class PostHandler(base.BaseHandler):
+       def get(self, slug):
+               entry = self.planet.get_entry_by_slug(slug)
+               if not entry:
+                       raise tornado.web.HTTPError(404)
+
+               self.render("blog/post.html", post=entry)