Re: [Rest2web-develop] Sort in indextree
Brought to you by:
mjfoord
|
From: Michael F. <fuz...@vo...> - 2007-04-04 15:49:38
|
Hello all,
Sorry for the very late response. I've just checked in the following
change to the sidebar function. :-)
Michael
Gael Varoquaux wrote:
> On Mon, Jan 01, 2007 at 11:47:28PM +0000, Michael Foord wrote:
>
>> So your patch just allows the passing in of a comparison function to the
>> sidebar function.
>>
>
>
>> If a comparison function is passed in, it is used to sort the pages.
>>
>
> Yes, simple, but useful.
>
>
>> It sounds fine. Can you give me an example function I can put in the docs ?
>>
>
> Well, how about this (adapted from the sidebar example): sorting by crumb
> value, inverse order.
>
> .. raw:: html
>
> {+coloring}
>
> cmp_page = lambda page1, page2 : 2*(page1['crumb'] < page2['crumb'] ) - 1
>
> for page in sidebar(indextree, cmp=cmp_page):
> val = page['crumb']
> link = page['target']
> if page['title']:
> print '<br /><strong><a href="%s">%s</a></strong>' \
> % (link, val)
> else:
> print '<br /><a href="%s">%s</a>' % (link, val)
>
> {-coloring}
>
> But this allows for much more powerful uses (like having a "date"
> uservalue, and sorting by date).
>
> Cheers,
>
> Gaël
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Rest2web-develop mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/rest2web-develop
>
>
|