Ticket #2749 (closed defect: fixed)

Opened 6 months ago

Last modified 2 months ago

ListTagged in 0.6 does not give the titles of the pages from the first heading

Reported by: blyth Assigned to: athomas
Priority: normal Component: TagsPlugin
Severity: normal Keywords: ListTagged
Cc: blyth@hep1.phys.ntu.edu.tw Trac Release: 0.11

Description

In prior versions of TracTags the full title of pages as gleaned from the first heading on the page was presented in the ListTagged? list of pages making the list much more informative than just the page names

Attachments

Change History

03/17/08 04:38:59 changed by blyth

  • owner changed from jimbydamonk to athomas.
  • component changed from TracTagsXmlrpcPlugin to TagsPlugin.

03/17/08 08:16:31 changed by athomas

This is a "feature" of using 0.11's resource system. If people really want this behaviour back I can special-case the Wiki title.

05/29/08 08:06:46 changed by jsilence

I'd second the feature request...

-jsl

06/02/08 04:50:04 changed by blyth

  • cc set to blyth@hep1.phys.ntu.edu.tw.

This would make ListTagged so much more useful to me that I would like to re-state my enhancement request

06/03/08 22:51:16 changed by blyth

Here is my diff to do precisely what I requested, I hope that this can be added to trunk.

Index: macros.py
===================================================================
--- File macros.py (revision 3766)
+++ File macros.py (working copy)
@@ -13,6, +13,8 @@
  from tractags.api import TagSystem 
  from genshi.builder import tag as builder 
   
+ from trac.wiki import model 
+ import re 
   
  def render_cloud(env, req, cloud, renderer=None): 
      """Render a tag cloud 
@@ -70,6, +72,20 @@
   
   
  class ListTaggedMacro(WikiMacroBase): 
+  
+     first_head = re.compile('=\s+([^=]*)=') 
+  
+     def wikipage_first_heading(self, page): 
+         from trac.wiki import model 
+         page = model.WikiPage(self.env, page) 
+         title = '' 
+         if page.exists: 
+             ret = self.__class__.first_head.search(page.text) 
+             title = ret and ret.group(1) or '' 
+  
+         return title 
+  
+  
      def expand_macro(self, formatter, name, content): 
          req = formatter.req 
          query_result = TagSystem(self.env).query(req, content) 
@@ -83,15, +99,21 @@
          for resource, tags in sorted(query_result, 
                                       key=lambda r: str(r[0].id)): 
              tags = sorted(tags) 
+  
+            if resource.realm == 'wiki': 
+                 desc = ' ' + self.wikipage_first_heading(resource.id) 
+             else: 
+                 desc = '' 
+  
              if tags: 
                  rendered_tags = [ 
                      link(resource('tag', tag)) 
                      for tag in tags 
                      ] 
-                 li = builder.li(link(resource), ' (', rendered_tags[0], 
+                 li = builder.li(link(resource), desc,' (', rendered_tags[0], 
                                  [(' ', tag) for tag in rendered_tags[1:]], 
                                  ')') 
              else: 
-                 li = builder.li(link(resource)) 
+                 li = builder.li(link(resource), desc ) 
              ul(li, '\n') 
          return ul 

06/21/08 11:08:29 changed by athomas

  • status changed from new to closed.
  • resolution set to fixed.

(In [3880]) Reimplement descriptions for tagged objects. Fixes #2749.

Note: This is a tag provider API change.


Add/Change #2749 (ListTagged in 0.6 does not give the titles of the pages from the first heading)




Change Properties
Action