/kai/templates/articles/index.mako

https://bitbucket.org/bbangert/kai/ · Mako · 39 lines · 38 code · 1 blank · 0 comment · 7 complexity · a32765b9deb6c00d59cd30eb24552586 MD5 · raw file

  1. <div class="yui-b content">
  2. <h1>${_('Recent Blog Postings')}\
  3. % if c.user and c.user.in_group('admin'):
  4. <span class="subtle">(${h.link_to('Add Posting', url=url('new_article'))})</span>\
  5. % endif
  6. </h1>
  7. <%
  8. if c.articles:
  9. results = list(c.articles)
  10. if c.reverse:
  11. results.reverse()
  12. %>
  13. ${widgets.pager(c.start, results, c.articles.total_rows, 'published')}
  14. % for article in results[:10]:
  15. ${display_article(article)}
  16. % endfor
  17. </div>
  18. <%def name="display_article(article)" cached="True" cache_timeout="600" cache_key="${article.id}" cache_type="ext:memcached" cache_url="127.0.0.1:11211">
  19. <div class="atomentry" id="article-${article.slug}">
  20. <h2 class="title">${h.link_to(article.title, url=url('article_archives', article=article))}</h2>
  21. <%
  22. author = '<cite>%s</cite>' % article.author
  23. date = '<span class="date">%s</span>' % format.date(article.published, "long")
  24. post_dict = dict(author=author, date=date)
  25. %>
  26. <p class="author">${_('Posted by %(author)s on %(date)s' % post_dict) | n}</p>
  27. <div class="articlecontent">
  28. ${h.textilize(article.body)}
  29. </div>
  30. </div>
  31. </%def>
  32. <%namespace name="widgets" file="/widgets.mako"/>
  33. <%def name="title()">${parent.title()} - ${_('Blog')}</%def>
  34. <%inherit file="/layout.mako" />
  35. <%def name="styles()">
  36. ${h.auto_discovery_link(url.current(format='atom', qualified=True), feed_type='atom', title='News Feed')}
  37. ${parent.styles()}
  38. </%def>