← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~huwshimi/launchpad/tag-cloud-removal-709009 into lp:launchpad

 

Huw Wilkins has proposed merging lp:~huwshimi/launchpad/tag-cloud-removal-709009 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #709009 in Launchpad itself: "Tag clouds are very hard to read"
  https://bugs.launchpad.net/launchpad/+bug/709009

For more details, see:
https://code.launchpad.net/~huwshimi/launchpad/tag-cloud-removal-709009/+merge/81689

This removes the tag cloud from bug listings and replaces it with a list of bugs ordered by most used. A screenshot of the change is here: https://launchpadlibrarian.net/84759427/tags_screenshot.png

I know the approach for the JavaScript is a little ugly, if there are suggestions for doing it a better way they are more than welcome.
-- 
https://code.launchpad.net/~huwshimi/launchpad/tag-cloud-removal-709009/+merge/81689
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~huwshimi/launchpad/tag-cloud-removal-709009 into lp:launchpad.
=== modified file 'lib/canonical/launchpad/icing/style.css'
--- lib/canonical/launchpad/icing/style.css	2011-11-02 21:19:13 +0000
+++ lib/canonical/launchpad/icing/style.css	2011-11-09 08:38:25 +0000
@@ -656,6 +656,23 @@
     margin-left: 1em;
 }
 
+/* Tags portlet */
+.tag-list {
+    margin-bottom: 0.5em;
+    }
+.tag-list li {
+    padding-bottom: 0;
+    }
+.tag-count {
+    display: inline-block;
+    min-width: 1.5em;
+    text-align: right;
+    padding-right: 0.25em;
+    }
+.edit-official-tags {
+    margin-top: 1em;
+}
+
 /* === Translations === */
 
 .translation code {font-weight: bold;} /* an interpolation code, such as %i */

=== modified file 'lib/lp/bugs/browser/bugtarget.py'
--- lib/lp/bugs/browser/bugtarget.py	2011-07-28 17:31:16 +0000
+++ lib/lp/bugs/browser/bugtarget.py	2011-11-09 08:38:25 +0000
@@ -1413,10 +1413,6 @@
         # Use path_only here to reduce the size of the rendered page.
         return "+bugs?field.tag=%s" % urllib.quote(tag)
 
-    def _calculateFactor(self, tag, count, max_count, official_tags):
-        bonus = 1.5 if tag in official_tags else 1
-        return (count / max_count) + bonus
-
     @property
     def tags_cloud_data(self):
         """The data for rendering a tags cloud"""
@@ -1428,12 +1424,11 @@
         return sorted(
             [dict(
                 tag=tag,
-                factor=self._calculateFactor(
-                    tag, count, max_count, official_tags),
+                count=count,
                 url=self._getSearchURL(tag),
                 )
             for (tag, count) in tags.iteritems()],
-            key=itemgetter('tag'))
+            key=itemgetter('count'), reverse=True)
 
     @property
     def show_manage_tags_link(self):

=== modified file 'lib/lp/bugs/templates/bugtarget-portlet-bugtags.pt'
--- lib/lp/bugs/templates/bugtarget-portlet-bugtags.pt	2009-12-03 18:33:22 +0000
+++ lib/lp/bugs/templates/bugtarget-portlet-bugtags.pt	2011-11-09 08:38:25 +0000
@@ -26,6 +26,26 @@
           else {
             portlet.set('innerHTML',
                         response.responseText + portlet.get('innerHTML'));
+            var show_more_link = Y.one('#show-more-tags-link');
+            var show_less_link = Y.one('#show-less-tags-link');
+            var tag_list = Y.all('.tag-list li');
+            if (tag_list.size() > 10) {
+                var extra_tags = tag_list.slice(10);
+                extra_tags.addClass('hidden');
+                show_more_link.removeClass('hidden');
+                show_more_link.on('click', function(e) {
+                    e.halt();
+                    extra_tags.removeClass('hidden');
+                    show_more_link.addClass('hidden');
+                    show_less_link.removeClass('hidden');
+                });
+                show_less_link.on('click', function(e) {
+                    e.halt();
+                    extra_tags.addClass('hidden');
+                    show_more_link.removeClass('hidden');
+                    show_less_link.addClass('hidden');
+                });
+            }
           }
         }
 
@@ -36,7 +56,9 @@
       });
     });
   </script>
-  <ul>
+  <a href="" id="show-more-tags-link" class="js-action hidden">Show all tags&hellip;</a>
+  <a href="" id="show-less-tags-link" class="js-action hidden">Show less tags&hellip;</a>
+  <ul class="edit-official-tags">
     <li tal:condition="view/show_manage_tags_link">
       <a class="sprite edit"
          tal:attributes="href context/fmt:url/+manage-official-tags">

=== modified file 'lib/lp/bugs/templates/bugtarget-portlet-tags-content.pt'
--- lib/lp/bugs/templates/bugtarget-portlet-tags-content.pt	2011-06-08 17:51:43 +0000
+++ lib/lp/bugs/templates/bugtarget-portlet-tags-content.pt	2011-11-09 08:38:25 +0000
@@ -4,12 +4,14 @@
      class="portletBody">
   <div class="section" tal:define="tags_cloud_data view/tags_cloud_data">
     <h2 tal:condition="tags_cloud_data">Tags</h2>
-    <div style="text-align: justify">
-      <a tal:repeat="tag_info tags_cloud_data"
-         tal:content="tag_info/tag"
-         tal:attributes="href tag_info/url;
-                        style string:font-size: ${tag_info/factor}em" />
-    </div>
+    <ul class="tag-list">
+      <li tal:repeat="tag_info tags_cloud_data">
+        <span tal:content="tag_info/count"
+              class="tag-count" />
+        <a tal:content="tag_info/tag"
+         tal:attributes="href tag_info/url" />
+      </li>
+    </ul>
   </div>
 </div>
 


Follow ups