Re: First example of the showmore plugin
will <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
Instead of hardcoding the <!---more--->, I would instead make it user
configurable (in the config dict) and remove it from the text when they
view the full version.
For the linking to an entry issue, the cheesy thing to do would be to
count the number of entries in the file_list in the cb_prepare callback.
If the number is one, then it's likely they're looking at one entry. If
you combine that with some other information--maybe from the data dict
(like the path_info or something)--that might be better.
I can get you code if you need it. But given my current track record,
it'll take me a month and a half to do so. ;)
/will
On Wed, 9 Jul 2003, Chris Moffitt wrote:
>
> Here's my first stab at the showmore plugin. It works to a point, but it
> does not link directly to an entry yet. I haven't figured out how to get
> the url.
>
> Here it is -
>
> I call it from a story by putting $showmore('link to more') in the template.
>
> Thoughts or comments are appreciated.
>
> -Chris
>
> """
> If the user puts <!---more---> in a document, then split
> the output at the label and present a link to more detailed information
> """
> from Pyblosxom import tools
>
> entry = {}
>
> def showmore(var):
> global entry
> registry = tools.get_registry()
> req = registry["request"]
> data = req.getData()
> conf = req.getConfiguration()
> story = entry.getData()
> if entry.has_key('more'):
> output = "<BR /> %s" % var
> return output
> else:
> return ''
>
> def cb_prepare(args):
> request = args["request"]
> data = request.getData()
> data["showmore"] = showmore
>
> def cb_story(args):
> global entry
> entry = args['entry']
>
>
> def cb_postformat(args):
> text = str(args['entry_data']['body'])
> try:
> first, last = text.split("<!---more--->")
> args['entry_data']['body'] = first
> entry['more'] = last
> except:
> pass
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps