Changeset 746

Show
Ignore:
Timestamp:
05/07/07 18:29:30 (1 year ago)
Author:
brian
Message:

modified blog code to be much more functional.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee-www/trunk/cherokee/blog/models.py

    r734 r746  
    88class Post(models.Model): 
    99    author = models.ForeignKey(User, verbose_name=_('Author')) 
    10     title = models.CharField(_('Title'), maxlength=100) 
    11     slug = models.SlugField(_('Slug'), prepopulate_from=('title',)) 
     10    headline = models.CharField(_('Headline'), maxlength=100) 
     11    slug = models.SlugField(_('Slug'), prepopulate_from=('headline',)) 
    1212    body = models.TextField(_('Body')) 
    13     posted_date = models.DateTimeField(_('Date Posted'), default=datetime.now) 
     13    pub_date = models.DateTimeField(_('Date Posted'), default=datetime.now) 
    1414    is_active = models.BooleanField(_('Is Active')) 
    1515     
     
    1717        verbose_name = _('post') 
    1818        verbose_name_plural = _('posts') 
    19         ordering = ('-posted_date',) 
    20         get_latest_by = 'posted_date' 
     19        ordering = ('-pub_date',) 
     20        get_latest_by = 'pub_date' 
    2121     
    2222    class Admin: 
    23         list_display = ('title', 'posted_date', 'is_active',) 
     23        list_display = ('headline', 'pub_date', 'is_active',) 
    2424     
    2525    def __str__(self): 
    26         return self.titl
     26        return self.headlin
    2727     
    2828    def get_absolute_url(self): 
    29         return '/blog/%s/%s/' % (self.posted_date.strftime('%Y/%b/%d').lower(), self.slug) 
     29        return '/blog/%s/%s/' % (self.pub_date.strftime('%Y/%b/%d').lower(), self.slug) 
  • cherokee-www/trunk/cherokee/blog/sitemaps.py

    r734 r746  
    99     
    1010    def items(self): 
    11         return Post.objects.filter(posted_date__lte=datetime.now()) 
     11        return Post.objects.filter(pub_date__lte=datetime.now()) 
  • cherokee-www/trunk/cherokee/blog/templates/blog/post_archive.html

    r735 r746  
    11{% extends "base.html" %} 
     2{% load text comments %} 
     3 
     4{% block extrahead %} 
     5    <link href="/media/css/blog.css" type="text/css" rel="stylesheet" /> 
     6    <script src="/media/js/jquery.js" type="text/javascript"></script> 
     7    <script src="/media/js/plugins/jquery.block.js" type="text/javascript"></script> 
     8    <script src="/media/js/blog.js" type="text/javascript"></script> 
     9{% endblock %} 
    210 
    311{% block content %} 
    412    {% for post in latest %} 
    5     <h2>{{ post.title }}</h2> 
    6     <p>{{ post.body }}</p> 
     13    {% get_free_comment_count for blog.post post.id as comment_count %} 
     14    <div id="post_{{ post.id }}" class="post"> 
     15        <div class="post_date"> 
     16            <p class="month">{{ post.pub_date|date:"M" }}</p> 
     17            <p class="day">{{ post.pub_date|date:"d" }}</p> 
     18            <p class="year">{{ post.pub_date|date:"Y" }}</p> 
     19        </div> 
     20        <div class="post_detail"> 
     21            <h2><a href="{{ post.get_absolute_url }}">{{ post.headline }}</a></h2> 
     22     
     23            <p>{{ post.body|markdown_and_pygments }}</p> 
     24     
     25            <ul class="post_info_line"> 
     26                <li><a href="#" onclick="show_comments(this, {{ post.id }}, '{{ comment_count }} comment{{ comment_count|pluralize }}', 'hide comment{{ comment_count|pluralize }}'); return false;">{{ comment_count }} comment{{ comment_count|pluralize }}</a></li> 
     27                <li><a href="#" onclick="show_add_comment({{ post.id }}); return false;">say something</a></li> 
     28                <li><a href="#" onclick="digg_this('{{ post_headline }}', '{{ post.get_absolute_url }}'); return false;" id="digg_this">digg this</a></li> 
     29                <li><a href="http://del.icio.us/post" onclick="delicious_bookmark('{{ post.headline }}', '{{ post.get_absolute_url }}'); return false;" id="delicious">save this</a></li> 
     30            </ul> 
     31             
     32            <br class="clear" /> 
     33             
     34            <div id="add_comment_for_{{ post.id }}" class="add_comment" style="display: none;"> 
     35                <form method="POST" action=""> 
     36                    <ol> 
     37                        <li> 
     38                            <label for="id_person_name">Your Name</label> 
     39                            <input type="text" name="person_name" id="id_person_name" /> 
     40                        </li> 
     41                        <li> 
     42                            <label for="id_comment">Comment</label> 
     43                            <textarea name="comment" id="id_comment" rows="10" cols="60"></textarea> 
     44                        </li> 
     45                    </ol> 
     46                    <p><input type="submit" value="Post" /></p> 
     47                </form> 
     48            </div> 
     49             
     50            <div id="comments_for_{{ post.id }}" class="comments" style="display: none;"></div> 
     51             
     52        </div> 
     53         
     54        <br class="clear" /> 
     55        <br class="clear" /> 
     56         
     57    </div> 
     58     
    759    {% endfor %} 
    860{% endblock %} 
  • cherokee-www/trunk/cherokee/blog/urls.py

    r734 r746  
    11 
    22from django.conf.urls.defaults import * 
     3from django.views.generic.simple import direct_to_template 
     4 
    35from models import Post 
    46 
    57info_dict = { 
    68    'queryset': Post.objects.filter(is_active=True), 
    7     'date_field': 'posted_date', 
     9    'date_field': 'pub_date', 
    810} 
    911 
     
    1618    (r'^/?$', 'archive_index', info_dict), 
    1719) 
     20 
     21urlpatterns += patterns('', 
     22    (r'^comment_list/(?P<id>\d+)/$', direct_to_template, {'template': 'blog/comment_list.html'}), 
     23) 
  • cherokee-www/trunk/cherokee/media/css/global.css

    r735 r746  
    2424    font-size: 11px; 
    2525} 
     26 
     27.clear { 
     28    clear: both; 
     29} 
  • cherokee-www/trunk/cherokee/settings.py

    r741 r746  
    5252TEMPLATE_CONTEXT_PROCESSORS = ( 
    5353    'django.core.context_processors.i18n', 
     54    'django.core.context_processors.auth', 
    5455) 
    5556 
     
    6566    'django.contrib.admin', 
    6667    'django.contrib.sitemaps', 
     68    'django.contrib.comments', 
    6769    'django.contrib.markup', 
    6870