Commits

Christian Jann committed 1956cbc

Generate "Read more..." links via ".. raw:: html"

Just insert

.. raw:: html

<!-- more -->

into a blog post to generate a "Read more..." link, which links
to the full post.

Comments (0)

Files changed (2)

tinkerer/ext/patch.py

 '''
 import re
 import xml.dom.minidom
+from tinkerer.ext.uistr import UIStr
 
 try:
     from html.entities import name2codepoint
     doc = xml.dom.minidom.parseString(in_str)
     patch_node(doc, docpath)
 
+    body = doc.toxml()
+    if(docname!=None):
+        body = make_read_more_link(body, docpath, docname)
+    
     if link_title:
-        return hyperlink_title(doc.toxml(), docpath, docname)
+        return hyperlink_title(body, docpath, docname)
     else:
-        return doc.toxml()
+        return body
 
 
 
 
 
 
+def make_read_more_link(body, docpath, docname):            
+    marker_more="<!-- more -->"
+    pos=body.find(marker_more)
+    if(pos>-1):
+      body = body[:pos]
+      body = body + ('<a class="readmore" href="%s.html"><b>%s</b></a>' % 
+        (docpath + docname, UIStr.READ_MORE))
+    return body
+
+
+
 def patch_node(node, docpath):
     '''
     Recursively patches links in nodes.

tinkerer/ext/uistr.py

         UIStr.NEWER = unicode(_("Newer"), "utf-8")
         UIStr.OLDER = unicode(_("Older"), "utf-8")
         UIStr.PAGE_FMT = unicode(_("Page %d"), "utf-8")
+        UIStr.READ_MORE = unicode(_("Read more..."), "utf-8")