# HG changeset patch # User cmlenz # Date 1188514188 0 # Node ID dc35e98823902291506db6f9e830a48bf1b6bfe1 # Parent d218020fb92aced753c92f23b176b8873632ff67 GenshiTutorial: add Atom feeds. diff --git a/examples/tutorial/geddit/controller.py b/examples/tutorial/geddit/controller.py --- a/examples/tutorial/geddit/controller.py +++ b/examples/tutorial/geddit/controller.py @@ -20,6 +20,18 @@ self.data = data @cherrypy.expose + @template.output('index.xml', method='xml') + def feed(self, id=None): + if id: + link = self.data.get(id) + if not link: + raise cherrypy.NotFound() + return template.render('info.xml', link=link) + else: + links = sorted(self.data.values(), key=operator.attrgetter('time')) + return template.render(links=links) + + @cherrypy.expose @template.output('index.html') def index(self): links = sorted(self.data.values(), key=operator.attrgetter('time')) @@ -27,8 +39,8 @@ @cherrypy.expose @template.output('info.html') - def info(self, code): - link = self.data.get(code) + def info(self, id): + link = self.data.get(id) if not link: raise cherrypy.NotFound() return template.render(link=link) @@ -54,8 +66,8 @@ @cherrypy.expose @template.output('comment.html') - def comment(self, code, cancel=False, **data): - link = self.data.get(code) + def comment(self, id, cancel=False, **data): + link = self.data.get(id) if not link: raise cherrypy.NotFound() if cherrypy.request.method == 'POST': diff --git a/examples/tutorial/geddit/static/layout.css b/examples/tutorial/geddit/static/layout.css --- a/examples/tutorial/geddit/static/layout.css +++ b/examples/tutorial/geddit/static/layout.css @@ -30,3 +30,11 @@ ul.comments blockquote { color: #333; font-style: normal; margin: 0; padding: 0; } +.action:link, .action:visited { background: #f3f3f3; border: 1px outset #ddd; + color: #666; font-size: 90%; padding: 0 .3em; +} +.action:link:hover, .action:visited:hover { background: #e8e8e8; + border-color: #aaa; color: #000; text-decoration: none; +} + +form .error { color: #b00; } diff --git a/examples/tutorial/geddit/templates/index.html b/examples/tutorial/geddit/templates/index.html --- a/examples/tutorial/geddit/templates/index.html +++ b/examples/tutorial/geddit/templates/index.html @@ -5,10 +5,12 @@ News +

News

-

Submit new link

+

Submit new link