Re: A simple question about ordering of posts

Chris G <[email protected]> Sun, 31 Jan 2010 16:16:29 +0000
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <20100131161629.GF3466@chris>
On Sun, Jan 31, 2010 at 03:36:59PM +0000, chombee wrote:
> On Sun, Jan 31, 2010 at 02:27:41PM +0000, Chris G wrote:
> > On Sun, Jan 31, 2010 at 01:24:28PM +0000, chombee wrote:
> > > On Sun, Jan 31, 2010 at 10:09:54AM +0000, Chris G wrote:
> > > > I know it's probably totally back to front for a blog but how easy
> > > > would it be to get pyblosxom to display posts in increasing date
> > > > order?  Is the ordering set at just one place in the code?  I'm quite
> > > > happy to just patch my installed pyblosxom code as I realise this
> > > > won't be a common requirement.
> > > > 
> > > > For what it's worth I want to create a [not]blog where the story
> > > > template will just display the date and title so one sees just a list
> > > > of entries - in increasing date order.
> > > 
> > > Could you write a plugin to do this? Using the cb_filelist callback
> > > maybe:
> > > 
> > > http://pyblosxom.sourceforge.net/1.5/dev_architecture.html#cb-filelist
> > > 
> > You could well be right!  It would certainly be more elegant to do it
> > with a plugin rather than by patching the code directly.  I probably
> > need to write a plugin anyway as I need to do things at cb_story()
> > time to enable me to click on my list and view individual posts.
> 
> You shouldn't need a plugin to click on items in your list and view
> individual posts. Just make the items hyperlink to the permalink pages
> for each post. Take a look at the permalinks in the default flavour.
> 
> I think your plugin needs to do two things (maybe two different
> plugins):
> 
> 1. Reverse the sort order of items, maybe a cb_filelist plugin.
> 
Yes, I've got this done, I have a cb_filelist which essentially
duplicates blosxom_file_list_handler() but without the reverse of the
sort order.

> 2. Make it so that on index pages (such as the front page) only
> the title of each item is displayed and not the full contents (I think
> this is what you want?).
> 
You have it in one!  :-)

> I think there are a lot of ways to achieve 2. You could do it easily by
> using one flavour for the index pages and having that flavour hyperlink
> to another flavour for the permalink pages. Probably there would be much
> shared code between the two flavours, differing only in the story
> template, so one flavour could consist mostly of symlinks to the other
> flavour's files but with its own story file. I've done this before and
> it works, but I feels a little inelegant.
> 
> It might be more elegant to write a plugin. This could be a cb_story
> plugin that changes the 'body' field of a story to an empty string if
> the request is for an index view. This would be similar to the readmore
> plugin:
> 
This is the way I have done it.  Fairly simple in the end after
[re]learning various bits of python.

> http://bluesock.org/~willg/cgi-bin/devtrac.cgi/browser/trunk/pyblosxom/readmore.py#latest
> 
> Or perhaps it could be a cb_entryparser plugin that changes the value of
> 'template_name' in the entrydata dict if the request is for an index
> view, using a different story template for index views and for permalink
> pages. See:
> 
> http://pyblosxom.sourceforge.net/1.5/dev_writing_plugins.html#writing-an-entryparser
> 
> I'm a plugin-writing newbie, so my suggestions might not be the best or
> easiest way of doing things. Will would know better.
> 
Ah, it's 'template_name' in the 'entry' dictionary, I was looking for
'template' rather unsuccessfully.  No, just tried that, there's no
'template name' in there either.  I've just looked through the entry
dictionary that you get in cb_story and there's no template, only the
flavour.  There is a 'template' argument but that's the actual
template as a string, maybe one could modif that and return in in the
args. 

It's just as easy to empty (or not) the 'body'.
-- 
Chris Green


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com