# HG changeset patch # User k0s # Date 1257100218 18000 # Node ID 7e7fbdc64cc197785d9f89778602f30b54021764 # Parent 2a43e43a7e4d98c84925e6ef10e6c5bb18ee3035 enable atom support, this brings us to 2.0 diff -r 2a43e43a7e4d -r 7e7fbdc64cc1 bitsyblog/bitsyblog.py --- a/bitsyblog/bitsyblog.py Sun Nov 01 01:51:14 2009 -0400 +++ b/bitsyblog/bitsyblog.py Sun Nov 01 13:30:18 2009 -0500 @@ -25,14 +25,14 @@ import PyRSS2Gen import re -import utils # local import +import utils from blog import FileBlog from cStringIO import StringIO from docutils.utils import SystemMessage from genshi.builder import Markup from genshi.template import TemplateLoader -from lxml import etree +#from lxml import etree from markup.form import Form from paste.fileapp import FileApp from pkg_resources import resource_filename @@ -98,12 +98,13 @@ def __call__(self, environ, start_response): request = Request(environ) - # GENSHI: data dictionary + # genshi data dictionary request.environ['data'] = { 'site_name': self.site_name, 'request': request, 'link': self.link, 'logo': self.logo(request), - 'user_url': self.user_url } + 'user_url': self.user_url, + 'permalink': self.permalink } res = self.response_functions.get(request.method, self.error())(request) return res(environ, start_response) @@ -394,7 +395,7 @@ path = path[1:] if name: if name not in self.users: - exc.HTTPNotFound("No blog found for %s" % user) + exc.HTTPNotFound("No blog found for %s" % name) request.user = self.users[name] else: name = None @@ -623,17 +624,17 @@ retval = '
%s
' % body return retval - # this should be reenabled if 'system-message's again appear in the markup - try: - foo = etree.fromstring(retval) - except etree.XMLSyntaxError: - return retval - # should cleanup the
- for i in foo.getiterator(): - if dict(i.items()).get('class') == 'system-message': - i.clear() +# # XXX this should be reenabled if 'system-message's again appear in the markup +# try: +# foo = etree.fromstring(retval) +# except etree.XMLSyntaxError: +# return retval +# # should cleanup the
+# for i in foo.getiterator(): +# if dict(i.items()).get('class') == 'system-message': +# i.clear() - return etree.tostring(foo) +# return etree.tostring(foo) ### feeds @@ -689,39 +690,18 @@ def atom(self, request, blog, author=None): - retval = StringIO() - print >> retval, """ - -""" - if author: - title = "%s's blog" % author - link = request.host_url + '/' + author - else: - title = self.site_name + ' - atom' - link = request.application_url - - date = blog[0].date.isoformat() - print >> retval, '%s' % title - print >> retval, '' % link - print >> retval, '%s' % date - if author: - print >> retval, """ - - %s - """ % author - - for entry in blog: - print >> retval, '' - print >> retval, '%s' % cgi.escape(entry.title()) - print >> retval, '' % self.permalink(entry) - print >> retval, '%s' % entry.date.isoformat() - print >> retval, '%s' % cgi.escape(entry.body) + # data for genshi template + date = blog[0].date.isoformat() + data = request.environ['data'] + data['blog'] = blog + data['author'] = author + data['date'] = date - print >> retval, '' - - print >> retval, '' - return retval.getvalue() + # render the template + template = self.loader.load('atom.xml') + return template.generate(**data).render() + ### forms diff -r 2a43e43a7e4d -r 7e7fbdc64cc1 bitsyblog/templates/atom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bitsyblog/templates/atom.xml Sun Nov 01 13:30:18 2009 -0500 @@ -0,0 +1,25 @@ + + + + + + ${author}'s blog + + + + + ${site_name} - atom + + + + + ${date} + + + ${entry.title()} + + ${entry.date.isoformat()} + ${entry.body} + + diff -r 2a43e43a7e4d -r 7e7fbdc64cc1 bitsyblog/templates/blog.html --- a/bitsyblog/templates/blog.html Sun Nov 01 01:51:14 2009 -0400 +++ b/bitsyblog/templates/blog.html Sun Nov 01 13:30:18 2009 -0500 @@ -8,6 +8,7 @@ ${user} - ${site_name} + - - + + + diff -r 2a43e43a7e4d -r 7e7fbdc64cc1 bitsyblog/templates/index.html --- a/bitsyblog/templates/index.html Sun Nov 01 01:51:14 2009 -0400 +++ b/bitsyblog/templates/index.html Sun Nov 01 13:30:18 2009 -0500 @@ -7,8 +7,8 @@ ${site_name} - - + + diff -r 2a43e43a7e4d -r 7e7fbdc64cc1 bitsyblog/templates/site.html --- a/bitsyblog/templates/site.html Sun Nov 01 01:51:14 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ - diff -r 2a43e43a7e4d -r 7e7fbdc64cc1 setup.py --- a/setup.py Sun Nov 01 01:51:14 2009 -0400 +++ b/setup.py Sun Nov 01 13:30:18 2009 -0500 @@ -1,7 +1,7 @@ from setuptools import setup, find_packages import sys, os -version = '1.1.1' +version = '2.0' try: description = file('README.txt').read() @@ -33,10 +33,10 @@ 'python-dateutil', 'markup', 'skimpygimpy', - 'lxml', 'PyRSS2Gen', 'docutils', 'genshi', +# 'lxml', ], dependency_links=[ 'https://svn.openplans.org/svn/standalone/markup#egg=markup',