Login

Genshi is fantastic !

Written on 2008-06-25 22:55.

I did not notice it but a new release of genshi is available. The team at edgewall already famous for trac is doing a great job to ease the generation of xml templates as well as for text templates.

Lately I had to create a list of the available pages on the blog and I was wondering how to do it with a mix of <py:for> and <py:if>. But then I realized that it was easier to use the marvelous <py:choose> in this way:

<py:for each="pagenum in range(1, max_pages+1)">
  <py:choose test="">
  <li py:when="pagenum==page"><b>$pagenum</b></li>
  <li py:when="pagenum==1"><a href="/blogs${base}?page=1">1</a></li>
  <li py:when="pagenum==max_pages">
     <a href="/blogs${base}?page=$pagenum">$pagenum</a>
  </li>
  <li py:when="abs(page-pagenum)==1">
     <a href="/blogs${base}?page=$pagenum">$pagenum</a>
  </li>
  <li py:when="abs(page-pagenum)==2"><span py:strip="True">...</span></li>
  </py:choose>
</py:for>

This little piece of code will bold the current page, display a link to the first, the last, the previous and the next pages.

Musical countries meme

Written on 2008-06-18 17:00.

Take the overall top 50 artist from your last.fm account, look up their countries, display the list to the world.

us: 18
fr: 10
uk: 10
de: 3
is: 2
be: 2
br: 2
ca: 1
au: 1
ru: 1

Found through planet debian.

Pages :