Modify

Opened 5 years ago

Last modified 4 years ago

#6345 new defect

Generated links miss the page name on the default page

Reported by: aurelien@… Owned by: coderanger
Priority: normal Component: TocMacro
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

Hi,

My Trac instance has the wiki as default component (it's the default Trac setup). I'm using the [[TOC(SomePage)]] macro on the WikiStart page. It works well when I click on the main "Wiki" link (URL is http!://example.com/trac/wiki) but when I click on the logo, I get to the default page (URL is http!://example.com/trac), which causes a problem : the links do not contain the page name. Instead of http!://example.com/trac/wiki/SomePage#Section, I get http!://example.com/trac#Section.

I found a way to fix the bug, using the following patch :

diff -p -up ./0.11/tractoc/macro.py.nopathinfo ./0.11/tractoc/macro.py
--- ./0.11/tractoc/macro.py.nopathinfo  2009-12-17 14:42:42.000000000 +0100
+++ ./0.11/tractoc/macro.py     2009-12-17 14:43:15.000000000 +0100
@@ -43,7 +43,7 @@ def outline_tree(env, ol, outline, conte
                 li.append(new_ol)
                 stack[d+1] = (None, new_ol)
             href = get_resource_url(env, context.resource, context.href)
-            if href.endswith(context.req.path_info):
+            if context.req.path_info and href.endswith(context.req.path_info):
                 href = ''
             href += '#' + anchor
             li, ol = stack[depth]

I noticed that in my case the context.req.path_info variable is an empty string.

Please consider it for inclusion if it looks like the correct fix.

Attachments (0)

Change History (1)

comment:1 Changed 4 years ago by dnedelchev

It is a dupplicate of #4407 where is additional information as well as indicated workarand(s). I wrote a note there to link to this one too.

I can confirm that the problem persist (how it's described in these two bug-requests) both in 0.11 and in 0.12 However I leave the release indiction to 0.11 since TocMacro doesn't have an 0.12 dedicated variant yet.

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.