from django.contrib.syndication.feeds import Feed
from newape.articles.models import Article
from newape.lifestream.models import LifestreamEntry
from newape import settings

class ArticlesFeed(Feed):
    title = "Neoglam.com articles"
    link = settings.FEED_HOST + "/articles/"
    description = "Articles on a variety of topics published at Neoglam.com."

    def items(self):
        return Article.objects.order_by('-published_on')[:5]

    def item_link(self, item):
        return ''.join(
            [settings.FEED_HOST, 'articles/', str(item.id), '/', item.slug])

class LifestreamFeed(Feed):
    title = "the daniel's lifestream"
    link = settings.FEED_HOST + "/lifestream/"
    description = "the daniel's lifestream."

    def items(self):
        return LifestreamEntry.objects.order_by('-created_on')[:30]

    def item_link(self, item):
        return settings.FEED_HOST + '/lifestream/'

