fredag 03 sep 2004
Newline patch for PyTextile 2.0.8
This patch against PyTextile 2.0.8 prevents textile from adding a newline to the first line of a pre-block.
--- textile.py~ 2004-06-25 13:24:09.000000000 +0200
+++ textile.py 2004-09-03 14:00:53.000000000 +0200
@@ -1239,7 +1239,7 @@
attributes = self.parse_params(parameters, clear)
# Build the tag.
- open_tag = self.build_open_tag('pre', attributes) + '\n'
+ open_tag = self.build_open_tag('pre', attributes)
close_tag = '\n</pre>'
# Replace < and >.
söndag 22 aug 2004
Allow metadata in textile entries
This patch allows for metadata entries in .txtl files.
Example metadata:
title
#metakey metavalue
entry body text
The patch looks like this:
--- pyblosxom/contrib/entryparsers/txtl.py~ 2004-05-19 11:51:35.000000000 +0200
+++ pyblosxom/contrib/entryparsers/txtl.py 2004-08-16 17:51:49.000000000 +0200
@@ -190,11 +190,22 @@
def readfile(filename, request):
entryData = {}
- d = open(filename).read()
+ d = open(filename).readlines()
- # Grab title and body.
- title = d.split('\n')[0]
- body = d[len(title):]
+ # Grab title
+ entryData['title'] = d.pop(0).strip()
+
+ # this handles properties of the entry that are between
+ # the title and the body and start with a #
+ import re
+ while len(d) > 0:
+ match = re.match(r'^#(\w+)\s+(.*)', d[0])
+ if match:
+ d.pop(0)
+ entryData[match.groups()[0]] = match.groups()[1].strip()
+ else:
+ break
+ body = "\n" + ''.join(d)
# Grab textile configuration.
config = request.getConfiguration()
@@ -205,8 +216,7 @@
body = textile(body, head_offset=head_offset, validate=validate, output=output, encoding=encoding)
- entryData = {'title': title,
- 'body': body}
+ entryData['body'] = body
# Call the postformat callbacks
tools.run_callback('postformat',
The code is based on the standard pyblosxom entry parser for .txt-files.
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
fredag 20 aug 2004
sweet pyblosxom hacks
Sweet idea! Only accept blog entries via e-mail if they are PGP-signed.
onsdag 18 aug 2004
emacsmodes for blogging and for textile
It would be nice to have some emacs-modes for blogging. Textile-support would be nice too.
Some interesting URL:s to check further: