Changeset 3198

Show
Ignore:
Timestamp:
02/08/08 11:18:29 (1 year ago)
Author:
ctlajoie
Message:

AutoLinksPlugin: added the ability to link to non-plural page names by typing the plural form of their name

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • autolinksplugin/0.10/autolinks/autolinks.py

    r2758 r3198  
    1717        from trac.wiki.formatter import Formatter 
    1818        wiki_page_name = ( 
    19             r"(([A-Z]+[a-z]{2,})|([A-Z]{3,}))" 
     19            r"(([A-Z]+[a-z]{2,})|([A-Z]{3,}s?))" 
    2020            r"(?:#[\w:](?<!\d)(?:[\w:.-]*[\w-])?)?" # optional fragment id 
    2121            r"(?=:(?:\Z|\s)|[^:a-zA-Z]|\s|\Z)" # what should follow it 
     
    3434        # copied and modified from trac/wiki/api.py 
    3535        page, query, fragment = formatter.split_link(page) 
    36         href = formatter.href.wiki(page) + fragment 
    37         if not self.wikisys.has_page(page): 
     36        link = False 
     37        if self.wikisys.has_page(page): 
     38            link = True 
     39        elif page[-1] == 's' and self.wikisys.has_page(page[:-1]): 
     40            # if the page name ends in 's', see if there is a wiki page with the same name minus the 's' 
     41            # if there is, it will be linked 
     42            page = page[:-1] 
     43            link = True 
     44 
     45        if link: 
     46            href = formatter.href.wiki(page) + fragment 
     47            return html.A(label, href=href, class_='wiki') 
     48        else: 
    3849            return label 
    3950            # use the following line instead to link pages even if a wiki page 
    4051            # by that name does not exist yet 
    4152            #return html.A(label+'?', href=href, class_='missing wiki', rel='nofollow') 
    42         else: 
    43             return html.A(label, href=href, class_='wiki') 
    4453 
  • autolinksplugin/0.10/setup.py

    r2758 r3198  
    1414    license = "BSD", 
    1515    keywords = "trac plugin wiki proper case acronym links", 
    16     url = "", 
     16    url = "http://trac-hacks.org/wiki/AutoLinksPlugin", 
    1717    classifiers = [ 
    1818        'Framework :: Trac',