Add dyn:category_name

This commit is contained in:
Gregory Soutade 2014-06-09 11:46:25 +02:00
parent eb283280f1
commit 0b347c2f16
4 changed files with 27 additions and 1 deletions

View File

@ -50,6 +50,7 @@ class Index(DynastieGenerator):
'first_page_only' : self.createFirstPageOnly,
'ljdc_last' : self.createLJDCLast,
'comments_count' : self.createCommentsCount,
'category_name' : self.createCategoryName,
}
self.first_try = True
@ -85,6 +86,14 @@ class Index(DynastieGenerator):
else:
count = Comment.objects.filter(post=self.cur_post_obj.id).count()
self.replaceByText(dom, root, node, str(count))
def createCategoryName(self, posts, dom, root, node):
from dynastie.models import Category
if self.cur_post_obj is None:
category = ''
else:
category = Category.objects.filter(id=self.cur_post_obj.category.id)[0].name
self.replaceByText(dom, root, node, category)
def createNavigation(self, posts, dom, root, node):
if self.nb_pages == 0 or self.nb_pages == 1:

View File

@ -4,7 +4,7 @@
<dyn:year>
<dyn:month>
<dyn:posts>
<dyn:title link="1"/>
[<dyn:category_name/>] <dyn:title link="1"/>
</dyn:posts>
</dyn:month>
</dyn:year>

View File

@ -1,5 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<ljdc>
<entry>
<id>86876038790</id>
<address>http://lesjoiesducode.fr/post/86876038790/quand-je-corrige-sans-probleme-une-serie-de-bugs</address>
<title>quand je corrige sans problème une série de bugs mineurs</title>
<img>http://ljdchost.com/H3lqXrR.gif</img>
</entry>
<entry>
<id>86598933572</id>
<address>http://lesjoiesducode.fr/post/86598933572/vendredi-17h</address>
<title>vendredi, 17h</title>
<img>http://ljdchost.com/KtEbpO4.gif</img>
</entry>
<entry>
<id>87886854819</id>
<address>http://thecodinglove.com/post/87886854819/when-my-app-comes-back-from-qa-without-any-bugs</address>

View File

@ -605,4 +605,9 @@ div.all_posts div.post
.comments_link
{
padding-right:20px;
}
.year .title
{
display:inline;
}