Git Product home page Git Product logo

django-aggregator's Introduction

Django-aggregator

A planet app for your Django project. It crawls a set of feeds, aggregates them on a single page and re-publishes the entries with RSS and Atom feeds.

This app is based on Django's community aggregator, updated to Django 1.2 and slightly improved.

Installation

pip install -e git+git://github.com/brutasse/django-aggregator#egg=aggregator

Requirements:

  • Django >= 1.2
  • The universal feedparser

Configuration

Add aggregator to your INSTALLED_APPS & run syncdb.

Templates

Create a simple view that renders a template. Use the following template tags to fetch & render the data:

  • {% load aggregator_tags %} to load the template library
  • {% get_feed_list as feed_list %} to fetch the feeds
  • {% get_entries <num_latest> as entries_list %} to fetch the latest entries

And then, to display the list of indexed feeds:

<h2>Indexed feeds</h2>
<ul>
    {% for feed in feed_list %}
        <li>{{ feed.title }} (<a href="{{ feed.public_url }}">site</a>)</li>
    {% endfor %}
</ul>

To render the latest entries:

<h2>Latest entries</h2>
{% for entry in entries_list %}
    <div class="entry">
        <h2>{{ entry.feed.title }}: {{ entry.title|safe }}</h2>
        <p>{{ entry.summary|safe }}</p>
        <p>
            Published: {{ entry.date|date }}.
            <a href="{{ entry.link }}">Read more</a>
        </p>
    </div>
{% endfor %}

If you want to render only a preview of the entries, you can do:

{{ entry.summary|safe|truncatewords_html:30 }}

Feeds

To publish some feeds of the aggregated content, subclass the base Feed class:

from aggregator.feeds import Feed

class MyAwesomeFeed(Feed):
    title = 'Aggregated content on <topic>'
    link = 'http://example.com'
    description = 'A more detailed description'

You can have Atom feeds:

from django.utils.feedgenerator import Atom1Feed

class MyAwesomeAtomFeed(MyAwesomeFeed):
    feed_type = Atom1Feed
    subtitle = MyAwesomeFeed.description

And add them to your URLs:

from myproject.feeds import MyAwesomeFeed, MyAwesomeAtomFeed

urlpatterns = patterns('',
    # ...
    url(r'^path/to/feeds/rss/$', MyAwesomeFeed(), name='aggregator_rss'),
    url(r'^path/to/feeds/atom/$', MyAwesomeAtomFeed(), name='aggregator_atom'),
    # ...
)

When you're done you can add your feeds' URLs in the <head> section of your website.

Usage

Adding some feeds

Go to the admin and add the different feeds' name, title & URLs.

Updating the feeds

There are two management commands:

  • mark_defunct_feeds will fetch all the registered feeds and check if they return a 404 or 500 response. If so, they are marked as "defunct" and will be skipped at each update.
  • update_feeds fetches all the non-defunct feeds and checks for new content.

Here is how you could configure cron to schedule these two tasks:

PYTHONPATH=/path/to/project
DJANGO_SETTINGS_MODULE=settings_module

15,45 * * * * python /path/to/manage.py update_feeds
0 */6 * * *   python /path/to/manage.py mark_defunct_feeds

django-aggregator's People

Contributors

brutasse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-aggregator's Issues

syncdb: errors on models

Hi,

I'm quite a newbie here so maybe this is completly irrelevant. I tried to install your app but when syncb, here is what I get:

Error: One or more models did not validate:
aggregator.feed: "feed_url": URLField cannot have a "max_length" greater than 255 when using "unique=True".
aggregator.entry: "guid": CharField cannot have a "max_length" greater than 255 when using "unique=True".

Should I just edit the models or my settings are wrong somehow?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.