Permalink
Browse files

EveryBlock code from tarballs.

  • Loading branch information...
0 parents commit 25397148223dad81e7fbb9c7cf2f169162df4681 @brosner committed Jul 1, 2009
Showing 576 changed files with 44,682 additions and 0 deletions.
@@ -0,0 +1,52 @@
+======
+ebblog
+======
+
+The blog application used by http://blog.everyblock.com
+
+Requirements
+============
+
+A recent Django release. It has been tested with Django revision 11079 from
+Subversion. When Django 1.1 is released, that should work as well.
+
+Quickstart
+==========
+
+0. Install Django.
+
+1. Install the ebblog package by putting it on your Python path.
+
+2. Start a Django project (using Django 1.1, not 1.0). See the Django Book and
+ Django docs for more:
+
+ http://djangobook.com/en/2.0/
+ http://docs.djangoproject.com/en/dev/
+
+3. Update your settings file. It's probably easiest to just start with the
+ file ebblog/settings.py and tweak that (or import from it in your own
+ settings file). The application won't work until you set the following:
+
+ DATABASE_USER
+ DATABASE_NAME
+ DATABASE_HOST
+ DATABASE_PORT
+
+ If you decide not to start with ebblog.settings, you'll also need to add
+ ebblob.urls to your URLconf and add the absolute path to ebblog/templates
+ to your TEMPLATE_DIRS setting.
+
+4. Run "django-admin.py syncdb" to create all of the database tables.
+
+5. Run "django-admin.py runserver" and go to http://127.0.0.1:8000/ in your
+ Web browser to see the site in action. Go to http://127.0.0.1:8000/admin/
+ to add and edit blog entries.
+
+Customization
+=============
+
+The title, description, and link of the RSS feed should be set in
+ebblog/blog/feeds.py. Also, most of the visual customization can be
+accomplished by editing ebblog/templates/base.html. All of the other templates
+inherit from base.html, so any styles added there will apply to the other
+pages.
No changes.
No changes.
@@ -0,0 +1,7 @@
+from django.contrib.admin import ModelAdmin, site
+from ebblog.blog.models import Entry
+
+class EntryAdmin(ModelAdmin):
+ list_display = ('pub_date', 'headline', 'author')
+
+site.register(Entry, EntryAdmin)
@@ -0,0 +1,29 @@
+from django.contrib.syndication.feeds import Feed
+from django.utils.feedgenerator import Rss201rev2Feed
+from ebblog.blog.models import Entry
+
+# RSS feeds powered by Django's syndication framework use MIME type
+# 'application/rss+xml'. That's unacceptable to us, because that MIME type
+# prompts users to download the feed in some browsers, which is confusing.
+# Here, we set the MIME type so that it doesn't do that prompt.
+class CorrectMimeTypeFeed(Rss201rev2Feed):
+ mime_type = 'application/xml'
+
+# This is a django.contrib.syndication.feeds.Feed subclass whose feed_type
+# is set to our preferred MIME type.
+class BlogFeed(Feed):
+ feed_type = CorrectMimeTypeFeed
+
+class BlogEntryFeed(Feed):
+ title = ""
+ link = ""
+ description = ""
+
+ def items(self):
+ return Entry.objects.order_by('-pub_date')[:10]
+
+ def item_link(self, item):
+ return item.url()
+
+ def item_pubdate(self, item):
+ return item.pub_date
@@ -0,0 +1,18 @@
+from django.db import models
+
+class Entry(models.Model):
+ pub_date = models.DateTimeField()
+ author = models.CharField(max_length=32, help_text='Use the full name, e.g., "John Lennon".')
+ slug = models.CharField(max_length=32)
+ headline = models.CharField(max_length=255)
+ summary = models.TextField(help_text='Use plain text (no HTML).')
+ body = models.TextField(help_text='Use raw HTML, including <p> tags.')
+
+ class Meta:
+ verbose_name_plural = 'entries'
+
+ def __unicode__(self):
+ return self.headline
+
+ def url(self):
+ return "/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(), self.slug)
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+from django.core.management import execute_manager
+import settings_devel
+
+if __name__ == "__main__":
+ execute_manager(settings_devel)
@@ -0,0 +1,21 @@
+import os
+
+DATABASE_ENGINE = 'sqlite3'
+DATABASE_NAME = '/tmp/ebblog.db'
+DATABASE_USER = ''
+DATABASE_HOST = ''
+DATABASE_PORT = ''
+
+ROOT_URLCONF = 'ebblog.urls'
+
+INSTALLED_APPS = (
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'ebblog.blog',
+)
+
+TEMPLATE_DIRS = (
+ os.path.normpath(os.path.join(os.path.dirname(__file__), 'templates')),
+)
@@ -0,0 +1,7 @@
+{% extends "base.html" %}
+
+{% block title %}Page not found{% endblock %}
+
+{% block content %}
+<h1>Page not found</h1>
+{% endblock %}
@@ -0,0 +1,7 @@
+{% extends "base.html" %}
+
+{% block title %}Page unavailable{% endblock %}
+
+{% block content %}
+<h1>Page unavailable</h1>
+{% endblock %}
@@ -0,0 +1,32 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>{% block fulltitle %}{% block title %}{% endblock %} / ebblog{% endblock %}</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link rel="home" title="Home" href="/">
+ <link rel="alternate" type="application/rss+xml" title="RSS" href="/rss/">
+ {% block extrahead %}{% endblock %}
+</head>
+<body class="{% block pageid %}generic{% endblock %}">
+ <div id="container">
+ <div id="siteheader">
+ <h2 id="sitetitle"><a href="/">ebblog</a></h2>
+ </div><!--/siteheader-->
+ <div id="main">
+ <div id="prenav" class="globalnav">
+ <ul class="navlist">
+ <li class="latest"><a href="/">Latest posts</a></li>
+ <li class="archives"><a href="/archives/">Blog archives</a></li>
+ <li class="feed"><a href="/rss/">RSS feed</a></li>
+ </ul>
+ </div><!--/prenav-->
+ <div id="content">
+ {% block content %}{% endblock %}
+ </div><!--/content-->
+ </div><!--/main-->
+ </div><!--/container-->
+
+</body>
+</html>
@@ -0,0 +1,18 @@
+{% extends "base.html" %}
+
+{% block title %}Archives{% endblock %}
+
+{% block content %}
+
+<h1>Archive</h1>
+
+{% regroup object_list by pub_date.year as entries_by_year %}
+{% for group in entries_by_year %}
+<h2 class="yeargrouper">{{ group.grouper }}</h2>
+<ul id="archiveslist" class="linklist">
+{% for entry in group.list %}
+ <li><strong class="date">{{ entry.pub_date|date:"M j" }}</strong> <a class="title" href="{{ entry.url }}">{{ entry.headline }}</a></li>
+{% endfor %}
+</ul>
+{% endfor %}
+{% endblock %}
@@ -0,0 +1,19 @@
+{% extends "base.html" %}
+
+{% block title %}Archives / {{ day|date:"F j" }}{% endblock %}
+
+{% block content %}
+
+<h1>{{ day|date:"F j" }}</h1>
+
+{% for object in object_list %}
+<div class="post">
+ <h2 class="title"><a class="url" href="{{ object.url }}">{{ object.headline }}</a></h2>
+ <p class="dateline">Posted <span class="date">{{ object.pub_date|date:"F j, Y" }}</span> by <strong class="author">{{ object.author }}</strong></p>
+ <div class="body">
+ {{ object.body|safe }}
+ </div>
+</div><!--/post-->
+{% endfor %}
+
+{% endblock %}
@@ -0,0 +1,19 @@
+{% extends "base.html" %}
+
+{% block title %}Archives / {{ month|date:"F Y" }}{% endblock %}
+
+{% block content %}
+
+<h1>{{ month|date:"F Y" }}</h1>
+
+{% for object in object_list %}
+<div class="post">
+ <h2 class="title"><a class="url" href="{{ object.url }}">{{ object.headline }}</a></h2>
+ <p class="dateline">Posted <span class="date">{{ object.pub_date|date:"F j, Y" }}</span> by <strong class="author">{{ object.author }}</strong></p>
+ <div class="body">
+ {{ object.body|safe }}
+ </div>
+</div><!--/post-->
+{% endfor %}
+
+{% endblock %}
@@ -0,0 +1,15 @@
+{% extends "base.html" %}
+
+{% block title %}Archives / {{ year }}{% endblock %}
+
+{% block content %}
+
+<h1>{{ year }}</h1>
+
+<ul class="linklist">
+{% for date in date_list %}
+ <li><a href="{{ date|date:"M"|lower }}/">{{ date|date:"F" }}</a></li>
+{% endfor %}
+</ul>
+
+{% endblock %}
@@ -0,0 +1,13 @@
+{% extends "base.html" %}
+
+{% block title %}{{ object.headline }}{% endblock %}
+
+{% block content %}
+<div class="post">
+ <h1 class="title">{{ object.headline }}</h1>
+ <p class="dateline">Posted <span class="date">{{ object.pub_date|date:"F j, Y" }}</span> by <strong class="author">{{ object.author }}</strong></p>
+ <div class="body">
+ {{ object.body|safe }}
+ </div>
+</div>
+{% endblock %}
@@ -0,0 +1 @@
+{{ obj.body|safe }}
@@ -0,0 +1 @@
+{{ obj.headline }}
@@ -0,0 +1,17 @@
+{% extends "base.html" %}
+
+{% block fulltitle %}ebblog{% endblock %}
+
+{% block pageid %}latest{% endblock %}
+
+{% block content %}
+{% for object in latest %}
+<div class="post">
+ <h2 class="title"><a class="url" href="{{ object.url }}">{{ object.headline }}</a></h2>
+ <p class="dateline">Posted <span class="date">{{ object.pub_date|date:"F j, Y" }}</span> by <strong class="author">{{ object.author }}</strong></p>
+ <div class="body">
+ {{ object.body|safe }}
+ </div>
+</div><!--/post-->
+{% endfor %}
+{% endblock %}
@@ -0,0 +1,28 @@
+from django.conf.urls.defaults import *
+from django.contrib.syndication.views import feed as feed_view
+from django.views.generic import date_based, list_detail
+from django.contrib import admin
+from ebblog.blog.models import Entry
+from ebblog.blog import feeds
+
+admin.autodiscover()
+
+info_dict = {
+ 'queryset': Entry.objects.order_by('pub_date'),
+ 'date_field': 'pub_date',
+}
+
+FEEDS = {
+ 'rss': feeds.BlogEntryFeed,
+}
+
+urlpatterns = patterns('',
+ (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>\w+)/$', date_based.object_detail, dict(info_dict, slug_field='slug')),
+ (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', date_based.archive_day, info_dict),
+ (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', date_based.archive_month, info_dict),
+ (r'^(?P<year>\d{4})/$', date_based.archive_year, info_dict),
+ (r'^(rss)/$', feed_view, {'feed_dict': FEEDS}),
+ (r'^archives/', list_detail.object_list, {'queryset': Entry.objects.order_by('-pub_date'), 'template_name': 'blog/archive.html'}),
+ (r'^$', date_based.archive_index, dict(info_dict, template_name='homepage.html')),
+ ('^admin/', include(admin.site.urls)),
+)
Oops, something went wrong.

0 comments on commit 2539714

Please sign in to comment.