From c7b29da94d3b85ec91f0d5e2789db11a43473df5 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sun, 1 Feb 2009 06:25:10 -0500 Subject: lots went on: * rss feeds * some admin interface stuff * blah running issues: * admin interface with model inheretence? * rss feeds: unicode cool? * proper year/month implementation (don't want day) * right side bar info * dating issue (datetime vs date) --- bn_django/journal/admin.py | 51 ++++++++++++++++++++++ bn_django/journal/feeds.py | 34 +++++++++++++++ bn_django/journal/models.py | 34 ++++++++++----- .../feeds/latest_entries_description.html | 1 + .../templates/feeds/latest_entries_title.html | 1 + .../templates/feeds/latest_links_description.html | 1 + .../templates/feeds/latest_links_title.html | 1 + .../feeds/latest_microentries_description.html | 1 + .../templates/feeds/latest_microentries_title.html | 1 + .../templates/journal/entry_archive_month.html | 35 +++++++++++++++ .../templates/journal/entry_archive_year.html | 35 +++++++++++++++ .../journal/templates/journal/entry_detail.html | 4 +- .../journal/templates/journal/entry_list.html | 26 ++++++++--- .../templates/journal/linkartifact_list.html | 10 +++++ .../templates/journal/microentry_arhive_month.html | 31 +++++++++++++ .../templates/journal/microentry_arhive_year.html | 31 +++++++++++++ .../templates/journal/microentry_detail.html | 4 +- .../journal/templates/journal/microentry_list.html | 31 ++++++++----- bn_django/journal/urls.py | 27 ++++++++++-- bn_django/templates/about.html | 1 + bn_django/templates/base.html | 8 ++-- bn_django/templates/comment_list | 2 +- bn_django/templates/frontpage.html | 2 + 23 files changed, 334 insertions(+), 38 deletions(-) create mode 100644 bn_django/journal/admin.py create mode 100644 bn_django/journal/feeds.py create mode 100644 bn_django/journal/templates/feeds/latest_entries_description.html create mode 100644 bn_django/journal/templates/feeds/latest_entries_title.html create mode 100644 bn_django/journal/templates/feeds/latest_links_description.html create mode 100644 bn_django/journal/templates/feeds/latest_links_title.html create mode 100644 bn_django/journal/templates/feeds/latest_microentries_description.html create mode 100644 bn_django/journal/templates/feeds/latest_microentries_title.html create mode 100644 bn_django/journal/templates/journal/entry_archive_month.html create mode 100644 bn_django/journal/templates/journal/entry_archive_year.html create mode 100644 bn_django/journal/templates/journal/microentry_arhive_month.html create mode 100644 bn_django/journal/templates/journal/microentry_arhive_year.html (limited to 'bn_django') diff --git a/bn_django/journal/admin.py b/bn_django/journal/admin.py new file mode 100644 index 0000000..3f1024c --- /dev/null +++ b/bn_django/journal/admin.py @@ -0,0 +1,51 @@ +from django.contrib import admin +from bn_django.journal.models import * + +class EntryAdmin(admin.ModelAdmin): + #fieldsets = ( + #(None, { + #'fields': ('title', 'date', 'html_content', 'author', 'subjournal') + #}, ), + ##('Advanced options', { + #'classes': ('collapse',), + #'fields': ('slug',)})) + #prepopulated_fields = {'slug': ('title'),'text_content': ('html_content')} + #date_hierarchy = 'date' + #list_display = ('date', 'title', 'subjournal', 'author') + search_fields = ('title','text_content') + +class MicroEntryAdmin(admin.ModelAdmin): + #fieldsets = ( + #(None, { + #'fields': ('title', 'date', 'html_content', 'author', + #'subjournal',), }), + #('Advanced options', { + #'classes': ('collapse',), + #'fields': ('slug',)})) + prepopulated_fields = {'slug': ('title'),'text_content': ('html_content')} + date_hierarchy = 'date' + list_display = ('date', 'title', 'subjournal', 'author') + search_fields = ('title','text_content') + +class SubJournalAdmin(admin.ModelAdmin): + pass + +class LinkArtifactAdmin(admin.ModelAdmin): + pass + +class CodeAdmin(admin.ModelAdmin): + pass + +class VideoAdmin(admin.ModelAdmin): + pass + +class ImageAdmin(admin.ModelAdmin): + pass + +admin.site.register(Entry,EntryAdmin) +admin.site.register(MicroEntry,EntryAdmin) +admin.site.register(SubJournal) +admin.site.register(LinkArtifact) +admin.site.register(CodeArtifact) +admin.site.register(VideoArtifact) +admin.site.register(ImageArtifact) diff --git a/bn_django/journal/feeds.py b/bn_django/journal/feeds.py new file mode 100644 index 0000000..3577c46 --- /dev/null +++ b/bn_django/journal/feeds.py @@ -0,0 +1,34 @@ +from django.contrib.syndication.feeds import Feed +from models import Entry, MicroEntry, LinkArtifact + + +class LatestEntries(Feed): + title = "bnewbold.net journal entries" + link = "/journal/entries/" + description = " " + + def items(self): + return Entry.objects.order_by('-date')[:5] + +class LatestMicroEntries(Feed): + title = "bnewbold.net microentries" + link = "/journal/microentries/" + description = "Quick updates" + + def items(self): + return MicroEntry.objects.order_by('-date')[:5] + +class LatestLinks(Feed): + title = "bnewbold.net links" + link = "/artifacts/links/" + description = "Links to love" + + def items(self): + return LinkArtifact.objects.order_by('-date')[:5] + + def item_link(self,item): + return item.url + +feed_list = {'latest_entries':LatestEntries, + 'latest_microentries':LatestMicroEntries, + 'latest_links':LatestLinks } diff --git a/bn_django/journal/models.py b/bn_django/journal/models.py index d296f1f..20107c9 100644 --- a/bn_django/journal/models.py +++ b/bn_django/journal/models.py @@ -10,6 +10,9 @@ class SubJournal(models.Model): slug = models.SlugField() description = models.TextField("description of content",blank=True) + def __unicode__(self): + return self.name + class Meta: get_latest_by = 'date' ordering = ['-date'] @@ -17,7 +20,7 @@ class SubJournal(models.Model): class JournalCommon(models.Model): author = User("User who created this") date = models.DateTimeField("associated day", auto_now=True) - last_edited = models.DateField("day last edited", auto_now_add=True) + last_edited = models.DateTimeField("day last edited", auto_now_add=True) subjournal = models.ForeignKey(SubJournal,blank=True,null=True) defunct = models.BooleanField("is this entry all around done with?",default=False,blank=False) private = models.BooleanField("is this entry for validated users only?",default=False,blank=False) @@ -32,13 +35,24 @@ class Entry(JournalCommon): title = models.CharField("entry title", max_length=384) slug = models.SlugField() + def __unicode__(self): + return self.title + def get_absolute_url(self): - return "/journal/%s/"%self.slug + #return "/journal/entries/%04d/%02d/%02d/%s/"%(self.date.year, self.date.month, self.date.day, self.slug) + return "/journal/entries/%s/"%self.slug class MicroEntry(JournalCommon): html_content = models.TextField("html format content", blank=False) text_content = models.TextField("text version of content", blank=True,null=True) + def __unicode__(self): + self.text_content[:50] + + def get_absolute_url(self): + return "/journal/microentries/%s/"%self.id + #return "/journal/microentries/%04d/%02d/%02d/%s/"%(self.date.year, self.date.month, self.date.day, self.slug) + class Artifact(JournalCommon): html_caption = models.TextField("html format caption", blank=True) text_caption = models.TextField("text format caption", blank=True) @@ -61,6 +75,12 @@ class CodeArtifact(Artifact): class LinkArtifact(Artifact): url = models.URLField("external link to something wonderful!",verify_exists=False) + def __unicode__(self): + return self.title + + def get_absolute_url(self): + return "/artifacts/links/%s/"% self.id + class ImageArtifact(Artifact,Photo): """Multiply inherets from the photo app """ @@ -76,13 +96,3 @@ def delete_thumbnails(sender, instance, signal, *args, **kwargs): signals.post_save.connect(build_display_images, sender=ImageArtifact) signals.pre_delete.connect(delete_thumbnails, sender=ImageArtifact) - -from django.contrib import admin - -admin.site.register(Entry) -admin.site.register(MicroEntry) -admin.site.register(SubJournal) -admin.site.register(LinkArtifact) -admin.site.register(CodeArtifact) -admin.site.register(VideoArtifact) -admin.site.register(ImageArtifact) diff --git a/bn_django/journal/templates/feeds/latest_entries_description.html b/bn_django/journal/templates/feeds/latest_entries_description.html new file mode 100644 index 0000000..6f28865 --- /dev/null +++ b/bn_django/journal/templates/feeds/latest_entries_description.html @@ -0,0 +1 @@ +{{obj.html_content|safe|truncatewords_html:300}} diff --git a/bn_django/journal/templates/feeds/latest_entries_title.html b/bn_django/journal/templates/feeds/latest_entries_title.html new file mode 100644 index 0000000..e12d8e1 --- /dev/null +++ b/bn_django/journal/templates/feeds/latest_entries_title.html @@ -0,0 +1 @@ +{{obj.title|safe}} diff --git a/bn_django/journal/templates/feeds/latest_links_description.html b/bn_django/journal/templates/feeds/latest_links_description.html new file mode 100644 index 0000000..32c8857 --- /dev/null +++ b/bn_django/journal/templates/feeds/latest_links_description.html @@ -0,0 +1 @@ +{{ obj.html_caption|safe|truncatewords_html:200}} diff --git a/bn_django/journal/templates/feeds/latest_links_title.html b/bn_django/journal/templates/feeds/latest_links_title.html new file mode 100644 index 0000000..65599bb --- /dev/null +++ b/bn_django/journal/templates/feeds/latest_links_title.html @@ -0,0 +1 @@ +{{ obj.title }}: {{ obj.url }} diff --git a/bn_django/journal/templates/feeds/latest_microentries_description.html b/bn_django/journal/templates/feeds/latest_microentries_description.html new file mode 100644 index 0000000..427823d --- /dev/null +++ b/bn_django/journal/templates/feeds/latest_microentries_description.html @@ -0,0 +1 @@ +{{obj.html_content|safe|truncatewords_html:160}} diff --git a/bn_django/journal/templates/feeds/latest_microentries_title.html b/bn_django/journal/templates/feeds/latest_microentries_title.html new file mode 100644 index 0000000..d992ff6 --- /dev/null +++ b/bn_django/journal/templates/feeds/latest_microentries_title.html @@ -0,0 +1 @@ +{{obj.title}} diff --git a/bn_django/journal/templates/journal/entry_archive_month.html b/bn_django/journal/templates/journal/entry_archive_month.html new file mode 100644 index 0000000..a9e72da --- /dev/null +++ b/bn_django/journal/templates/journal/entry_archive_month.html @@ -0,0 +1,35 @@ +{% extends "journal/base.html" %} +{% load comments %} + +{% block title %}Journal Entries{% endblock %} + +{% block content %} +
+
+This page has an RSS feed. +
+See also artifacts, +microentries. + +
+{% if object_list %} + {% for item in object_list %} + {% get_comment_count for item as comment_count %} +

+ {% if item.title %}{{item.title}}{%else%}[Untitled]{%endif%}

+ {{item.date|date:"D, d/m/Y @H:i"}} by {{ item.author.username }}. + {{ comment_count }} comments +

+ {{ item.html_content|truncatewords_html:256 }} +

+ {% endfor %} +{% else %} +

No entries have been entered yet!

+{% endif %} + +{% if is_paginated %} {% if has_previous %} +« previous | +{% endif %} {% if has_next %} +next » +{% endif %} {% endif %} +{% endblock %} diff --git a/bn_django/journal/templates/journal/entry_archive_year.html b/bn_django/journal/templates/journal/entry_archive_year.html new file mode 100644 index 0000000..a9e72da --- /dev/null +++ b/bn_django/journal/templates/journal/entry_archive_year.html @@ -0,0 +1,35 @@ +{% extends "journal/base.html" %} +{% load comments %} + +{% block title %}Journal Entries{% endblock %} + +{% block content %} +
+
+This page has an RSS feed. +
+See also artifacts, +microentries. + +
+{% if object_list %} + {% for item in object_list %} + {% get_comment_count for item as comment_count %} +

+ {% if item.title %}{{item.title}}{%else%}[Untitled]{%endif%}

+ {{item.date|date:"D, d/m/Y @H:i"}} by {{ item.author.username }}. + {{ comment_count }} comments +

+ {{ item.html_content|truncatewords_html:256 }} +

+ {% endfor %} +{% else %} +

No entries have been entered yet!

+{% endif %} + +{% if is_paginated %} {% if has_previous %} +« previous | +{% endif %} {% if has_next %} +next » +{% endif %} {% endif %} +{% endblock %} diff --git a/bn_django/journal/templates/journal/entry_detail.html b/bn_django/journal/templates/journal/entry_detail.html index 9c74ed6..b68e4b6 100644 --- a/bn_django/journal/templates/journal/entry_detail.html +++ b/bn_django/journal/templates/journal/entry_detail.html @@ -1,8 +1,8 @@ {% extends "journal/base.html" %} -{# {% load markup %} #} {% load comments %} + {% block path %}{{ block.super }} - » {{ object.title }} + » {{ object.title }} {% endblock %} {% block title %} diff --git a/bn_django/journal/templates/journal/entry_list.html b/bn_django/journal/templates/journal/entry_list.html index caa07af..8902552 100644 --- a/bn_django/journal/templates/journal/entry_list.html +++ b/bn_django/journal/templates/journal/entry_list.html @@ -1,18 +1,34 @@ {% extends "journal/base.html" %} -{# {% load markup %} #} +{% load comments %} {% block title %}Journal Entries{% endblock %} +{% block otherhead %}{{ block.super}} + +{% endblock %} + {% block content %}
+
+This page has an RSS feed. +
+See also artifacts, +microentries. + +
{% if object_list %} - {% else %} -

No entries have been entered yet.

+

No entries have been entered yet!

{% endif %} {% if is_paginated %} {% if has_previous %} diff --git a/bn_django/journal/templates/journal/linkartifact_list.html b/bn_django/journal/templates/journal/linkartifact_list.html index 829e627..51e9ebe 100644 --- a/bn_django/journal/templates/journal/linkartifact_list.html +++ b/bn_django/journal/templates/journal/linkartifact_list.html @@ -1,5 +1,9 @@ {% extends "journal/base.html" %} +{% block otherhead %}{{ block.super}} + +{% endblock %} + {% block path %}artifacts » links {% endblock %} @@ -8,6 +12,12 @@ {% block content %}
+
+This page has an RSS feed. +
+microentries. +
+ {% if object_list %}