Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improved djangoproject community aggregator

git-svn-id: http://code.djangoproject.com/svn/djangoproject.com@422 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 98cc9069a7e5bc754d74e8cdc78e5fa00d181a98 1 parent d333f3f
jacob authored
View
33 django_website/apps/aggregator/bin/update_feeds.py
@@ -12,20 +12,31 @@
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:
+ parsed_feed = feedparser.parse(feed.feed_url)
+ for entry in parsed_feed.entries:
+ title = entry.title.encode(parsed_feed.encoding, "xmlcharrefreplace")
+ guid = entry.get("id", entry.link).encode(parsed_feed.encoding, "xmlcharrefreplace")
+ link = entry.link.encode(parsed_feed.encoding, "xmlcharrefreplace")
+ if hasattr(entry, "summary"):
+ content = entry.summary
+ elif hasattr(entry, "content"):
+ content = entry.content[0].value
+ elif hasattr(entry, "description"):
+ content = entry.description
+ else:
+ content = u""
+ content = content.encode(parsed_feed.encoding, "xmlcharrefreplace")
+ date_modified = datetime.datetime.fromtimestamp(time.mktime(entry.modified_parsed))
try:
- feeditem = feed.get_feeditem(guid__exact=str(entry.get("id", entry.link)))
+ feeditem = feed.get_feeditem(guid__exact=guid)
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.get("id", entry.link)),
- date_modified=datetime.datetime.fromtimestamp(time.mktime(entry.modified_parsed)))
+ feeditem = feed.add_feeditem(title=title,
+ link=link,
+ summary=content,
+ guid=guid,
+ date_modified=date_modified)
else:
- feeditem.date_modified = datetime.datetime.fromtimestamp(time.mktime(entry.modified_parsed))
+ feeditem.date_modified = date_modified
feeditem.save()
if __name__ == '__main__':
View
4 django_website/templates/aggregator/feeditems_list.html
@@ -17,9 +17,7 @@ <h2 class="deck">Django hasn't even been officially released yet, and there's
{% 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>
+{% if has_next %}<a href="?page={{ next }}">Earlier posts</a>{% endif %}</p>
</div>
{% endblock %}
View
2  django_website/templates/base_community.html
@@ -24,7 +24,7 @@
<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>
+<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.