Пример #1
0
def _feed_rss(url):
    feed = AtomFeed(title=site.sitename(), subtitle='Recent Articles',
                    feed_url=url + 'feed/rss', url=url, updated=datetime.now())

    for post in ServiceMixin.post_service.get_published_posts():
        feed.add(post.title, markdown(post.html),
                 content_type='html',
                 author=post.user.username,
                 url=url + 'post/' + post.slug,
                 updated=post.updated,
                 published=post.created)
    return ''.join(feed.generate())
Пример #2
0
 def value(self):
     field = self.field
     if field == 'text':
         value = self.meta.get('text', '')
     elif field == 'html':
         value = markdown(self.meta.get('html', ''))
     elif field in ('image', 'file'):
         f = self.meta.get('filename', '')
         if f:
             value = '/content/' + f
         else:
             value = ''
     return Markup(value)
Пример #3
0
def _feed_json(url):
    posts = []
    for post in ServiceMixin.post_service.get_published_posts():
        data = dict(author=post.user.username,
                    html=markdown(post.html),
                    url=urljoin( url , '/post/' + post.slug),
                    updated=post.updated,
                    published=post.created
                    )
        posts.append(data)

    rss = {
        'sitename': site.sitename(),
        'site': url,
        'updated': datetime.now(),
        'description': site.description(),
        'posts': posts
    }
    return rss