Modify

Opened 5 years ago

Last modified 2 years ago

#5903 new defect

Enhanced detection of links

Reported by: anonymous Owned by: rjollos
Priority: normal Component: BackLinksMacro
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

In the current version (released on 08/19/08) are not detected correctly all types of links.

E.g. following links are not currently detected:

[wiki:"Name of the page"]
NameOfThePage

It will be nice if future versions of the macro contain detection of these two additional link types. In our case we have a lot of these links and without patch macro is not so useful.

For my purpose I have modified existing source code (only for TRAC 0.11) and changed following lines.

Original source code:

if thispage:
      #sql += 'AND (w1.text LIKE \'%%[wiki:%s %%\' ' % (to_unicode(thispage, "utf-8").encode ("utf-8"))
      sql += 'AND (w1.text LIKE \'%%[wiki:%s %%\' ' % thispage
      sql += 'OR w1.text LIKE \'%%[wiki:%s]%%\')' % thispage
      #sql += 'OR w1.text LIKE \'%%[wiki:%s]%%\')' % (to_unicode (thispage, "utf-8").encode ("utf-8"))

My changes:

      #sql += 'AND (w1.text LIKE \'%%[wiki:%s %%\' ' % (to_unicode(thispage, "utf-8").encode ("utf-8"))
      sql += 'AND (w1.text LIKE \'%%[wiki:%s %%\' ' % thispage
      sql += 'OR w1.text LIKE \'%%[wiki:%s]%%\'' % thispage
      sql += 'OR w1.text LIKE \'%%[wiki:"%s"]%%\'' % thispage
      sql += 'OR w1.text LIKE \'%%%s%%\')' % thispage
      #sql += 'OR w1.text LIKE \'%%[wiki:%s]%%\')' % (to_unicode (thispage, "utf-8").encode ("utf-8"))

Whole script is in the attachment.

Thanks a lot for incorporating these changes.

Attachments (1)

BackLinksMenu.zip (1.1 KB) - added by anonymous 5 years ago.
Enhanced detection of links

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by anonymous

Enhanced detection of links

comment:1 Changed 2 years ago by rjollos

  • Component changed from BackLinksMenuMacro to BackLinksMacro

The functionality of BackLinksMenuMacro is being integrated into the BackLinksMacro.

comment:2 Changed 2 years ago by rjollos

#6611 closed as a duplicate.

comment:3 Changed 2 years ago by rjollos

(In [11969]) Refs #5903, #9175, #9503:

  • Merged codebases for BackLinksMacro and BackLinksMenuMacro.
  • Modified SQL query to utilize Trac's database agnostic API. Possible matches are captured with a LIKE clause, and then filtered with a regex in the Python code.

comment:4 Changed 2 years ago by rjollos

  • Owner changed from trapanator to rjollos

Feedback from testing is appreciated.

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.