Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added aggregator for Django feeds at /community

git-svn-id: http://code.djangoproject.com/svn/djangoproject.com@419 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 64515cc61b974de03134bbdb65696adb1b047ff9 1 parent 3c4da9a
jacob authored
View
0  django_website/apps/aggregator/__init__.py
No changes.
View
37 django_website/apps/aggregator/bin/update_feeds.py
@@ -0,0 +1,37 @@
+"""
+Update feeds for Django community page. Requires Mark Pilgrim's excellent
+Universal Feed Parser (http://feedparser.org)
+"""
+
+import os
+import time
+import optparse
+import datetime
+import feedparser
+
+def update_feeds():
+ from django.models.aggregator import feeds, feeditems
+ for feed in feeds.get_iterator(is_defunct__exact=False):
+ for entry in feedparser.parse(feed.feed_url).entries:
+ try:
+ feeditem = feed.get_feeditem(guid__exact=str(entry.id))
+ except feeditems.FeedItemDoesNotExist:
+ for i in ("summary", "content", "description"):
+ summary = entry.get(i, "")
+ if summary: break
+ feeditem = feed.add_feeditem(title=str(entry.title),
+ link=str(entry.link),
+ summary=str(summary),
+ guid=str(entry.id),
+ date_modified=datetime.datetime.fromtimestamp(time.mktime(entry.modified_parsed)))
+ else:
+ feeditem.date_modified = datetime.datetime.fromtimestamp(time.mktime(entry.modified_parsed))
+ feeditem.save()
+
+if __name__ == '__main__':
+ parser = optparse.OptionParser()
+ parser.add_option('--settings')
+ options, args = parser.parse_args()
+ if options.settings:
+ os.environ["DJANGO_SETTINGS_MODULE"] = options.settings
+ update_feeds()
View
1  django_website/apps/aggregator/models/__init__.py
@@ -0,0 +1 @@
+__all__ = ['aggregator']
View
27 django_website/apps/aggregator/models/aggregator.py
@@ -0,0 +1,27 @@
+from django.core import meta
+
+class Feed(meta.Model):
+ fields = (
+ meta.CharField('title', maxlength=200),
+ meta.URLField('feed_url', 'feed url', verify_exists=True, unique=True),
+ meta.URLField('public_url', 'public url', verify_exists=True),
+ meta.BooleanField("is_defunct", "is defunct"),
+ )
+ admin = meta.Admin()
+
+ def __repr__(self):
+ return self.title
+
+class FeedItem(meta.Model):
+ fields = (
+ meta.ForeignKey(Feed),
+ meta.CharField('title', maxlength=200),
+ meta.URLField('link'),
+ meta.TextField('summary', blank=True),
+ meta.DateTimeField('date_modified', 'date modified'),
+ meta.CharField('guid', maxlength=200, unique=True, db_index=True),
+ )
+ ordering = ("-date_modified",)
+
+ def __repr__(self):
+ return self.title
View
4 django_website/apps/aggregator/views.py
@@ -0,0 +1,4 @@
+from django.utils.httpwrappers import HttpResponse
+
+def aggregator(request):
+ return HttpResponse("Hello, world. You're at the poll index.")
View
1  django_website/settings/main.py
@@ -23,6 +23,7 @@
'django.contrib.comments',
'django_website.apps.blog',
'django_website.apps.docs',
+ 'django_website.apps.aggregator',
)
MEDIA_ROOT = "/home/html/djangoproject.com/m/"
MEDIA_URL = "http://www.djangoproject.com.com/m/"
View
12 django_website/settings/urls/main.py
@@ -1,16 +1,24 @@
from django.conf.urls.defaults import *
-info_dict = {
+comments_info_dict = {
'app_label': 'comments',
'module_name': 'freecomments',
'paginate_by': 15,
}
+aggregator_info_dict = {
+ 'app_label' : 'aggregator',
+ 'module_name' : 'feeditems',
+ 'paginate_by' : 15,
+ 'extra_lookup_kwargs': {'select_related' : True},
+}
+
urlpatterns = patterns('',
(r'^weblog/', include('django_website.apps.blog.urls.blog')),
(r'^documentation/', include('django_website.apps.docs.urls.docs')),
- (r'^comments/$', 'django.views.generic.list_detail.object_list', info_dict),
+ (r'^comments/$', 'django.views.generic.list_detail.object_list', comments_info_dict),
(r'^comments/', include('django.contrib.comments.urls.comments')),
+ (r'^community/$', 'django.views.generic.list_detail.object_list', aggregator_info_dict),
(r'^rss/', include('django.conf.urls.rss')),
(r'', include('django.conf.urls.flatfiles')),
)
View
25 django_website/templates/aggregator/feeditems_list.html
@@ -0,0 +1,25 @@
+{% extends "base_community" %}
+
+{% block content %}
+
+<h1>Community</h1>
+<h2 class="deck">Django hasn't even been officially released yet, and there's
+already a great, helpful, excited community of Web developers who've been
+hacking away at it. This page aggregates their feeds.</h2>
+
+{% for item in object_list %}
+<h2><a href="{{ item.link }}">{{ item.title }}</a></h2>
+<p class='date'>Posted {{ item.date_modified|timesince }} ago by <a href="{{ item.get_feed.public_url }}">{{ item.get_feed.title }}</a> (<a href="{{ item.get_feed.feed_url }}">RSS</a>)</p>
+<div>
+{{ item.summary }}
+</div>
+<p class="small"><a href="{{ item.link }}">Read this post in context &raquo;</a></p>
+{% endfor %}
+
+<div id="content-secondary">
+<p>{% if has_previous %}<a href="?page={{ previous }}">Previous</a> | {% endif %}
+Page {{ page }} of {{ pages }}
+{% if has_next %} | <a href="?page={{ next }}">Next</a>{% endif %}</p>
+</div>
+
+{% endblock %}
View
27 django_website/templates/base_community.html
@@ -1,7 +1,30 @@
-{% extends "base" %}
+{% extends "base_2col" %}
{% block sectionid %}community{% endblock %}
{% block title %}Community{% endblock %}
-{% block billboard %}<h2>Community</h2>{% endblock %}
+{% block billboard %}<h2>Community</h2>{% endblock %}
+
+{% block content-related %}
+
+<h2>Get involed</h2>
+
+<ul>
+<li>Do you write about Django? <a href="mailto:jacob@jacobian.org">Let us know</a> and we'll add your feed to this page.</li>
+<li>If you'd like to contribute to Django, join the <a href="http://groups-beta.google.com/group/django-developers">django-developers mailing list</a></li>
+<li><a href="http://code.djangoproject.com/newticket">Report bugs and make feature requests</a> in our ticket system.</li>
+<li>Contribute documentation to <a href="http://code.djangoproject.com/wiki">the wiki</a></li>
+<li>If you find bugs or documentation that isn't explained well enough, please post a comment to the appropriate page, and we'll fix things.</li>
+</ul>
+
+<h2>Get help</h2>
+
+<ul>
+<li><a href="/documentation/faq/">Check our FAQ</a> first. If you have a basic question that's not answered by the FAQ, <a href="http://code.djangoproject.com/newticket">file a ticket</a> to tell us you think it should be in there.</li>
+<li><a href="irc://irc.freenode.net/django">#django IRC channel on irc.freenode.net</a></li>
+<li>Read the <a href="http://loglibrary.com/show_page/latest/179">IRC channel logs</a></li>
+<li>Ask questions on the<a href="http://groups-beta.google.com/group/django-users">django-users mailing list</a></li>
+</ul>
+
+{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.