Ver código fonte

Shows next and previous blog posts in the article

Talha Mansoor 11 anos atrás
pai
commit
0b4b65397f
3 arquivos alterados com 40 adições e 0 exclusões
  1. 2 0
      ReadMe.md
  2. 15 0
      static/css/style.css
  3. 23 0
      templates/article.html

+ 2 - 0
ReadMe.md

@@ -17,3 +17,5 @@ on left. Content id
 ## tags
 
 Superscript, live filter
+
+Shows next and previous article with title

+ 15 - 0
static/css/style.css

@@ -147,6 +147,21 @@ ul.articles-in-tag li {
     text-decoration:none;
 }
 
+ul.articles_timeline {
+    list-style:none;
+    margin:0px;
+}
+
+ul.articles_timeline li.next_article {
+    float:right;
+    margin:0px;
+}
+
+ul.articles_timeline li.previous_article  {
+float:left;
+margin:0px;
+}
+
 /* Categories */
 .list-of-categories span {
     vertical-align: super;

+ 23 - 0
templates/article.html

@@ -23,6 +23,29 @@
 <div class="row-fluid">
     <div class="span8 offset1 article-content">
         {{ article.content }}
+        <aside>
+        {% for an_artcile in dates %}
+        {% if an_artcile.url == article.url %}
+        {% set index = loop.index0 %}
+        {% if not loop.first %}
+        {% set next_article = dates[index-1] %}
+        {% endif %}
+        {% if not loop.last %}
+        {% set previous_article = dates[index+1] %}
+        {% endif %}
+        <nav>
+        <ul class="articles_timeline">
+            {% if previous_article %}
+            <li class="previous_article">« <a href="/{{ previous_article.url }}" title="Previous: {{ previous_article.title }}">{{ previous_article.title }}</a></li>
+            {% endif %}
+            {% if next_article %}
+            <li class="next_article"><a href="/{{ next_article.url }}" title="Next: {{ next_article.title }}">{{ next_article.title }}</a> »</li>
+            {% endif %}
+        </ul>
+        </nav>
+        {% endif %}
+        {% endfor %}
+        </aside>
     </div>
     <section>
     <div class="span2 offset1">