Skip to content

Commit

Permalink
tagcloud in ux2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Rossi committed Apr 9, 2012
1 parent 9ebf783 commit 793e847
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions karl/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}


Expand Down
80 changes: 80 additions & 0 deletions karl/ux2/templates/tagcloud.pt
Original file line number Diff line number Diff line change
@@ -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>
1 change: 1 addition & 0 deletions karl/views/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions karl/views/tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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: []
Expand All @@ -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)]
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 793e847

Please sign in to comment.