[cmsiki-svn] SF.net SVN: cmsiki: [13] trunk/cmsiki
Status: Pre-Alpha
Brought to you by:
cnu
From: <cn...@us...> - 2007-03-27 16:51:25
|
Revision: 13 http://cmsiki.svn.sourceforge.net/cmsiki/?rev=13&view=rev Author: cnu Date: 2007-03-27 09:50:59 -0700 (Tue, 27 Mar 2007) Log Message: ----------- Added slug field to category model Category detail view added. moved category list in sidebar to base.html changed regex in cmsikireplace Modified Paths: -------------- trunk/cmsiki/apps/story/models.py trunk/cmsiki/cmsikireplace.py trunk/cmsiki/settings.py trunk/cmsiki/templates/base.html trunk/cmsiki/templates/story/story_archive.html trunk/cmsiki/templates/story/story_archive_day.html trunk/cmsiki/templates/story/story_archive_month.html trunk/cmsiki/templates/story/story_detail.html trunk/cmsiki/urls.py Added Paths: ----------- trunk/cmsiki/templates/story/category_detail.html Modified: trunk/cmsiki/apps/story/models.py =================================================================== --- trunk/cmsiki/apps/story/models.py 2007-03-24 20:03:22 UTC (rev 12) +++ trunk/cmsiki/apps/story/models.py 2007-03-27 16:50:59 UTC (rev 13) @@ -1,17 +1,19 @@ from django.db import models from django.contrib.auth.models import User import cmsikireplace +import re # Create your models here. class Category(models.Model): name = models.CharField(maxlength=50) description = models.CharField(maxlength=200) + slug = models.SlugField(prepopulate_from=('name',)) def __str__(self): return self.name class Admin: - list_display = ('name', 'description') + list_display = ('name', 'description', 'slug') class Story(models.Model): title = models.CharField(maxlength=150) Modified: trunk/cmsiki/cmsikireplace.py =================================================================== --- trunk/cmsiki/cmsikireplace.py 2007-03-24 20:03:22 UTC (rev 12) +++ trunk/cmsiki/cmsikireplace.py 2007-03-27 16:50:59 UTC (rev 13) @@ -40,7 +40,7 @@ def getPageHTML(tag): '''Return the page contents from the wiki as HTML.''' - page_pattern = re.compile(':[a-zA-Z_0-9]+@') + page_pattern = re.compile(':\w+@') wiki_pattern = re.compile('@[a-zA-Z]+\]') page_match = page_pattern.findall(tag)[0] page_name = page_match[1:-1] @@ -60,7 +60,7 @@ def getPage(tag): '''Returns the page contents from the wiki as WikiText.''' - page_pattern = re.compile(':[a-zA-Z_0-9]+@') + page_pattern = re.compile(':\w+@') wiki_pattern = re.compile('@[a-zA-Z]+\]') page_match = page_pattern.findall(tag)[0] page_name = page_match[1:-1] @@ -79,7 +79,7 @@ def getPageInfo(tag): '''Return the page contents from the wiki as WikiText.''' - page_pattern = re.compile(':[a-zA-Z_0-9]+@') + page_pattern = re.compile(':\w+@') wiki_pattern = re.compile('@[a-zA-Z]+\]') page_match = page_pattern.findall(tag)[0] page_name = page_match[1:-1] Modified: trunk/cmsiki/settings.py =================================================================== --- trunk/cmsiki/settings.py 2007-03-24 20:03:22 UTC (rev 12) +++ trunk/cmsiki/settings.py 2007-03-27 16:50:59 UTC (rev 13) @@ -18,7 +18,7 @@ # Local time zone for this installation. All choices can be found here: # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE -TIME_ZONE = 'America/Calcutta' +TIME_ZONE = 'Asia/Calcutta' # Language code for this installation. All choices can be found here: # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes Modified: trunk/cmsiki/templates/base.html =================================================================== --- trunk/cmsiki/templates/base.html 2007-03-24 20:03:22 UTC (rev 12) +++ trunk/cmsiki/templates/base.html 2007-03-27 16:50:59 UTC (rev 13) @@ -71,15 +71,11 @@ <h2>Categories</h2> {% block categories %} <ul> - <li><a href="http://localhost/wordpress/?cat=2" - title="View all posts filed under foo">foo</a> (1) + {% for category in categories %} + <li><a href="/category/{{ category.slug }}" + title="View all posts filed under {{ category }}">{{ category.name }}</a> </li> - <li><a href="http://localhost/wordpress/?cat=3" - title="View all posts filed under foo">bar</a> (1) - </li> - <li><a href="http://localhost/wordpress/?cat=1" - title="View all posts filed under baz">baz</a> (3) - </li> + {% endfor %} </ul> {% endblock %} </li> Added: trunk/cmsiki/templates/story/category_detail.html =================================================================== --- trunk/cmsiki/templates/story/category_detail.html (rev 0) +++ trunk/cmsiki/templates/story/category_detail.html 2007-03-27 16:50:59 UTC (rev 13) @@ -0,0 +1,26 @@ +{% extends "base.html" %} + +{% block title %}{{ object.name }}Category{% endblock %} + +{% block post %} + +{% ifequal object.story_set.count 0 %} +<div class="post"> +No posts under this category +</div> + +{% else %} + +{% for story in object.story_set.all %} + +<div class="post"> + <h2><a href="{{ story.get_absolute_url }}">{{ story.title }}</a></h2> + <div class="postinfo">Posted on <span class="postdate">{{ story.pub_date|date:"F j, Y" }}</span> by <strong>{{ story.author }}</strong></div> + + {{ story.replaced_body }} + <div class="postinfo">Posted under category <a href="/category/{{ story.category }}">{{ story.category }}</a>.</div> +</div> +{% endfor %} +</div> +{% endifequal %} +{% endblock %} Modified: trunk/cmsiki/templates/story/story_archive.html =================================================================== --- trunk/cmsiki/templates/story/story_archive.html 2007-03-24 20:03:22 UTC (rev 12) +++ trunk/cmsiki/templates/story/story_archive.html 2007-03-27 16:50:59 UTC (rev 13) @@ -1,15 +1,6 @@ {% extends "base.html" %} {% block title %}Home{% endblock %} -{% block categories %} -<ul> - {% for category in categories %} - <li><a href="/category/{{ category }}" - title="View all posts filed under {{ category }}">{{ category }}</a> - </li> - {% endfor %} -</ul> -{% endblock %} {% block post %} {% for story in latest %} Modified: trunk/cmsiki/templates/story/story_archive_day.html =================================================================== --- trunk/cmsiki/templates/story/story_archive_day.html 2007-03-24 20:03:22 UTC (rev 12) +++ trunk/cmsiki/templates/story/story_archive_day.html 2007-03-27 16:50:59 UTC (rev 13) @@ -1,16 +1,6 @@ {% extends "base.html" %} {% block title %}{{ day|date:"F j" }} archive{% endblock %} -{% block categories %} -<ul> - {% for category in categories %} - <li><a href="/category/{{ category }}" - title="View all posts filed under {{ category }}">{{ category }}</a> - </li> - {% endfor %} -</ul> -{% endblock %} - {% block content %} <div class="content"> {% for story in object_list %} Modified: trunk/cmsiki/templates/story/story_archive_month.html =================================================================== --- trunk/cmsiki/templates/story/story_archive_month.html 2007-03-24 20:03:22 UTC (rev 12) +++ trunk/cmsiki/templates/story/story_archive_month.html 2007-03-27 16:50:59 UTC (rev 13) @@ -1,16 +1,6 @@ {% extends "base.html" %} {% block title %}{{ month|date:"F" }} month archive{% endblock %} -{% block categories %} -<ul> - {% for category in categories %} - <li><a href="/category/{{ category }}" - title="View all posts filed under {{ category }}">{{ category }}</a> - </li> - {% endfor %} -</ul> -{% endblock %} - {% block content %} <div class="content"> Modified: trunk/cmsiki/templates/story/story_detail.html =================================================================== --- trunk/cmsiki/templates/story/story_detail.html 2007-03-24 20:03:22 UTC (rev 12) +++ trunk/cmsiki/templates/story/story_detail.html 2007-03-27 16:50:59 UTC (rev 13) @@ -4,8 +4,8 @@ {% block categories %} <ul> {% for category in categories %} - <li><a href="/category/{{ category }}" - title="View all posts filed under {{ category }}">{{ category }}</a> + <li><a href="/category/{{ category.slug }}" + title="View all posts filed under {{ category }}">{{ category.name }}</a> </li> {% endfor %} </ul> Modified: trunk/cmsiki/urls.py =================================================================== --- trunk/cmsiki/urls.py 2007-03-24 20:03:22 UTC (rev 12) +++ trunk/cmsiki/urls.py 2007-03-27 16:50:59 UTC (rev 13) @@ -10,6 +10,13 @@ }, } +category_detail_info = { + 'queryset':Category.objects.all(), + 'extra_context':{ + 'categories':Category.objects.all(), + }, +} + urlpatterns = patterns('django.views.generic.date_based', # Example: @@ -24,6 +31,11 @@ (r'^/?$', 'archive_index', dict(info_dict)), ) +urlpatterns += patterns('django.views.generic.list_detail', + (r'^category/(?P<slug>[-\w]+)/$', 'object_detail', dict(category_detail_info, slug_field='slug')), +) + + if settings.DEBUG: urlpatterns += patterns('', (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/cnu/projects/python/django/cmsiki/static/', 'show_indexes':True}), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |