Commits

Anonymous committed 6d05172

Follow-up to r6295: make the file revision string information global to the module.

Also enhances the plugins admin panel so that it can show that information.

Comments (0)

Files changed (12)

sample-plugins/HelloWorld.py

 """Example macro."""
 
+revision = "$Rev$"
+url = "$URL$"
+
 #
 # The following shows the code for macro, old-style.
 #
     the !MacroList macro (usually used in the TracWikiMacros page).
     """
 
-    revision = "$Rev$"
-    url = "$URL$"
-
     def expand_macro(self, formatter, name, args):
         """Return some output that will be displayed in the Wiki content.
 

sample-plugins/Timestamp.py

 """Inserts the current time (in seconds) into the wiki page."""
 
+revision = "$Rev$"
+url = "$URL$"
+
 #
 # The following shows the code for macro, old-style.
 #
 class TimestampMacro(WikiMacroBase):
     """Inserts the current time (in seconds) into the wiki page."""
 
-    revision = "$Rev$"
-    url = "$URL$"
-
     def expand_macro(self, formatter, name, args):
         t = datetime.now(utc)
         return tag.b(format_datetime(t, '%c'))

sample-plugins/permissions/authz_policy.py

 #
 # Author: Alec Thomas <alec@swapoff.org>
 
+revision = "$Rev$"
+url = "$URL$"
 
 """Permission policy enforcement through an authz-like configuration file.
 
 
 class AuthzPolicy(Component):
 
-    revision = "$Rev$"
-    url = "$URL$"
-
     implements(IPermissionPolicy)
 
     authz_file = Option('authz_policy', 'authz_file', None,

sample-plugins/permissions/public_wiki_policy.py

 from trac.core import *
 from trac.perm import IPermissionPolicy
 
+revision = "$Rev$"
+url = "$URL$"
+
 class PublicWikiPolicy(Component):
-    """Sample permission policy plugin illustrating how to check 
+    """Allow public access to some wiki pages.
+
+    This is a sample permission policy plugin illustrating how to check 
     permission on realms.
 
     Don't forget to integrate that plugin in the appropriate place in the
 
     """
 
-    revision = "$Rev$"
-    url = "$URL$"
-
     implements(IPermissionPolicy)
 
     view = Option('public_wiki', 'view', 'Public*',

sample-plugins/permissions/vulnerability_tickets.py

 from trac.core import *
 from trac.perm import IPermissionPolicy, IPermissionRequestor
 
+revision = "$Rev$"
+url = "$URL$"
+
 class SecurityTicketsPolicy(Component):
-    """Permission policy restricting the access to security sensitive tickets
+    """Prevent public access to security sensitive tickets.
     
     Add the VULNERABILITY_VIEW permission as a pre-requisite for any
     other permission check done on tickets that have the words
     }}}
     """
     
-    revision = "$Rev$"
-    url = "$URL$"
-
     implements(IPermissionPolicy, IPermissionRequestor)
 
     # IPermissionPolicy methods

sample-plugins/revision_links.py

 from trac.versioncontrol.web_ui import ChangesetModule
 from trac.wiki.api import IWikiSyntaxProvider
 
+revision = "$Rev$"
+url = "$URL$"
+
 class RevisionLinks(Component):
     """Adds a few more ways to refer to changesets."""
 
-    revision = "$Rev$"
-    url = "$URL$"
-
     implements(IWikiSyntaxProvider)
 
     KEYWORDS = ['[Rr]ev(?:ision)?', '[Cc]hangeset']

sample-plugins/ticket_clone.py

 from genshi.builder import tag
 from genshi.filters import Transformer
 
+revision = "$Rev$"
+url = "$URL$"
+
 class SimpleTicketCloneButton(Component):
-    """Add a 'Clone' button in the ticket box. 
+    """Add a 'Clone' button to the ticket box. 
     
     This button is located next to the 'Reply' to description button,
     and pressing it will send a request for creating a new ticket
     which will be based on the cloned one.
     """
        
-    revision = "$Rev$"
-    url = "$URL$"
-
     implements(ITemplateStreamFilter)
 
     # ITemplateStreamFilter methods

sample-plugins/workflow/CodeReview.py

 from trac.config import Option, ListOption
 from trac.util.compat import set
 
+revision = "$Rev$"
+url = "$URL$"
+
 class CodeReviewActionController(Component):
     """Support for simple code reviews.
 
     workflow = ConfigurableTicketWorkflow,CodeReviewActionController
     """
 
-    revision = "$Rev$"
-    url = "$URL$"
-
     implements(ITicketActionController, IPermissionRequestor)
 
     # IPermissionRequestor methods

sample-plugins/workflow/DeleteTicket.py

 from trac.ticket.api import ITicketActionController
 from trac.perm import IPermissionRequestor
 
+revision = "$Rev$"
+url = "$URL$"
+
 class DeleteTicketActionController(Component):
     """Provides the admin with a way to delete a ticket.
 
     workflow = ConfigurableTicketWorkflow,DeleteTicketActionController
     """
 
-    revision = "$Rev$"
-    url = "$URL$"
-
     implements(ITicketActionController, IPermissionRequestor)
 
     # IPermissionRequestor methods

sample-plugins/workflow/StatusFixer.py

 from trac.ticket.api import ITicketActionController, TicketSystem
 from trac.perm import IPermissionRequestor
 
+revision = "$Rev$"
+url = "$URL$"
+
 class StatusFixerActionController(Component):
     """Provides the admin with a way to correct a ticket's status.
 
     workflow = ConfigurableTicketWorkflow,StatusFixerActionController
     """
 
-    revision = "$Rev$"
-    url = "$URL$"
-
     implements(ITicketActionController, IPermissionRequestor)
 
     # IPermissionRequestor methods

sample-plugins/workflow/VoteOperation.py

 from trac.ticket.model import Priority, Ticket
 #from trac.perm import IPermissionRequestor # (TODO)
 
+revision = "$Rev$"
+url = "$URL$"
+
 class VoteOperation(Component):
     """Provides a simplistic vote feature.
 
     workflow = ConfigurableTicketWorkflow,VoteOperation
     """
     
-    revision = "$Rev$"
-    url = "$URL$"
-
     implements(ITicketActionController)
 
     def get_ticket_actions(self, req, ticket):

trac/admin/web_ui.py

                 if plugin_filename and os.access(dist.location,
                                                  os.F_OK + os.W_OK):
                     readonly = False
+                if plugin_filename:
+                    info = {'summary': description}
+                    for k in 'author author_email home_page license'.split():
+                        v = getattr(module, k, '')
+                        if v:
+                            info[k] = v
+                    version = (getattr(module, 'version', '') or
+                               getattr(module, 'revision', ''))
+                    # special handling for "$Rev$" strings
+                    version = version.replace('$', '').replace('Rev: ', 'r') 
+                else:
+                    info = get_pkginfo(dist)
+                    version = dist.version
                 plugins[dist.project_name] = {
-                    'name': dist.project_name, 'version': dist.version,
+                    'name': dist.project_name, 'version': version,
                     'path': dist.location, 'description': description,
                     'plugin_filename': plugin_filename, 'readonly': readonly,
-                    'info': get_pkginfo(dist), 'components': []
+                    'info': info, 'components': []
                 }
             plugins[dist.project_name]['components'].append({
                 'name': component.__name__, 'module': module.__name__,