Add dyn:comments_count

This commit is contained in:
Gregory Soutade 2014-06-05 19:56:47 +02:00
parent 193b439517
commit 361be87cb2
4 changed files with 39 additions and 1 deletions

View File

@ -49,6 +49,7 @@ class Index(DynastieGenerator):
'replace' : self.createReplace,
'first_page_only' : self.createFirstPageOnly,
'ljdc_last' : self.createLJDCLast,
'comments_count' : self.createCommentsCount,
}
self.first_try = True
@ -77,6 +78,14 @@ class Index(DynastieGenerator):
root.replaceChild(div_element, replace_elem)
return div_element
def createCommentsCount(self, posts, dom, root, node):
from dynastie.models import Comment
if self.cur_post_obj is None:
count = 0
else:
count = Comment.objects.filter(post=self.cur_post_obj.id).count()
self.replaceByText(dom, root, node, str(count))
def createNavigation(self, posts, dom, root, node):
if self.nb_pages == 0 or self.nb_pages == 1:
return None

View File

@ -13,7 +13,7 @@
</header>
<dyn:post_content/>
<footer class="post_footer">
<dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace>
<dyn:replace div_name="a" class="comments_link" href="dyn:post_url#comments"><dyn:comments_count/> commentaire(s)</dyn:replace> <dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace>
</footer>
</article>
</dyn:posts>

View File

@ -1,5 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<ljdc>
<entry>
<id>87886854819</id>
<address>http://thecodinglove.com/post/87886854819/when-my-app-comes-back-from-qa-without-any-bugs</address>
<title>when my app comes back from QA without any bugs</title>
<img>http://i.imgur.com/uk5JoVB.gif</img>
</entry>
<entry>
<id>86408294325</id>
<address>http://lesjoiesducode.fr/post/86408294325/quand-on-me-donne-quelque-chose-a-coder-apres-un-mois</address>
<title>quand on me donne quelque chose à coder après un mois passé à rédiger des docs</title>
<img>http://ljdchost.com/eSi5YaK.gif</img>
</entry>
<entry>
<id>86498759470</id>
<address>http://lesjoiesducode.fr/post/86498759470/quand-on-debug-en-mode-ninja-pendant-la-demo</address>
<title>quand on debug en mode ninja pendant la démo</title>
<img>http://ljdchost.com/ibpfNpQ8sZ4ziO.gif</img>
</entry>
<entry>
<id>86206676795</id>
<address>http://lesjoiesducode.fr/post/86206676795/quand-une-mise-en-production-seffectue-sans-souci</address>
<title>quand une mise en production s'effectue sans souci</title>
<img>http://i.imgur.com/oRTod71.gif</img>
</entry>
<entry>
<id>87094581962</id>
<address>http://thecodinglove.com/post/87094581962/when-caffeine-is-no-longer-effective</address>

View File

@ -600,4 +600,9 @@ div.all_posts div.post
#last_ljdc
{
padding-bottom:40px;
}
.comments_link
{
padding-right:20px;
}