Hyperlink recipe tag list
authorW. Trevor King <wking@drexel.edu>
Fri, 23 Jul 2010 19:35:57 +0000 (15:35 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 23 Jul 2010 19:35:57 +0000 (15:35 -0400)
cookbook/server.py
cookbook/template/recipe.html

index 99dba5eaf85175e3939f7af0be4b48b46c5d010e..28d1142391df7384c348fc3c2080c97f10160651 100644 (file)
@@ -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 = [
+            '<a href="./?%s">%s</a>' % (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):
index d5c0f03ef3ce369cd730ac494370d4278dd5b6db..ac7a90ae8f5f8f3affe6ab37ced362c43af0f73d 100644 (file)
@@ -24,7 +24,7 @@
     {% endif %}
     {% if recipe.tags %}
         <span class="detail-field-header">Tags:</span>
-        <span class="detail-field-contents">{{ ', '.join(recipe.tags) }}
+        <span class="detail-field-contents">{{ ', '.join(tag_links) }}
        </span><br/>
     {% endif %}
     </p>