Random notes from mg

a blog by Marius Gedminas

Marius is a Python hacker. He works for Programmers of Vilnius, a small Python/Zope 3 startup. He has a personal home page at http://gedmin.as. His email is marius@gedmin.as. He does not like spam, but is not afraid of it.

Sat, 16 May 2009

Enabling comments in PyBlosxom

I've just spent the whole night setting up blog comments. PyBlosxom doesn't make it painless, sadly, more like the opposite.

First: don't be scared by the list of comment-related plugins on the PyBlosxom site. There's only one important plugin: comments. All others depend on it and enhance its functionality. The last three or four times I was about to add comments to my blog I got scared at step one: evaluate the available plugins. Don't repeat my mistake!

Second, follow the instructions carefully. There's no shortcut.

Third, fix what's broken. Be prepared to debug the source code. print >> sys.stderr, "message" is your friend.

Fourth, fiddle with the look (CSS and HTML).

Fifth, write a blog post and eagerly await your first comments.

Step 3 screams for an explanation, doesn't it? Problem 1: the comments plugin requires that you use categories in your blog. I'm not (I'm holding out for tags). Workaround: comment out if entry['absolute_path'] check in cb_story and cb_story_end.

Problem 2: the AJAX post returns "Empty response from server". Workaround: modify cb_story_end to call readComments directly if entry['num_comments'] is None, since cb_story, which usually does the read, is not called during the AJAX post.

Problem 3: if you enable comment moderation (by setting comment_draft_ext to a different value from comment_ext), the AJAX post returns "Empty response from server" once more. Workaround: modify cb_prepare to notice this case and set data['moderated'] = True, create a new template comment-moderated and render it in cb_story_end just like the preview template is rendered; also modify __shouldOutput to return True when rendering comment-moderated.

I'll post patches to the pyblosxom mailing tomorrow, unless I forget. It's 6 am already, and I'm kind of sleepy. I just hope I haven't inadvertently broken my RSS feed or flooded any planets.

Oh, and a helpful hint: don't name the post you're writing comments.txt, or the #comments anchor will point to the start of the story instead of the comments.

posted at 06:13 | tags: | permanent link to this entry | 11 comments

Fri, 03 Apr 2009

Baking CSS into RSS

Wanted: PyBlosxom plugin to bake CSS styles into the RSS feed, i.e. replace things like <span style="keyword"> in the main blog pages with things like <span style="color: #ff7700"> in the RSS.

Also wanted: a spam-resistant comments plugin. (Maybe some/all of them are? I was always afraid to try.) And a tags plugin (categories are too limiting). And useful page titles. And a pony.

Update: Laurence Rowe and Alexander Artemenko suggested I check out cssutils. Alexander also pointed out that a similar question was asked on stackoverflow. Peter Bengtsson recently posted a similar tool built with lxml and regexps. Meanwhile, I took the plunge and installed a comments plugin, and even somehow managed not to get drowned in spam.

posted at 09:37 | tags: | permanent link to this entry | 0 comments

Sun, 16 Jan 2005

More on PyBlosxom

I want to store my blog in Subversion. Problem: Subversion does not preserve mtimes of files. Solution: a plugin like pyfilenamemtime, but different (I do not want to rename existing blog entries). Since I want to import my existing blog entries without renaming them, I wrote a plugin that reads timestamps from a separate text file. This should suffice, in addition to adding

[miscellany]
### Set use-commit-times to make checkout/update/switch/revert
### put last-committed timestamps on every file touched.
use-commit-times = yes

to ~/.subversion/config.

Now I want to have an RSS or Atom feed that validates. Answer: rss2renderer.

I'd like to have browsable archives for entries that do not fit on the front page (and then make the front page contain fewer entries). There are plugins in the PyBlosxom plugin registry that look promising: pyarchives, wbgpager.

More wishes: I want to be able to post blog entries with images. I'd like to be able to be able to add new blog entries with gnome-blogger and via a web form. And I want to have drafts that I can look at until I become satisfied and publish.

Stay tuned, if I figure out how to accomplish what I want, I'll blog about it.

posted at 21:38 | tags: | permanent link to this entry | 0 comments

Thu, 30 Sep 2004

Pyblosxom badness

I've just discovered that Pyblosxom's default (i.e. builtin) RSS template does not include dates nor IDs. I'm disappointed. This kind of breaks the whole "usable out of the box" feeling.

Google to the rescue: after a brief look at Blosxom and RSS and Daniel's pyblosxom RSS templates I've borrowed Daniel's story.rss with a different timezone substituted. Doesn't pyblosxom have a variable that would expand into the server's time zone? What about daylight savings time -- do I have to edit story.rss twice a year, or what?

I'm disappointed.

posted at 01:29 | tags: | permanent link to this entry | 0 comments