Edgewall Software
Modify

Opened 8 years ago

Closed 6 years ago

#2780 closed enhancement (fixed)

ShowPath integration into Trac

Reported by: cmarschalek Owned by: rblank
Priority: normal Milestone: 0.11.2
Component: wiki system Version: devel
Severity: normal Keywords: showpath wiki patch
Cc:
Release Notes:
API Changes:

Description

I'd like to see bread-crumb-navigation for the wiki.

I adapted the ShowPath? Trac hack (http://trac-hacks.org/wiki/TracShowPathPatch) to 0.9.3. As I'm not very capable with Python, instead of a diff, here's what needs to be changed:

Python Source

The following code needs to be added to "wiki/web_ui.py":

        prefix = Markup(page.name)
        heirarchy = prefix.split('/')

        if len(heirarchy) > 1 or heirarchy[0] != 'WikiStart':
            req.hdf.setValue('wiki.page_parent.node_count', '%s' % len(heirarchy))
            for i in range(len(heirarchy)):
                req.hdf.setValue('wiki.page_parent.node.%d' % i, heirarchy[i])

Inbetween

       req.hdf['wiki.action'] = action
       req.hdf['wiki.page_name'] = page.name
       req.hdf['wiki.current_href'] = self.env.href.wiki(page.name)

and

        return 'wiki.cs', None

The linenumber in 0.9.3, for the text above, is 120…

CSS

The wiki template (wiki.cs) hast to be changed too:

This line

   <li><a href="<?cs var:trac.href.wiki ?>">Start Page</a></li>

has to be replaced with this

 <div class="wikinav">
   >> <a href="<?cs var:$trac.href.wiki ?>">Start Page</a>
   <?cs set:node_href = trac.href.wiki ?><?cs set:node_max = wiki.page_parent.node_count - 1 ?>
   <?cs each:node = wiki.page_parent.node ?>
   <?cs set:node_href = node_href + '/' + node ?> > <?cs if:node_max == name(node) ?><?cs var:node ?>
   <?cs else ?><a href="<?cs var:node_href ?>"><?cs var:node ?></a><?cs /if ?><?cs /each ?>
 </div>

The wikinav class has to be defined in the default css too.

I hope this simple change can be integrated into trac :)

c.marschalek@[-remove-me-]schrack-seconet.com

Attachments (2)

showpath-r3717.diff (1.6 KB) - added by anonymous 8 years ago.
showpath patch updated to the trunk r3717
2780-wiki-show-path-r7470.patch (1.2 KB) - added by rblank 6 years ago.
Patch against 0.11-stable showing the path of hierarchical wiki pages

Download all attachments as: .zip

Change History (27)

comment:1 Changed 8 years ago by anonymous

  • Priority changed from low to normal
  • Version changed from 0.9.4 to 0.9.5

comment:2 Changed 8 years ago by anonymous

  • Version changed from 0.9.5 to devel

comment:3 Changed 8 years ago by anonymous

any news on this?

comment:4 Changed 8 years ago by anonymous

  • Milestone set to 0.9.7

comment:5 Changed 8 years ago by mgood

  • Milestone 0.9.7 deleted

Milestone 0.9.7 is for bug fixes only. This will not be added for that release.

comment:6 Changed 8 years ago by cmarschalek

Well, can you set another milestone (or close it) then? It would be nice to finally find out what you guys think about this enhancement :) Tia!

comment:7 Changed 8 years ago by sgrayban@…

I added this patch by hand the to 0.10 trunk and it works just great.

comment:8 Changed 8 years ago by anonymous

  • Milestone set to 0.10

comment:9 Changed 8 years ago by cmlenz

  • Milestone 0.10 deleted

We're feature-freezing 0.10, so this isn't going in now.

comment:10 Changed 8 years ago by anonymous

please don't ignore this feature. It is very useful.

comment:11 follow-up: Changed 8 years ago by markus

I'd like to see it too coming with 0.10…

Changed 8 years ago by anonymous

showpath patch updated to the trunk r3717

comment:12 in reply to: ↑ 11 Changed 8 years ago by mgood

Replying to markus:

I'd like to see it too coming with 0.10…

