Modify

Opened 15 years ago

Closed 14 years ago

#4051 closed defect (fixed)

[Patch] BackLinksMacro

Reported by: anonymous Owned by: Trap
Priority: normal Component: BackLinksMacro
Severity: normal Keywords:
Cc: Trac Release: 0.10

Description

SQL in 0.11 version looks for explicit wiki links but not simple CamelCase references to thispage.

Revised query as shown below:

if thispage:
    sql += 'AND (w1.text LIKE \'%%[wiki:%s %%\' ' % thispage
    sql += 'OR w1.text LIKE \'%%[wiki:%s]%%\' ' % thispage
    sql += 'OR w1.text LIKE \'%%%s%%\')' % thispage

The plugin works for me now in 0.11 with sqlite3.

Attachments (2)

BackLink.5.CamelCase.Fix.patch (1.7 KB) - added by JaeWook Choi 15 years ago.
BackLink.5.CamelCase.Fix.2.patch (1.8 KB) - added by JaeWook Choi 15 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 15 years ago by anonymous

That's great. Thanks for submitting the fix! Tested and working on 0.11b with sqlite3.

comment:2 Changed 15 years ago by anonymous

Here's a patch for the 0.10 version. The primary difference between this patch and the code above is that this patch filters out things that use the !NoLinkHere syntax.

--- BackLinks.py.orig   2008-01-31 15:39:26.000000000 -0500
+++ BackLinks.py        2009-02-06 23:43:41.000000000 -0500
@@ -19,8 +19,12 @@
                  '(SELECT name, MAX(version) AS VERSION FROM WIKI GROUP BY NAME) w2 ' + \
                  'WHERE w1.version = w2.version AND w1.name = w2.name '
        if thispage:
-                       sql += 'AND (w1.text LIKE \'%%[wiki:%s %%\' ' % (unicode(thispage, "utf-8").encode ("utf-8"))
-                       sql += 'OR w1.text LIKE \'%%[wiki:%s]%%\')' % (unicode (thispage, "utf-8").encode ("utf-8"))
+            utf8 = unicode(thispage, "utf-8").encode("utf-8")
+            sql += 'AND (w1.text LIKE \'%%[wiki:%s %%\' ' % utf8 
+            sql += 'OR w1.text LIKE \'%%[wiki:%s]%%\' ' % utf8 
+            if thispage[1:].lower() != thispage[1:]:
+                sql += "OR replace(w1.text, '!%s', '') LIKE '%%%s%%' " % (utf8, utf8) 
+            sql += ')'
        cursor.execute(sql)
        buf = StringIO()
        buf.write('<hr style="width: 10%; padding: 0; margin: 2em 0 1em 0;"/>')

comment:3 Changed 15 years ago by JaeWook Choi

Improved the fix for camel case TracLinks

Changed 15 years ago by JaeWook Choi

Changed 15 years ago by JaeWook Choi

comment:4 Changed 14 years ago by anonymous

Summary: BackLinksMacro[Patch] BackLinksMacro

comment:5 Changed 14 years ago by Trap

Resolution: fixed
Status: newclosed

I've got your suggestions and I fixed in r7509

Thank you.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Trap.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.