söndag 22 aug 2004

xhtml plugin for pyblosxom

I wanted pyblosxom to send application/xhtml+xml to browsers that claim to support it so I whipped together a pyblosxom-plugin to do it.

I needed to modify two files from pyblosxom too. First the cgi, pyblosxom.cgi to make it recognize HTTP_ACCEPT:

--- pyblosxom/web/pyblosxom.cgi~        2004-05-04 22:53:48.000000000 +0200
+++ pyblosxom/web/pyblosxom.cgi 2004-08-22 14:02:31.000000000 +0200
@@ -34,7 +34,8 @@
     d = {}
     for mem in ["HTTP_HOST", "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", 
             "QUERY_STRING", "REMOTE_ADDR", "REQUEST_METHOD", "REQUEST_URI", 
-            "SCRIPT_NAME", "HTTP_IF_NONE_MATCH", "HTTP_IF_MODIFIED_SINCE"]:
+            "SCRIPT_NAME", "HTTP_IF_NONE_MATCH", "HTTP_IF_MODIFIED_SINCE",
+            "HTTP_ACCEPT"]:
         d[mem] = os.environ.get(mem, "")
     req.addHttp(d)

I also needed to modify the default renderer to not escape the body of entries:

--- pyblosxom/Pyblosxom/renderers/blosxom.py~   2004-05-28 02:55:08.000000000 +0200
+++ pyblosxom/Pyblosxom/renderers/blosxom.py    2004-08-22 13:01:55.000000000 +0200
@@ -125,7 +125,7 @@
 
         output = []
 
-        if data["content-type"].endswith("xml"):
+        if data["content-type"].endswith("/xml"):
             quotes = {"'": "'", '"': """}
             entry['title'] = escape(entry['title'],quotes)
             entry.setData(escape(entry.getData(),quotes))

The plugin itself can be downloaded here

copyright © 1999-2008 Ludvig Omholt | min publika pgpnyckel | version 4.0 (r1109M) using pyblosxom 1.1 RC1
stargirl.org - moderskeppet Valid XHTML 1.0! Valid CSS! RSS Feed
Dumma robotar kan skicka sin skräppost för automatisk klassificering hit: honung@ludde.net