constance

Scripts for generating (an earlier obsolete version of) my personal web site
git clone https://code.djc.id.au/git/constance/
commit 6db1706dae87027d0e247b094851477c08b856d8
parent 7866f895d3859966e92093c8e5ed926f749f8379
Author: Dan Callaghan <djc@djc.id.au>
Date:   Fri, 19 Sep 2008 02:06:56 +1000

optional previous/next links

Diffstat:
MTODO | 1-
Mconfig.defaults | 3+++
Mstatic/css/common.css | 8++++++++
Mtemplates/multiple.xml | 9+++++++++
4 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/TODO b/TODO
@@ -18,7 +18,6 @@
 - something better for viewutils.tag_list (at least fix URL quoting)
 - have almost completely ditched colubrid, just need to replace StaticExports for testing then rm it
 - use encoding from config for blog.py instead of hard-coding utf8
-- config option to add next/prev links to page (as well as the link rels)
 - markdown typography/smartypants
   - or even just, better markdown
 - generate goog sitemaps
diff --git a/config.defaults b/config.defaults
@@ -13,6 +13,9 @@ email =
 # The maximum number of entries (of any kind) to be shown on each page.
 entries_per_page = 20
 
+# Whether to include explicit previous/next <A> links for paged browsing (when needed). <LINK> elements are always included.
+show_prev_next = False
+
 # The maximum number of entries to be included in feeds.
 entries_in_feed = 20
 
diff --git a/static/css/common.css b/static/css/common.css
@@ -149,6 +149,14 @@ div.blocksep {
     white-space: nowrap;
 }
 
+/* Previous/next links, if enabled */
+#prevnextlinks {
+    padding: 2em 0;
+    clear: both;
+    border-top: 1px solid #ddd;
+    text-align: center;
+}
+
 /* Links at the bottom */
 #links {
     padding: 0.5em 2em 2em 2em;
diff --git a/templates/multiple.xml b/templates/multiple.xml
@@ -22,5 +22,14 @@
     ${show_entry(entry, show_comments=False)}
 </py:for>
 
+<p id="prevnextlinks"
+   py:if="defined('offset') and config.getboolean('global', 'show_prev_next')"
+   py:with="show_prev = bool(offset);
+            show_next = len(sorted_entries) > offset + config.getint('global', 'entries_per_page')">
+    <a py:if="show_prev" rel="prev" href="?offset=${max(0, offset - 20)}">Newer entries</a>
+    <py:if test="show_prev and show_next">—</py:if>
+    <a py:if="show_next" rel="next" href="?offset=${offset + 20}">Older entries</a>
+</p>
+
 </body>
 </html>