示例#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)))
示例#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))
    )
示例#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()]
示例#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()]
示例#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')
    )
示例#6
0
def blogger_get_users_blogs(appkey, 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)}]
示例#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'))
示例#8
0
def blogger_get_users_blogs(appkey, 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)
    }]
示例#9
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
示例#10
0
 def __call__(self, req, navigation_bar):
     if req.user.has_privilege(self.perm):
         for link_id, url, title, children in navigation_bar:
             if link_id == self.category:
                 link = url_for(self.endpoint)
                 children.append((self.link_id, link, self.text))
示例#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