Django

Code

Changeset 422

Show
Ignore:
Timestamp:
08/06/05 18:54:06 (3 years ago)
Author:
jacob
Message:

Improved djangoproject community aggregator

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • djangoproject.com/django_website/apps/aggregator/bin/update_feeds.py

    r421 r422  
    1313    from django.models.aggregator import feeds, feeditems 
    1414    for feed in feeds.get_iterator(is_defunct__exact=False): 
    15         for entry in feedparser.parse(feed.feed_url).entries: 
     15        parsed_feed = feedparser.parse(feed.feed_url) 
     16        for entry in parsed_feed.entries: 
     17            title = entry.title.encode(parsed_feed.encoding, "xmlcharrefreplace") 
     18            guid = entry.get("id", entry.link).encode(parsed_feed.encoding, "xmlcharrefreplace") 
     19            link = entry.link.encode(parsed_feed.encoding, "xmlcharrefreplace") 
     20            if hasattr(entry, "summary"): 
     21                content = entry.summary 
     22            elif hasattr(entry, "content"): 
     23                content = entry.content[0].value 
     24            elif hasattr(entry, "description"): 
     25                content = entry.description 
     26            else: 
     27                content = u"" 
     28            content = content.encode(parsed_feed.encoding, "xmlcharrefreplace") 
     29            date_modified = datetime.datetime.fromtimestamp(time.mktime(entry.modified_parsed)) 
    1630            try: 
    17                 feeditem = feed.get_feeditem(guid__exact=str(entry.get("id", entry.link))
     31                feeditem = feed.get_feeditem(guid__exact=guid
    1832            except feeditems.FeedItemDoesNotExist: 
    19                 for i in ("summary", "content", "description"): 
    20                     summary = entry.get(i, "") 
    21                     if summary: break 
    22                 feeditem = feed.add_feeditem(title=str(entry.title), 
    23                                              link=str(entry.link), 
    24                                              summary=str(summary), 
    25                                              guid=str(entry.get("id", entry.link)), 
    26                                              date_modified=datetime.datetime.fromtimestamp(time.mktime(entry.modified_parsed))) 
     33                feeditem = feed.add_feeditem(title=title, 
     34                                             link=link, 
     35                                             summary=content, 
     36                                             guid=guid, 
     37                                             date_modified=date_modified) 
    2738            else: 
    28                 feeditem.date_modified = datetime.datetime.fromtimestamp(time.mktime(entry.modified_parsed)) 
     39                feeditem.date_modified = date_modified 
    2940                feeditem.save() 
    3041 
  • djangoproject.com/django_website/templates/aggregator/feeditems_list.html

    r419 r422  
    1818 
    1919<div id="content-secondary"> 
    20 <p>{% if has_previous %}<a href="?page={{ previous }}">Previous</a> | {% endif %} 
    21 Page {{ page }} of {{ pages }} 
    22 {% if has_next %} | <a href="?page={{ next }}">Next</a>{% endif %}</p> 
     20{% if has_next %}<a href="?page={{ next }}">Earlier posts</a>{% endif %}</p> 
    2321</div> 
    2422 
  • djangoproject.com/django_website/templates/base_community.html

    r419 r422  
    2525<li><a href="irc://irc.freenode.net/django">#django IRC channel on irc.freenode.net</a></li> 
    2626<li>Read the <a href="http://loglibrary.com/show_page/latest/179">IRC channel logs</a></li> 
    27 <li>Ask questions on the<a href="http://groups-beta.google.com/group/django-users">django-users mailing list</a></li> 
     27<li>Ask questions on the <a href="http://groups-beta.google.com/group/django-users">django-users mailing list</a></li> 
    2828</ul> 
    2929