[cmsiki-svn] SF.net SVN: cmsiki: [17] trunk/cmsiki
Status: Pre-Alpha
Brought to you by:
cnu
From: <cn...@us...> - 2007-03-29 20:45:15
|
Revision: 17 http://cmsiki.svn.sourceforge.net/cmsiki/?rev=17&view=rev Author: cnu Date: 2007-03-29 13:45:06 -0700 (Thu, 29 Mar 2007) Log Message: ----------- Added list of month and year archives to the side bar. Using template tags http://www.rossp.org/blog/2006/jun/23/building-blog-django-4/ Modified Paths: -------------- trunk/cmsiki/templates/base.html trunk/cmsiki/urls.py Added Paths: ----------- trunk/cmsiki/apps/story/templatetags/ trunk/cmsiki/apps/story/templatetags/__init__.py trunk/cmsiki/apps/story/templatetags/story_months.py trunk/cmsiki/apps/story/templatetags/story_years.py Added: trunk/cmsiki/apps/story/templatetags/__init__.py =================================================================== Added: trunk/cmsiki/apps/story/templatetags/story_months.py =================================================================== --- trunk/cmsiki/apps/story/templatetags/story_months.py (rev 0) +++ trunk/cmsiki/apps/story/templatetags/story_months.py 2007-03-29 20:45:06 UTC (rev 17) @@ -0,0 +1,17 @@ +from cmsiki.apps.story.models import Story +from django.template import Library,Node + +register = Library() + +def build_month_list(parser, token): + """ + {% get_month_list %} + """ + return MonthMenuObject() + +class MonthMenuObject(Node): + def render(self, context): + context['story_months'] = Story.objects.dates("pub_date", "month") + return '' + +register.tag('get_month_list', build_month_list) Added: trunk/cmsiki/apps/story/templatetags/story_years.py =================================================================== --- trunk/cmsiki/apps/story/templatetags/story_years.py (rev 0) +++ trunk/cmsiki/apps/story/templatetags/story_years.py 2007-03-29 20:45:06 UTC (rev 17) @@ -0,0 +1,17 @@ +from cmsiki.apps.story.models import Story +from django.template import Library,Node + +register = Library() + +def build_year_list(parser, token): + """ + {% get_year_list %} + """ + return YearMenuObject() + +class YearMenuObject(Node): + def render(self, context): + context['story_years'] = Story.objects.dates("pub_date", "year") + return '' + +register.tag('get_year_list', build_year_list) Modified: trunk/cmsiki/templates/base.html =================================================================== --- trunk/cmsiki/templates/base.html 2007-03-27 20:19:28 UTC (rev 16) +++ trunk/cmsiki/templates/base.html 2007-03-29 20:45:06 UTC (rev 17) @@ -86,12 +86,12 @@ <h2>Month Archives</h2> {% block montharchives %} <ul> - <li><a href="http://localhost:8000/2007/03" - title="March 2007">March 2007</a> + {% load story_months %}{% get_month_list %} + {% for month in story_months %} + <li><a href="/{{ month|date:"Y/m/" }}" + title="{{ month|date:"F Y" }}">{{ month|date:"F Y" }}</a> </li> - <li><a href="http://localhost:8000/2007/02" - title="February 2007">February 2007</a> - </li> + {% endfor %} </ul> {% endblock %} </li> @@ -99,14 +99,17 @@ <h2>Year Archives</h2> {% block yeararchives %} <ul> - <li><a href="http://localhost:8000/2007" - title="2007">2007</a> + {% load story_years %}{% get_year_list %} + {% for year in story_years %} + <li><a href="/{{ year|date:"Y/" }}" + title="{{ year|date:"Y" }}">{{ year|date:"Y" }}</a> </li> + {% endfor %} </ul> - {% endblock %} - </li> - </ul> - </div> + {% endblock %} + </li> + </ul> + </div> <!-- End Obar --> @@ -128,12 +131,7 @@ <div class="entry"> - <p><span>I am trying out this new Digg theme which I - found over - at <a - href="http://www.wpdesigner.com/">http://www.wpdesigner.com/</a></span></p> - <p>This site has over 40 free downloadable - theme. The task is now to port this over to cmsiki + <p>This is the base HTML. If this shows up in any place, then something is wrong with the templates. </p> <p class="postinfo"> Modified: trunk/cmsiki/urls.py =================================================================== --- trunk/cmsiki/urls.py 2007-03-27 20:19:28 UTC (rev 16) +++ trunk/cmsiki/urls.py 2007-03-29 20:45:06 UTC (rev 17) @@ -9,6 +9,8 @@ 'extra_context':{ 'categories':Category.objects.all(), 'pages':Page.objects.all(), + 'month_archives':Story.objects.dates('pub_date','month'), + 'year_archives':Story.objects.dates('pub_date','year'), }, } @@ -17,6 +19,8 @@ 'extra_context':{ 'categories':Category.objects.all(), 'pages':Page.objects.all(), + 'month_archives':Story.objects.dates('pub_date','month'), + 'year_archives':Story.objects.dates('pub_date','year'), }, } @@ -25,6 +29,8 @@ 'extra_context':{ 'categories':Category.objects.all(), 'pages':Page.objects.all(), + 'month_archives':Story.objects.dates('pub_date','month'), + 'year_archives':Story.objects.dates('pub_date','year'), }, } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |