Re: Questions about categories
Wari Wahab <wari-Yu9E6tdDWSZWk0Htik3J/[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
* Chris Moffitt <[email protected]> [030707 09:54]: > Thanks to everyone for putting up with my last set of questions. > Since people were so helpful, I'm going to ask a couple more. You're welcome > The first one is about the category plugin. It seems to be working > just fine on my system (win2K with Apache), but my hierarchy is > displayed like this (thanks to dospath2uri ;) )- [..SNIP..] > Any hints on how to get it to display in that way? I've (hopefully) fixed that in the CVS version :) Feel free the check it out (or you can do the fix yourself by changing split('/') to split(os.sep)) > Second question - I noticed on Wari's site that he had a navigation > scheme like - > Top Level :: Child :: Another Child > At the top of his page. Any hints on how to implement that > functionality? You noticed? Hehehe.. That's my super secret plugin, so secret, I'm not gonna give it to anyone.. :P Anyway, that plugin is called breadcrumbs, and I'm not really sure if it works on Windows, I've attached it in this mail. The reason it wasn't posted at all is because I thought is was crummy (if you pardon the pun :), and also, it was done in the old pyblosxom way. It could be more efficient if done properly. > And one final question. Has anyone looked at developing a "show more" > plugin. If an entry is over X characters then a more link is > displayed with a link to the full entry? I wished someone would do that plugin for me :) Again, should not be difficult to do anyway, at least, that's what I think.
breadcrumbs.py
(text/plain, 1.2 KB)
# vim: tabstop=4 shiftwidth=4 expandtab
"""
Creates Yahoo style navigation
"""
__author__ = "Wari Wahab - wari at wari dot per dot sg"
__version__ = "$Id:$"
SEPERATOR=' :: '
from Pyblosxom import tools
import os, string
class BreadCrumbs:
def __init__(self, request):
self._request = request
self._crumbs = ''
def __str__(self):
self.littleCrumbs()
return str(self._crumbs)
def littleCrumbs(self):
conf = self._request.getConfiguration()
data = self._request.getData()
path = string.replace(data['root_datadir'], conf['datadir'], '')
crumblets = path.split(os.sep)
path_data = []
crumbs = ''
for mem in crumblets:
if mem:
crumbs += '/%s' % mem
if crumbs != path:
path_data.append('<a href=%s%s>%s</a>' % (conf['base_url'], crumbs, mem))
else:
path_data.append(mem)
self._crumbs = SEPERATOR.join(path_data)
def cb_prepare(args):
request = args['request']
data = request.getData()
data["breadcrumbs"] = BreadCrumbs(request)
if __name__ == '__main__':
pass