Opened 4 years ago
Last modified 9 months 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)
Change History (5)
Changed 4 years ago by anonymous
comment:1 Changed 9 months ago by rjollos
- Component changed from BackLinksMenuMacro to BackLinksMacro
The functionality of BackLinksMenuMacro is being integrated into the BackLinksMacro.
comment:2 Changed 9 months ago by rjollos
#6611 closed as a duplicate.
comment:3 Changed 9 months 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 9 months ago by rjollos
- Owner changed from trapanator to rjollos
Feedback from testing is appreciated.


Enhanced detection of links