Esempio n. 1
0
File: kb.py Progetto: Plurk/Solace
def post_revisions(request, id):
    """Shows all post revisions and a diff of the text."""
    post = Post.query.get(id)
    if post is None or post.topic.locale != request.view_lang:
        raise NotFound()
    if post.is_deleted and not (request.user and request.user.is_moderator):
        raise Forbidden()

    revisions = [{
        'id':       None,
        'latest':   True,
        'date':     post.updated,
        'editor':   post.editor or post.author,
        'text':     post.text
    }] + [{
        'id':       revision.id,
        'latest':   False,
        'date':     revision.date,
        'editor':   revision.editor,
        'text':     revision.text
    } for revision in post.revisions.order_by(PostRevision.date.desc())]

    last_text = None
    for revision in reversed(revisions):
        if last_text is not None:
            revision['diff'] = format_creole_diff(last_text, revision['text'])
        else:
            revision['diff'] = format_creole(revision['text'])
        last_text = revision['text']

    return render_template('kb/post_revisions.html', post=post,
                           revisions=revisions)
Esempio n. 2
0
def post_revisions(request, id):
    """Shows all post revisions and a diff of the text."""
    post = Post.query.get(id)
    if post is None or post.topic.locale != request.view_lang:
        raise NotFound()
    if post.is_deleted and not (request.user and request.user.is_moderator):
        raise Forbidden()

    revisions = [{
        'id': None,
        'latest': True,
        'date': post.updated,
        'editor': post.editor or post.author,
        'text': post.text
    }] + [{
        'id': revision.id,
        'latest': False,
        'date': revision.date,
        'editor': revision.editor,
        'text': revision.text
    } for revision in post.revisions.order_by(PostRevision.date.desc())]

    last_text = None
    for revision in reversed(revisions):
        if last_text is not None:
            revision['diff'] = format_creole_diff(last_text, revision['text'])
        else:
            revision['diff'] = format_creole(revision['text'])
        last_text = revision['text']

    return render_template('kb/post_revisions.html',
                           post=post,
                           revisions=revisions)
Esempio n. 3
0
File: api.py Progetto: tzoght/solace
def list_api_methods():
    """List all API methods."""
    result = []
    for rule in url_map.iter_rules():
        if rule.build_only:
            continue
        view = get_view(rule.endpoint)
        if not getattr(view, 'is_api_method', False):
            continue
        handler = view.__name__
        if handler.startswith('api.'):
            handler = handler[4:]
        result.append(
            dict(handler=handler,
                 valid_methods=view.valid_methods,
                 doc=format_creole((inspect.getdoc(view)
                                    or '').decode('utf-8')),
                 url=unicode(rule)))
    result.sort(key=lambda x: (x['url'], x['handler']))
    return result
Esempio n. 4
0
def list_api_methods():
    """List all API methods."""
    result = []
    for rule in url_map.iter_rules():
        if rule.build_only:
            continue
        view = get_view(rule.endpoint)
        if not getattr(view, 'is_api_method', False):
            continue
        handler = view.__name__
        if handler.startswith('api.'):
            handler = handler[4:]
        result.append(dict(
            handler=handler,
            valid_methods=view.valid_methods,
            doc=format_creole((inspect.getdoc(view) or '').decode('utf-8')),
            url=unicode(rule)
        ))
    result.sort(key=lambda x: (x['url'], x['handler']))
    return result
Esempio n. 5
0
 def rendered_text(self):
     """The rendered text."""
     return format_creole(self.text)
Esempio n. 6
0
 def _set_text(self, value):
     self._text = value
     self.rendered_text = format_creole(value, inline=self.render_text_inline)
Esempio n. 7
0
 def _set_text(self, value):
     self._text = value
     self.rendered_text = format_creole(value,
                                        inline=self.render_text_inline)
Esempio n. 8
0
 def rendered_text(self):
     """The rendered text."""
     return format_creole(self.text)