7QtUTWQIPK1wOip3EAIyqc changeset

Changeset373164666138 (b)
ParentNone (a)
ab
0+home.html
0+
0+{% extends "layout/base2.html" %}
0+{% load generic_content %}
0+{% load blog_extras %}
0+
0+
0+
0+
0+{% block cont_actu %}
0+{% get_latest_objects blog.entry 5 as latest_entry %}
0+{% display_last_entry %}
0+
0+
0+
0+{% endblock cont_actu %}
0+
0+blog_extras.py
0+
0+# -*- coding: utf-8 -*-
0+from django import template
0+from django.template import Library, Node, TemplateSyntaxError
0+from django.conf import settings
0+from monsite.blog.models import Tag,Entry
0+
0+
0+
0+
0+register = template.Library()
0+
0+
0+@register.inclusion_tag('blog/tag_list.html')
0+def show_alltags():
0+        allmytags = Tag.objects.order_by('name')
0+        return {'alltags': allmytags}
0+
0+@register.inclusion_tag('blog/archive_by_year.html')
0+def archive_by_year():
0+        year_list = Entry.objects.dates('pub_date','year', order='ASC')
0+        return {'year_list': year_list}
0+
0+@register.inclusion_tag('blog/archive_by_month.html')
0+def archive_by_month():
0+        month_list = Entry.objects.dates('pub_date','month', order='ASC')
0+        return {'month_list': month_list}
0+
0+
0+def display_last_entry(context):
0+    """
0+    Display latest posts, ``latest_posts`` var should be in the context.
0+
0+    Usage::
0+
0+        {% get_latest_objects journal.Post 5 as latest_posts %}
0+        {% display_footer_posts %}
0+
0+    This will use ``display_footer_posts.html`` template.
0+    """
0+    return { 'latest_entry': context['latest_entry'] }
0+
0+
0+
0+register.inclusion_tag('blog/display_last_entry.html', takes_context=True)(display_last_entry)
0+
0+display_last_entry.html
0+
0+<h3>Derniers billets publiés</h3>
0+<ul>
0+{% for entry in latest_posts %}
0+    <li><a href="{{ entry.get_absolute_url }}" title="Lire le billet intitulé {{ entry.title }}">{{ entry|safe }}</a></li>
0+{% endfor %}
0+</ul>
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
--- Revision None
+++ Revision 373164666138
@@ -0,0 +1,72 @@
+home.html
+
+{% extends "layout/base2.html" %}
+{% load generic_content %}
+{% load blog_extras %}
+
+
+
+
+{% block cont_actu %}
+{% get_latest_objects blog.entry 5 as latest_entry %}
+{% display_last_entry %}
+
+
+
+{% endblock cont_actu %}
+
+blog_extras.py
+
+# -*- coding: utf-8 -*-
+from django import template
+from django.template import Library, Node, TemplateSyntaxError
+from django.conf import settings
+from monsite.blog.models import Tag,Entry
+
+
+
+
+register = template.Library()
+
+
+@register.inclusion_tag('blog/tag_list.html')
+def show_alltags():
+ allmytags = Tag.objects.order_by('name')
+ return {'alltags': allmytags}
+
+@register.inclusion_tag('blog/archive_by_year.html')
+def archive_by_year():
+ year_list = Entry.objects.dates('pub_date','year', order='ASC')
+ return {'year_list': year_list}
+
+@register.inclusion_tag('blog/archive_by_month.html')
+def archive_by_month():
+ month_list = Entry.objects.dates('pub_date','month', order='ASC')
+ return {'month_list': month_list}
+
+
+def display_last_entry(context):
+ """
+ Display latest posts, ``latest_posts`` var should be in the context.
+
+ Usage::
+
+ {% get_latest_objects journal.Post 5 as latest_posts %}
+ {% display_footer_posts %}
+
+ This will use ``display_footer_posts.html`` template.
+ """
+ return { 'latest_entry': context['latest_entry'] }
+
+
+
+register.inclusion_tag('blog/display_last_entry.html', takes_context=True)(display_last_entry)
+
+display_last_entry.html
+
+<h3>Derniers billets publiés</h3>
+<ul>
+{% for entry in latest_posts %}
+ <li><a href="{{ entry.get_absolute_url }}" title="Lire le billet intitulé {{ entry.title }}">{{ entry|safe }}</a></li>
+{% endfor %}
+</ul>