changeset 96:94b5806b9e2f

blog/item: various improvments: - title and publication date are now clickable if HTTP link of item is set - show labels (aka tags/categories) - text only content in body is urlized
author Goffi <goffi@goffi.org>
date Fri, 19 Jan 2018 18:19:57 +0100
parents e4ffb56efd4e
children e8955d01ad0c
files default/blog/item.html default/static/blog.css
diffstat 2 files changed, 47 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/default/blog/item.html	Fri Jan 19 18:17:06 2018 +0100
+++ b/default/blog/item.html	Fri Jan 19 18:19:57 2018 +0100
@@ -30,24 +30,47 @@
 
     <header>
         {% block header %}
-        <div class="title">{% block blog_title %}{{ item.title_xhtml or item.title or '' }}{% endblock %}</div>
-            {% block metadata %}
+        {# title and publication date link to a HTTP page if items_http_uri is set #}
+        {% set item_http_uri = items_http_uri.get(item.id) if items_http_uri is defined else none %}
+
+        <div class="title">
+            {% block blog_title scoped %}
+                {% set title = item.title_xhtml or item.title or '' %}
+                {% if item_http_uri %}
+                    <a href="{{item_http_uri}}">{{title}}</a>
+                {% else %}
+                    {{title}}
+                {% endif %}
+            {% endblock %}
+        </div>
+            {% block metadata scoped %}
             <div class="metadata">
             {% if identities is defined %}
                 <span class="author">{{identities[item.author_jid].nick | default(item.author)}}</span>
             {% else %}
                 <span class="author">{{item.author}}</span>
             {% endif %}
-            <span class="blog_data">{{item.published|date_fmt(fmt=dates_format)}}</span>
+            {% set published = item.published|date_fmt(fmt=dates_format) %}
+            {% if item_http_uri %}
+                <span class="blog_data"><a href="{{item_http_uri}}">{{published}}</a></span>
+            {% else %}
+                {{- published -}}
+            {% endif %}
             </div>
-
+            {% if item.tags %}
+                <div class="labels">
+                    {% for tag in item.tags %}
+                        <span>{{tag}}</span>
+                    {% endfor %}
+                </div>
+            {% endif %}
             {% endblock metadata %}
         {% endblock header %}
     </header>
 
     <div class="content{{' text' if not item.content_xhtml}}">
         {% block content %}
-        {{- item.content_xhtml or item.content or '' -}}
+        {{- item.content_xhtml or item.content|urlize or '' -}}
         {% endblock content %}
     </div>
 
--- a/default/static/blog.css	Fri Jan 19 18:17:06 2018 +0100
+++ b/default/static/blog.css	Fri Jan 19 18:19:57 2018 +0100
@@ -18,6 +18,11 @@
 
 /** header **/
 
+header a {
+    color: inherit;
+    text-decoration: inherit;
+}
+
 header .metadata {
     text-align: right;
 }
@@ -30,6 +35,20 @@
     content: ", ";
 }
 
+/*** labels ***/
+
+.labels {
+    text-align: right;
+}
+
+.labels span {
+	font-variant: small-caps;
+	font-size: 0.8rem;
+	background-color: #ddd;
+	border-radius: 0.4em;
+	padding: 0 0.5em;
+}
+
 
 /** content **/