1.1 --- a/agdj/blog/views.py Sun Feb 01 01:35:02 2009 -0500
1.2 +++ b/agdj/blog/views.py Sun Feb 01 02:55:17 2009 -0500
1.3 @@ -36,10 +36,10 @@
1.4
1.5
1.6 @use_template("blog/post_list.html")
1.7 -def post_list(request):
1.8 +def post_list(request, limit=10):
1.9 "List all entries"
1.10
1.11 - posts = models.Entry.objects.filter(public=True).order_by("-pub_date")
1.12 + posts = models.Entry.objects.filter(public=True).order_by("-pub_date")[:limit]
1.13 return dict(posts=posts)
1.14
1.15
1.16 @@ -51,3 +51,24 @@
1.17 posts = models.Entry.objects.filter(public=True).order_by("-pub_date")
1.18 posts = TaggedItem.objects.get_by_model(posts, tag)
1.19 return dict(posts=posts, tag=tag)
1.20 +
1.21 +
1.22 +@use_template("blog/archive.html")
1.23 +def archive_index(request):
1.24 + "Show the multi-year archive"
1.25 + from agdj.blog import archive
1.26 +
1.27 + archive = archive.Archive(models.Entry.objects.all())
1.28 +
1.29 + return {"archive": archive}
1.30 +
1.31 +
1.32 +def archive_month(request, year, month):
1.33 + "Show the multi-year archive"
1.34 + from django.views.generic.date_based import archive_month
1.35 + from agdj.blog import archive
1.36 + return archive_month(
1.37 + # request, year, month, qs, date_field
1.38 + request, year, month, models.Entry.objects.all(), "pub_date",
1.39 + template_name="blog/archive_month.html",)
1.40 +