Permalink
Browse files

tagcloud in ux2.

  • Loading branch information...
chrisrossi committed Apr 9, 2012
1 parent 9ebf783 commit 793e847191c17dbbe2c151e0e88e28bb7b167c59
Showing with 87 additions and 0 deletions.
  1. +1 −0 karl/application.py
  2. +80 −0 karl/ux2/templates/tagcloud.pt
  3. +1 −0 karl/views/tags.py
  4. +5 −0 karl/views/tests/test_tags.py
View
@@ -83,6 +83,7 @@ def _get_egg_rev():
'templates/anonymous_formish_form.pt': 'templates/formish_form.pt',
'templates/community_formish_form.pt': 'templates/formish_form.pt',
'templates/layout_formish_form.pt': 'templates/formish_form.pt',
+ 'templates/community_tagcloud.pt': 'templates/tagcloud.pt',
}
@@ -0,0 +1,80 @@
+<div xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:tal="http://xml.zope.org/namespaces/tal"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ metal:use-macro="main_template">
+
+<div metal:fill-slot="content">
+
+ <header>
+ <a class="rightFloatLink" title="View tag listing"
+ href="taglisting.html">Tag listing</a>
+
+ <h1>${layout.page_title}</h1>
+ </header>
+
+ <div id="tagcloud"
+ metal:define-macro="tagcloud">
+ <h2 class="tagsHeaderSpace">
+ <form id="tag-form" action="" method="post"
+ onsubmit="this.action='showtag/'+getElementById('tag-field').value;
+ return true"
+ ><tal:x tal:condition="crumbs|False" tal:content="crumbs">SYSTEM / Tags</tal:x
+ ><tal:x tal:condition="not crumbs|True">${layout.project_name} / Tags</tal:x>
+ <input id="tag-field" class="tag_field" type="text" name="tag"
+ size="20" /></form>
+ </h2>
+
+ <p>This is the ${layout.project_name} tag cloud - a list of tags where size reflect
+ popularity.</p>
+
+ <span tal:repeat="e entries"
+ tal:attributes="class e['class']">
+ <a href="#" title=""
+ tal:attributes="href string:showtag/${e['name']};
+ title
+ string:count: ${e['count']}, weight: ${e['weight']};
+ "
+ tal:content="e['name']">NAME</a> </span>
+
+ </div>
+
+ <div id="taglisting"
+ metal:define-macro="taglisting">
+
+ <h2 class="tagsHeaderSpace">
+ <form id="tag-form" action="" method="post"
+ onsubmit="this.action='showtag/'+getElementById('tag-field').value;
+ return true"
+ ><tal:x tal:condition="crumbs|False" tal:content="crumbs">SYSTEM / Tags</tal:x
+ ><tal:x tal:condition="not crumbs|True">${layout.project_name} / Tags</tal:x> /
+ <input id="tag-field" class="tag_field" type="text" name="tag"
+ size="20" />
+ </form>
+ </h2>
+
+ <p>This page shows all the tags applied across ${layout.project_name}, with a
+ count of each tag.</p>
+
+ <table border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <th> Tag </th>
+ <th> Count </th>
+ </tr>
+
+ <tr tal:repeat="entry entries">
+ <td>
+ <a href="${layout.here_url}showtag/${entry['name']}"
+ >${entry['name']}</a>
+ </td>
+ <td>
+ ${entry['count']}
+ </td>
+ </tr>
+
+ </table>
+
+ </div>
+
+
+</div>
+</div>
View
@@ -310,6 +310,7 @@ def _calculateTagWeights(taglist):
return taglist
def tag_cloud_view(context, request):
+ request.layout_manager.layout.section_style = 'none'
page_title = 'Tag Cloud'
api = TemplateAPI(context, request, page_title)
tags = find_tags(context)
@@ -490,6 +490,7 @@ def _callFUT(self, context, request):
def test_wo_tags_tool(self):
request = testing.DummyRequest()
+ request.layout_manager = mock.Mock()
context = testing.DummyModel()
context.catalog = DummyCatalog()
@@ -499,6 +500,7 @@ def test_wo_tags_tool(self):
def test_w_tags_tool_empty(self):
request = testing.DummyRequest()
+ request.layout_manager = mock.Mock()
context = testing.DummyModel()
tags = context.tags = DummyTags()
tags.getCloud = lambda: []
@@ -510,6 +512,7 @@ def test_w_tags_tool_empty(self):
def test_w_tags_tool_one_tag(self):
request = testing.DummyRequest()
+ request.layout_manager = mock.Mock()
context = testing.DummyModel()
tags = context.tags = DummyTags()
tags.getCloud = lambda: [('foo', 1)]
@@ -526,6 +529,7 @@ def test_w_tags_tool_one_tag(self):
def test_w_tags_sorted_by_name(self):
request = testing.DummyRequest()
+ request.layout_manager = mock.Mock()
context = testing.DummyModel()
tags = context.tags = DummyTags()
tags.getCloud = lambda: [('tag_%03d' % x, x)
@@ -539,6 +543,7 @@ def test_w_tags_sorted_by_name(self):
def test_w_tags_exceeding_limit(self):
request = testing.DummyRequest()
+ request.layout_manager = mock.Mock()
context = testing.DummyModel()
tags = context.tags = DummyTags()
tags.getCloud = lambda: [('tag_%03d' % x, x)

0 comments on commit 793e847

Please sign in to comment.