Example #1
0
def dump_category(category):
    return dict(
        categoryId=category.id,
        description=category.name,
        categoryDescription=category.description,
        categoryName=category.name,
        # don't ask me... WordPress is doing that...
        htmlUrl=escape(url_for(category)),
        rssUrl=escape(url_for('blog/atom_feed', category=category.slug)))
Example #2
0
def dump_category(category):
    return dict(
        categoryId=category.id,
        description=category.name,
        categoryDescription=category.description,
        categoryName=category.name,
        # don't ask me... WordPress is doing that...
        htmlUrl=escape(url_for(category)),
        rssUrl=escape(url_for('blog/atom_feed', category=category.slug))
    )
Example #3
0
def wp_get_tags(blog_id, username, password):
    request = login(username, password)
    return [{
        'tag_id':       tag['id'],
        'name':         tag['name'],
        'count':        tag['count'],
        'slug':         tag['slug'],
        'html_url':     escape(url_for('blog/show_tag', slug=tag['slug'])),
        'rss_url':      escape(url_for('blog/atom_feed', tag=tag['slug']))
    } for tag in Tag.query.get_cloud()]
Example #4
0
def wp_get_tags(blog_id, username, password):
    request = login(username, password)
    return [{
        'tag_id': tag['id'],
        'name': tag['name'],
        'count': tag['count'],
        'slug': tag['slug'],
        'html_url': escape(url_for('blog/show_tag', slug=tag['slug'])),
        'rss_url': escape(url_for('blog/atom_feed', tag=tag['slug']))
    } for tag in Tag.query.get_cloud()]
Example #5
0
def dump_post(post):
    """Dumps a post into a structure for the MetaWeblog API."""
    link = url_for(post, _external=True)
    tags = ','.join([x.name for x in post.tags])

    return dict(
        pubDate=post.pub_date,
        dateCreated=post.pub_date,
        userid=post.author.id,
        page_id=post.id,
        title=post.title,
        link=link,
        permaLink=link,
        description=post.text,
        zeml_parser=post.parser,
        author=post.author.email,
        categories=[x.name for x in post.categories],
        postid=post.id,
        page_status=post.status == STATUS_PUBLISHED and "published" or "draft",
        mt_keywords=tags,
        mt_tags=tags,
        mt_allow_comments=post.comments_enabled,
        mt_allow_pings=post.pings_enabled,
        wp_slug=post.slug,
        wp_password="",
        wp_author=post.author.display_name,
        wp_author_id=post.author.id,
        wp_author_display_name=post.author.display_name,
        date_created_gmt=post.pub_date,
        wp_page_template=post.extra.get('page_template')
    )
Example #6
0
def blogger_get_users_blogs(username, password):
    request = login(username, password)
    return [{'isAdmin': request.user.has_privilege(BLOG_ADMIN),
             'url': request.app.cfg['blog_url'],
             'blogid': 1,
             'blogName': request.app.cfg['blog_title'],
             'xmlrpc': url_for("services/WordPress", _external=True)}]
Example #7
0
def dump_post(post):
    """Dumps a post into a structure for the MetaWeblog API."""
    link = url_for(post, _external=True)
    tags = ','.join([x.name for x in post.tags])

    return dict(pubDate=post.pub_date,
                dateCreated=post.pub_date,
                userid=post.author.id,
                page_id=post.id,
                title=post.title,
                link=link,
                permaLink=link,
                description=post.text,
                zeml_parser=post.parser,
                author=post.author.email,
                categories=[x.name for x in post.categories],
                postid=post.id,
                page_status=post.status == STATUS_PUBLISHED and "published"
                or "draft",
                mt_keywords=tags,
                mt_tags=tags,
                mt_allow_comments=post.comments_enabled,
                mt_allow_pings=post.pings_enabled,
                wp_slug=post.slug,
                wp_password="",
                wp_author=post.author.display_name,
                wp_author_id=post.author.id,
                wp_author_display_name=post.author.display_name,
                date_created_gmt=post.pub_date,
                wp_page_template=post.extra.get('page_template'))
Example #8
0
def add_config_link(req, navigation_bar):
    """Add a link to the reStructuredText options page"""
    if req.user.has_privilege(BLOG_ADMIN):
        for link_id, url, title, children in navigation_bar:
            if link_id == 'options':
                children.insert(2, ('restructuredtext',
                                    url_for('restructuredtext_parser/config'),
                                    _('reStructuredText')))
Example #9
0
def blogger_get_users_blogs(username, password):
    request = login(username, password)
    return [{
        'isAdmin': request.user.has_privilege(BLOG_ADMIN),
        'url': request.app.cfg['blog_url'],
        'blogid': 1,
        'blogName': request.app.cfg['blog_title'],
        'xmlrpc': url_for("services/WordPress", _external=True)
    }]
Example #10
0
 def avatar(self, comment, size=80):
     if comment.user is None:
         email = comment._email
         www = comment._www
     else:
         email = comment.user.email
         www = comment.user.www
     if email:
         #: Return Gravatar URL
         return u"http://www.gravatar.com/avatar.php?" + urlencode(
             {
                 'gravatar_id': md5(email).hexdigest(),
                 'size': size,
                 'default': 'identicon'
             })
     elif www and www.find('livejournal.com') != -1:
         #: Return LiveJournal userpic
         return u"http://ljpic.seacrow.com/geturl?" + urlencode(
             {'url': www})
     return url_for('zaiki_theme/shared', filename='img/user.gif')
Example #11
0
 def oncall(*args, **kwargs):
     rv = f(*args, **kwargs)
     if rv.status_code == 200:
         rv.headers['X-Pingback'] = url_for('services/pingback',
                                            _external=True)
     return rv
Example #12
0
 def oncall(*args, **kwargs):
     rv = f(*args, **kwargs)
     if rv.status_code == 200:
         rv.headers['X-Pingback'] = url_for('services/pingback',
                                            _external=True)
     return rv