Re: More than py['num_entries'] entries displaed on the page?

will guaraldi <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <[email protected]>
Well, I checked in some adjustments to the existing blosxom renderer that
allow you to do multiple story templates in a given list of entries.

For example, my booklist plugin generates entries that use the booklist
template and not the story template.  It works on an entry by entry basis.
It overrides the blosxom_flavour property on the entry (though I think
that should be renamed to blosxom_taste) so that entry gets rendered with
the template of your choosing.

The template has to be listed in the blosxom_custom_flavours property of
your config.

So then your plugin could get the list of entries to be displayed and
change the templates involved.  I think it'd be pretty easy to do.

In fact, it was so easy (at least a basic implementation of what I'm
thinking you're looking for) that I whipped one together and attached it
to this email.  Theoretically it should work with either the CVS codebase
or the .8.1 codebase.  See if that helps guide you in the right direction
or if it merely serves to send you spinning into the great void of
confusion.

I'm puzzled as to why I'm not seeing any override code for the config
file.  I'm wondering if I accidentally whacked the code for that at some
point during one of my latest coding sprees.

/will


On Sun, 8 Feb 2004, Moof wrote:
>
> Nope, no luck with that.
>
> Thinking about it a little further, I probably will want to write my own
> renderer. I can then have, say, 2 entries diplayed using story.flavour,
> (full text) 20 entries displayed using story-short.flavour (the first
> 20-30 words of text) and the rest displayed as story-headline.flavour
> (title and post date only) - Otherwise 150 full-text posts would get a
> bit much :)
>
> Am I right in thinkign that the right bit of pyblosxom to do this with
> would be a renderer?
>
> Thanks,
> Moof
last10summary.py (application/x-python, 655 B)
"""
Thrown-together plugin to summarize all entries after the first five
in the html flavour.
"""
def cb_prepare(args):
    request = args["request"]
    data = request.getData()

    flavour = data.get("flavour", "html")

    # we don't want to do anything if the flavour isn't html
    if not flavour in ["html"]:
        return

    # grab the entry list
    entry_list = data["entry_list"]

    # for all the entries after the 10th one, we set the taste
    # to summary.
    i = 5
    while i < len(entry_list):
        if entry_list[i].get("flavour_name", "story") == "story":
            entry_list[i]["flavour_name"] = "summary"
        i = i + 1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.