Beispiel #1
0
def yield_entry(topic, user):
    url = canonical_url('front.view_topic', tid=topic.id)
    yield u'<entry>'
    yield u'<id><![CDATA[%s]]></id>' % url
    yield u'<link href="%s" />' % escape(url)
    yield u'<title type="html"><![CDATA[%s]]></title>' % topic.title
    yield u'<updated>%s</updated>' % xmldatetime(topic.updated_at)
    yield u'<published>%s</published>' % xmldatetime(topic.created_at)

    yield u'<author>'
    if user:
        yield u'<name>%s</name>' % escape(user.username)
        url = canonical_url('front.view_user', username=user.username)
        yield u'<uri>%s</uri>' % url
    else:
        yield u'<name>Anonymous</name>'
    yield u'</author>'

    yield u'<content type="html"><![CDATA[%s]]></content>' % topic.html
    yield u'</entry>'
Beispiel #2
0
def yield_entry(topic, user):
    url = canonical_url('front.view_topic', tid=topic.id)
    yield u'<entry>'
    yield u'<id><![CDATA[%s]]></id>' % url
    yield u'<link href="%s" />' % escape(url)
    yield u'<title type="html"><![CDATA[%s]]></title>' % topic.title
    yield u'<updated>%s</updated>' % xmldatetime(topic.updated_at)
    yield u'<published>%s</published>' % xmldatetime(topic.created_at)

    yield u'<author>'
    if user:
        yield u'<name>%s</name>' % escape(user.username)
        url = canonical_url('front.view_user', username=user.username)
        yield u'<uri>%s</uri>' % url
    else:
        yield u'<name>Anonymous</name>'
    yield u'</author>'
    webpage = WebPage.cache.get(topic.webpage) or u''
    if webpage:
        webpage_dict = dict(webpage)

        def yield_webpage():
            if webpage_dict.get('image'):
                yield u'<figure>'
                yield u'<img src="%s">' % webpage_dict['image']
                yield u'<figcaption>'\
                      u'<a href="{link}">{title}</a>{link}'\
                      u'</figcaption>'.format(**webpage_dict)
                yield u'</figure>'
            else:
                yield u'<div><a href="{link}">{title}</a></div>'\
                      u'<div>{link}</div>'.format(**webpage_dict)

        webpage = u''.join(yield_webpage())
    yield u'<content type="html"><![CDATA[%s]]></content>' % (webpage +
                                                              topic.html)

    yield u'</entry>'
Beispiel #3
0
def yield_feed(title, web_url, self_url, topics):
    yield u'<?xml version="1.0" encoding="utf-8"?>\n'
    yield u'<feed xmlns="http://www.w3.org/2005/Atom">'
    yield u'<title><![CDATA[%s]]></title>' % title
    yield u'<link href="%s" />' % escape(web_url)
    yield u'<link href="%s" rel="self" />' % escape(self_url)
    yield u'<id><![CDATA[%s]]></id>' % web_url
    if topics:
        yield u'<updated>%s</updated>' % xmldatetime(topics[0].updated_at)
    users = User.cache.get_dict({o.user_id for o in topics})
    for topic in topics:
        for text in yield_entry(topic, users.get(str(topic.user_id))):
            yield text
    yield u'</feed>'
Beispiel #4
0
def yield_feed(title, web_url, self_url, topics):
    yield u'<?xml version="1.0" encoding="utf-8"?>\n'
    yield u'<feed xmlns="http://www.w3.org/2005/Atom">'
    yield u'<title><![CDATA[%s]]></title>' % title
    yield u'<link href="%s" />' % escape(web_url)
    yield u'<link href="%s" rel="self" />' % escape(self_url)
    yield u'<id><![CDATA[%s]]></id>' % web_url
    if topics:
        yield u'<updated>%s</updated>' % xmldatetime(topics[0].updated_at)
    users = User.cache.get_dict({o.user_id for o in topics})
    for topic in topics:
        for text in yield_entry(topic, users.get(str(topic.user_id))):
            yield text
    yield u'</feed>'
Beispiel #5
0
def yield_entry(topic, user):
    url = canonical_url('front.view_topic', tid=topic.id)
    yield u'<entry>'
    yield u'<id><![CDATA[%s]]></id>' % url
    yield u'<link href="%s" />' % escape(url)
    yield u'<title type="html"><![CDATA[%s]]></title>' % topic.title
    yield u'<updated>%s</updated>' % xmldatetime(topic.updated_at)
    yield u'<published>%s</published>' % xmldatetime(topic.created_at)

    yield u'<author>'
    if user:
        yield u'<name>%s</name>' % escape(user.username)
        url = canonical_url('front.view_user', username=user.username)
        yield u'<uri>%s</uri>' % url
    else:
        yield u'<name>Anonymous</name>'
    yield u'</author>'
    webpage = WebPage.cache.get(topic.webpage) or u''
    if webpage:
        webpage_dict = dict(webpage)

        def yield_webpage():
            if webpage_dict.get('image'):
                yield u'<figure>'
                yield u'<img src="%s">' % webpage_dict['image']
                yield u'<figcaption>'\
                      u'<a href="{link}">{title}</a>{link}'\
                      u'</figcaption>'.format(**webpage_dict)
                yield u'</figure>'
            else:
                yield u'<div><a href="{link}">{title}</a></div>'\
                      u'<div>{link}</div>'.format(**webpage_dict)
        webpage = u''.join(yield_webpage())
    yield u'<content type="html"><![CDATA[%s]]></content>' % (webpage + topic.html)

    yield u'</entry>'