As cmlenz said, this will not be going into 0.10. We need to lock down the feature set so we can work out some remaining bugs and push out the release.

comment:13 Changed 8 years ago by sid

You should be able to do this quite easily in 0.11 using PageTemplates. See r3881 and #962 for more details.

You'll just need to add a PageTemplates/DefaultPage? with the macro in it.

comment:14 Changed 7 years ago by cboos

  • Resolution set to duplicate
  • Severity changed from trivial to minor
  • Status changed from new to closed

See #4423, which discusses how to solve this in a generic way.

comment:15 follow-up: Changed 7 years ago by cboos

  • Milestone set to 0.11
  • Resolution duplicate deleted
  • Severity changed from minor to normal
  • Status changed from closed to reopened

I'll add the hierarchical path information, similar to what we have for the repository browser. Related to #4507.

comment:16 Changed 7 years ago by cmarschalek

Thanks, sounds great!

comment:17 Changed 7 years ago by anonymous

For 0.10.4 change:

    	prefix = Markup(page.name)

to

    	prefix = page.name

and this will work — not sure the implications, but that did the trick for me.

Also slap some css in share\trac\htdocs\css\trac.css

div.wikinav {
 position: absolute;
 top: 117px;
 left: 10px;
 color: #999;
 text-transform: lowercase;
 display: block;
}

Adjust CSS for positioning as needed.

comment:18 Changed 6 years ago by Jason Winnebeck <jpwasp@…>

I took the version on MacroBazaar, which wasn't quite right, fixed it up, and put it on Trac Hacks at th:wiki:ShowPathPlugin.

Changed 6 years ago by rblank

Patch against 0.11-stable showing the path of hierarchical wiki pages

comment:19 in reply to: ↑ 15 Changed 6 years ago by rblank

  • Keywords patch added
  • Owner changed from jonas to rblank
  • Status changed from reopened to new

Replying to cboos:

I'll add the hierarchical path information, similar to what we have for the repository browser.

The patch above adds clickable path information to the top of hierarchical wiki pages. The path is not shown for non-hierarchical pages.

Questions:

  • The style has been borrowed directly from the repository browser. It is relatively close to the style of first-level wiki titles, except for the color. Should it be made more differentiated?
  • Should this functionality be made configurable?

Comments?

comment:20 follow-up: Changed 6 years ago by cmarschalek

The style should be a css class which can be customized when needed (imho) ;)

comment:21 in reply to: ↑ 20 ; follow-up: Changed 6 years ago by rblank

Replying to cmarschalek:

The style should be a css class which can be customized when needed (imho) ;)

If you look at the patch, you'll see that it is a set of CSS classes.

comment:22 in reply to: ↑ 21 ; follow-up: Changed 6 years ago by cmarschalek

Replying to rblank:

Replying to cmarschalek:

The style should be a css class which can be customized when needed (imho) ;)

If you look at the patch, you'll see that it is a set of CSS classes.

"Should this functionality be made configurable? "

Did you mean the overall functionality of showing the breadcrumbs then? If so, imho, this doesn't need to be configurable (like I said before a wiki should have some default way of navigation). I'm certain though, that at least someone will not like such feature, but looking at the patch (yes, now I did;) it should be quite easy to remove…

comment:23 in reply to: ↑ 22 Changed 6 years ago by anonymous

Replying to cmarschalek:

Did you mean the overall functionality of showing the breadcrumbs then?

Yes, that's what I meant. Sorry for not being clear.

Please note though that this patch doesn't implement breadcrumbs, but shows the path for pages that have a hierarchical structure (i.e. contain a '/'). Breadcrumbs are a list of the most recently visited items. There's a plugin for that: th:BreadCrumbsNavPlugin.

comment:24 Changed 6 years ago by anonymous

  • Milestone changed from 0.11.3 to 0.11.2

Well for hierachical data the recently visited items is the path ;) Anyway this "path" is what I ment with breadcrumbs in lack of a better term…

How about letting this in into 0.11.2?

comment:25 Changed 6 years ago by rblank

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

Patch applied in [7554].

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed The owner will remain rblank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from rblank to the specified user.
Author


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

 
Note: See TracTickets for help on using tickets.