Permalink
Browse files

Initial import.

  • Loading branch information...
0 parents commit 22540de6ff9240d5318b5c35de8106227d1b1f27 Greg Taylor committed May 23, 2011
Showing 1,507 changed files with 45,916 additions and 0 deletions.
@@ -0,0 +1,14 @@
+*.pyc
+*~
+*.svn
+*.db3
+.dump
+local_settings.py
+.project
+.pydevproject
+.settings
+fabtastic
+*.log
+*.pid
+media/admin_media
+.DS_Store
@@ -0,0 +1,19 @@
+gsite
+=====
+
+This project contains the complete source code for my website, which can
+be found at http://gc-taylor.com. Given that it is not at all difficult to
+hand-craft such a thing on your own, this is mostly offered in the open for
+the sake of example.
+
+Licensing
+--------------------------
+
+All source code contained within is licensed under Creative Commons,
+Attribution 3.0 Unported, which you may find at
+http://creativecommons.org/licenses/by/3.0/
+
+Support, installing, etc.
+-------------------------
+
+Absolutely no support is offered for any of this.
No changes.
No changes.
No changes.
@@ -0,0 +1,14 @@
+from django.contrib import admin
+from apps.blog.models import BlogPost, BlogCategory
+
+class BlogPostAdmin(admin.ModelAdmin):
+ list_display = ['title', 'slug', 'date_added']
+ list_filter = ('date_added', 'category')
+ search_fields = ['title', 'body', 'category__name']
+ prepopulated_fields = {"slug": ("title",)}
+admin.site.register(BlogPost, BlogPostAdmin)
+
+class BlogCategoryAdmin(admin.ModelAdmin):
+ list_display = ['name', 'slug']
+ prepopulated_fields = {"slug": ("name",)}
+admin.site.register(BlogCategory, BlogCategoryAdmin)
@@ -0,0 +1,92 @@
+import datetime
+from django.contrib.syndication.views import Feed, FeedDoesNotExist
+from apps.blog.models import BlogPost, BlogCategory
+
+AUTHOR_NAME = "Greg Taylor"
+AUTHOR_EMAIL = "gtaylor@gc-taylor.com"
+COPYRIGHT = "Copyright (c) 2011, Gregory Taylor"
+
+class LatestBposts(Feed):
+ """
+ A feed of all of the latest published BlogPost objects.
+ """
+ title = "Greg Taylor's Blog"
+ description = "The latest posts from the blog of Greg Taylor."
+ copyright = COPYRIGHT
+ author_name = AUTHOR_NAME
+ author_email = AUTHOR_EMAIL
+ link = 'http://gc-taylor.com'
+
+ def items(self):
+ now = datetime.datetime.now
+ return BlogPost.objects.filter(date_published__lte=now)[:10]
+
+ def item_title(self, item):
+ return item.title
+
+ def item_description(self, item):
+ return item.body
+
+ def item_guid(self, item):
+ return '%s' % item.id
+
+ def item_link(self, item):
+ return item.get_absolute_url()
+
+ def item_pubdate(self, item):
+ return item.date_published
+
+ def item_categories(self, item):
+ return [cat.name for cat in item.category.all()]
+
+class BpostCatPosts(Feed):
+ """
+ Latest blog posts for a certain category.
+ """
+ author_name = AUTHOR_NAME
+ author_email = AUTHOR_EMAIL
+ copyright = COPYRIGHT
+
+ def title(self, obj):
+ return "Greg Taylor's Latest: %s" % obj.name
+
+ def description(self, obj):
+ return "The latest posts from the %s category of Greg Taylor's blog." % obj.name
+
+ def link(self, obj):
+ if not obj:
+ raise FeedDoesNotExist
+ return obj.get_absolute_url()
+
+ def get_object(self, request, bcat_id):
+ return BlogCategory.objects.get(id=bcat_id)
+
+ def items(self, obj):
+ now = datetime.datetime.now
+ return BlogPost.objects.filter(category__in=[obj.id],
+ date_published__lte=now)[:10]
+
+ def item_title(self, item):
+ return item.title
+
+ def item_description(self, item):
+ return item.body
+
+ def item_guid(self, item):
+ return '%s' % item.id
+
+ def item_link(self, item):
+ return item.get_absolute_url()
+
+ def item_pubdate(self, item):
+ return item.date_published
+
+ def item_categories(self, item):
+ return [cat.name for cat in item.category.all()]
+
+class BpostCatPostsBySlug(BpostCatPosts):
+ """
+ Latest bog posts for a certain category, looked up by slug instead of PK.
+ """
+ def get_object(self, request, bcat_slug):
+ return BlogCategory.objects.get(slug=bcat_slug)
@@ -0,0 +1,64 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding model 'BlogCategory'
+ db.create_table('blog_blogcategory', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=50)),
+ ))
+ db.send_create_signal('blog', ['BlogCategory'])
+
+ # Adding model 'BlogPost'
+ db.create_table('blog_blogpost', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('title', self.gf('django.db.models.fields.CharField')(max_length=255)),
+ ('body', self.gf('django.db.models.fields.TextField')()),
+ ('date_added', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+ ))
+ db.send_create_signal('blog', ['BlogPost'])
+
+ # Adding M2M table for field category on 'BlogPost'
+ db.create_table('blog_blogpost_category', (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('blogpost', models.ForeignKey(orm['blog.blogpost'], null=False)),
+ ('blogcategory', models.ForeignKey(orm['blog.blogcategory'], null=False))
+ ))
+ db.create_unique('blog_blogpost_category', ['blogpost_id', 'blogcategory_id'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'BlogCategory'
+ db.delete_table('blog_blogcategory')
+
+ # Deleting model 'BlogPost'
+ db.delete_table('blog_blogpost')
+
+ # Removing M2M table for field category on 'BlogPost'
+ db.delete_table('blog_blogpost_category')
+
+
+ models = {
+ 'blog.blogcategory': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'BlogCategory'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'})
+ },
+ 'blog.blogpost': {
+ 'Meta': {'ordering': "['-date_added']", 'object_name': 'BlogPost'},
+ 'body': ('django.db.models.fields.TextField', [], {}),
+ 'category': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['blog.BlogCategory']", 'symmetrical': 'False'}),
+ 'date_added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['blog']
@@ -0,0 +1,55 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+from django.template.defaultfilters import slugify
+from apps.blog.models import BlogPost, BlogCategory
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding field 'BlogCategory.slug'
+ db.add_column('blog_blogcategory', 'slug', self.gf('django.db.models.fields.SlugField')(default='', max_length=255, db_index=True), keep_default=False)
+
+ # Adding field 'BlogPost.slug'
+ db.add_column('blog_blogpost', 'slug', self.gf('django.db.models.fields.SlugField')(default='', max_length=255, db_index=True), keep_default=False)
+
+ for bpost in BlogPost.objects.all():
+ bpost.slug = slugify(bpost.title)
+ bpost.save()
+
+ for bcat in BlogCategory.objects.all():
+ bcat.slug = slugify(bcat.name)
+ bcat.save()
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'BlogCategory.slug'
+ db.delete_column('blog_blogcategory', 'slug')
+
+ # Deleting field 'BlogPost.slug'
+ db.delete_column('blog_blogpost', 'slug')
+
+
+ models = {
+ 'blog.blogcategory': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'BlogCategory'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'db_index': 'True'})
+ },
+ 'blog.blogpost': {
+ 'Meta': {'ordering': "['-date_added']", 'object_name': 'BlogPost'},
+ 'body': ('django.db.models.fields.TextField', [], {}),
+ 'category': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['blog.BlogCategory']", 'symmetrical': 'False'}),
+ 'date_added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'db_index': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['blog']
@@ -0,0 +1,44 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+from apps.blog.models import BlogPost
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding field 'BlogPost.date_published'
+ db.add_column('blog_blogpost', 'date_published', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True), keep_default=False)
+ for bpost in BlogPost.objects.all():
+ bpost.date_published = bpost.date_added
+ bpost.save()
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'BlogPost.date_published'
+ db.delete_column('blog_blogpost', 'date_published')
+
+
+ models = {
+ 'blog.blogcategory': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'BlogCategory'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'db_index': 'True'})
+ },
+ 'blog.blogpost': {
+ 'Meta': {'ordering': "['-date_added']", 'object_name': 'BlogPost'},
+ 'body': ('django.db.models.fields.TextField', [], {}),
+ 'category': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['blog.BlogCategory']", 'symmetrical': 'False'}),
+ 'date_added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'date_published': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'db_index': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['blog']
@@ -0,0 +1,41 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding field 'BlogPost.date_last_modified'
+ db.add_column('blog_blogpost', 'date_last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, default=datetime.datetime(2011, 3, 20, 18, 49, 45, 910972), blank=True), keep_default=False)
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'BlogPost.date_last_modified'
+ db.delete_column('blog_blogpost', 'date_last_modified')
+
+
+ models = {
+ 'blog.blogcategory': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'BlogCategory'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'db_index': 'True'})
+ },
+ 'blog.blogpost': {
+ 'Meta': {'ordering': "['-date_added']", 'object_name': 'BlogPost'},
+ 'body': ('django.db.models.fields.TextField', [], {}),
+ 'category': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['blog.BlogCategory']", 'symmetrical': 'False'}),
+ 'date_added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'date_last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'date_published': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'db_index': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['blog']
No changes.
Oops, something went wrong.

0 comments on commit 22540de

Please sign in to comment.