Opened 7 years ago

Closed 10 months ago

Last modified 10 months ago

#5903 closed defect (duplicate)

Enhanced detection of links

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


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"]

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) (1.1 KB) - added by anonymous 7 years ago.
Enhanced detection of links

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by anonymous

Enhanced detection of links

comment:1 Changed 4 years ago by rjollos

  • Component changed from BackLinksMenuMacro to BackLinksMacro

The functionality of BackLinksMenuMacro is being integrated into the BackLinksMacro.

comment:2 Changed 4 years ago by rjollos

#6611 closed as a duplicate.

comment:3 Changed 4 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 4 years ago by rjollos

  • Owner changed from trapanator to rjollos

Feedback from testing is appreciated.

comment:5 Changed 10 months ago by rjollos

  • Resolution set to duplicate
  • Status changed from new to closed

This should be resolved by the use of the TracLinks parser, suggested in #12619.

Last edited 10 months ago by rjollos (previous) (diff)

Add Comment

Modify Ticket

as closed The owner will remain rjollos.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.