Example #1
0
def blog_feed():
    posts = Gallery.get_list(published=True, to_json=True)

    feed_url = "{}/blog/feed.atom".format(g.app_base_link)
    feed = AtomFeed('KateHeddleston.com Blog Posts',
                    feed_url=feed_url,
                    url='{}/blog'.format(g.app_base_link))

    for post in posts:
        post_html = []
        for item in post.get('items'):
            item_text = ""
            if item.get('title'):
                item_text += u'<h2>{}</h2><br>'.format(item.get('title'))
            if item.get('image_name'):
                img_src = u'{}/{}'.format(post.get('base_url'), item.get('image_name'))
                item_text += u"<img src='{}' />".format(img_src)
            if item.get('image_caption'):
                item_text += u"<div>{}</div>".format(item.get('image_caption'))
            item_text += '<br>'
            item_text += item.get('body')
            post_html.append(item_text)
        text = '</p><p>'.join(post_html)
        text = '<p>' + text + '</p>'

        post_url = "{}/blog/{}".format(g.app_base_link, post.get('uuid'))
        published_at = datetime.datetime.strptime(post['published_at_raw'], '%Y-%m-%dT%H:%M:%S')
        feed.add(post.get('name'),
                 text,
                 content_type='html',
                 author=post.get('author'),
                 url=post_url,
                 updated=published_at,
                 published=published_at)
    return feed.get_response()
Example #2
0
def blog_feed():
    posts = Gallery.get_list(published=True, to_json=True)

    feed_url = "{}/blog/feed.atom".format(g.app_base_link)
    feed = AtomFeed('KateHeddleston.com Blog Posts',
                    feed_url=feed_url,
                    url='{}/blog'.format(g.app_base_link))

    for post in posts:
        post_html = []
        for item in post.get('items'):
            item_text = ""
            if item.get('title'):
                item_text += u'<h2>{}</h2><br>'.format(item.get('title'))
            if item.get('image_name'):
                img_src = u'{}/{}'.format(post.get('base_url'), item.get('image_name'))
                item_text += u"<img src='{}' />".format(img_src)
            if item.get('image_caption'):
                item_text += u"<div>{}</div>".format(item.get('image_caption'))
            item_text += '<br>'
            item_text += item.get('body')
            post_html.append(item_text)
        text = '</p><p>'.join(post_html)
        text = '<p>' + text + '</p>'

        post_url = "{}/blog/{}".format(g.app_base_link, post.get('uuid'))
        published_at = datetime.datetime.strptime(post['published_at_raw'], '%Y-%m-%dT%H:%M:%S')
        feed.add(post.get('name'),
                 unicode(text),
                 content_type='html',
                 author=post.get('author'),
                 url=post_url,
                 updated=published_at,
                 published=published_at)
    return feed.get_response()
def get_comments_for_galleries():
    galleries = Gallery.get_list(published=True)
    tweets = []
    for gallery in galleries:
        gallery_uuid = gallery.uuid
        url = 'https://www.kateheddleston.com/blog/{}'.format(gallery_uuid)
        update_facebook_comments(url, gallery_uuid)
        tweets = tweets + update_tweet_comments(url, gallery_uuid)
    return tweets
Example #4
0
def get_comments_for_galleries():
    galleries = Gallery.get_list(published=True)
    tweets = []
    for gallery in galleries:
        gallery_uuid = gallery.uuid
        url = 'https://www.kateheddleston.com/blog/{}'.format(gallery_uuid)
        update_facebook_comments(url, gallery_uuid)
        tweets = tweets + update_tweet_comments(url, gallery_uuid)
    return tweets
Example #5
0
def blog():
    g.nav_view = 'blog'
    posts = Gallery.get_list(published=True, to_json=True, sort_by='published_at')
    return render_template('blog.html', posts=posts)
Example #6
0
def api_get_galleries():
    galleries = Gallery.get_list(published=False,
                                 to_json=True,
                                 sort_by='published_at')
    return json.dumps(galleries), 200, {'Content-Type': 'application/json'}
Example #7
0
def api_get_galleries():
    galleries = Gallery.get_list(published=False, to_json=True, sort_by='published_at')
    return json.dumps(galleries), 200, {'Content-Type': 'application/json'}
Example #8
0
def blog():
    g.nav_view = 'blog'
    posts = Gallery.get_list(published=True, to_json=True, sort_by='published_at')
    return render_template('blog.html', posts=posts)