Modify

Opened 16 years ago

Last modified 10 years ago

#3584 new defect

ToC Macro doesn't work with relative links

Reported by: Jim Sermersheim Owned by:
Priority: normal Component: TocMacro
Severity: normal Keywords:
Cc: Jim Sermersheim Trac Release: 0.11

Description

The second ToC here does not work -- gives "Error: Page ./sub does not exist"

[[TOC(inline,noheading,depth=1, test/sub, test/sub2)]]

[[TOC(inline,noheading,depth=1, ./sub, ./sub2)]]

[./sub sub][[BR]]
[./sub2 sub2]

Note that the first ToC works (but I need relative links) as do the relative links at the bottom.

Attachments (0)

Change History (7)

comment:1 Changed 16 years ago by anonymous

Trac Release: 0.100.11

comment:2 Changed 16 years ago by anonymous

Cc: Jim Sermersheim added; anonymous removed

comment:3 Changed 16 years ago by Duane Buss

A dirty hack for jimse was to insert the following code at the bottom of expandmacro()

for pagename in pagenames:

new if pagename.startswith('.'): new rel_url = get_relative_url(self.env, self.resource, self.context.href, pagename) new pagename = rel_url.lstrip(self.context.href.base+'/'+self.resource.realm)

page_resource = self.resource(id=pagename) if not 'WIKI_VIEW' in self.context.perm(page_resource):

# Not access to the page, so should not be included continue

if 'title_index' in params:

self._render_title_index(ol, page_resource, active and \

pagename == current_page, paramsmin_depth? < 2)

else:

self._render_page_outline(ol, page_resource, active, params)

return base

comment:4 Changed 16 years ago by Duane Buss

      for pagename in pagenames:
            // the three lines below this comment are new
            if pagename.startswith('.'):
               rel_url = get_relative_url(self.env, self.resource,  self.context.href, pagename)
               pagename = rel_url.lstrip(self.context.href.base+'/'+self.resource.realm)
            page_resource = self.resource(id=pagename)
            if not 'WIKI_VIEW' in self.context.perm(page_resource):
                # Not access to the page, so should not be included
                continue
            if 'title_index' in params:
                self._render_title_index(ol, page_resource, active and \
                            pagename == current_page,
                            params['min_depth'] < 2)
            else:
                self._render_page_outline(ol, page_resource, active, params)
        return base

comment:5 Changed 16 years ago by anonymous

Please attach patches as unified diffs (diff -u or svn diff)

comment:6 Changed 16 years ago by Duane Buss

It's not a diff because I don't think that is the perfect fix. A better fix would be to have a relative resource id generator function in trac which could be used.

comment:7 Changed 10 years ago by Ryan J Ollos

Owner: Noah Kantrowitz deleted

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.

Add Comment


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

 
Note: See TracTickets for help on using tickets.