From: W. Trevor King Date: Fri, 23 Jul 2010 19:35:57 +0000 (-0400) Subject: Hyperlink recipe tag list X-Git-Tag: v0.1~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1f31799b6d0a30c79492c365914f07a26b14d508;p=cookbook.git Hyperlink recipe tag list --- diff --git a/cookbook/server.py b/cookbook/server.py index 99dba5e..28d1142 100644 --- a/cookbook/server.py +++ b/cookbook/server.py @@ -25,6 +25,7 @@ import os import random import re import types +from urllib import urlencode import uuid from xml.sax import saxutils @@ -82,8 +83,12 @@ class Server (object): recipe = random.choice(self.cookbook) else: recipe = self.cookbook.index[name] + tag_links = [ + '%s' % (urlencode({'tag':t}), t) + for t in recipe.tags] template = self.env.get_template('recipe.html') - return template.render(cookbook=self.cookbook, recipe=recipe) + return template.render(cookbook=self.cookbook, recipe=recipe, + tag_links=tag_links) @cherrypy.expose def add_tag(self, name, tag): diff --git a/cookbook/template/recipe.html b/cookbook/template/recipe.html index d5c0f03..ac7a90a 100644 --- a/cookbook/template/recipe.html +++ b/cookbook/template/recipe.html @@ -24,7 +24,7 @@ {% endif %} {% if recipe.tags %} Tags: - {{ ', '.join(recipe.tags) }} + {{ ', '.join(tag_links) }}
{% endif %}