Пример #1
0
def edit():

    article_id = request.args.get("id", None)
    if article_id is None:
        return redirect(url_for("manage"))

    article = Article.get_article_by_id(article_id)
    if not article:
        return redirect(url_for("manage"))

    article_id = article.id
    title = article.title
    summary = article.summary
    content = article.content
    default_label_id = article.labelid

    labels = Label.get_labels()
    username = session.get("username", "")
    return render_template(
        "backend/post_article.html",
        id=article_id,
        title=title,
        summary=summary,
        content=content,
        default_label_id=default_label_id,
        labels=labels,
        username=username,
    )
Пример #2
0
def article():
    id = request.args.get("id", 1)
    try:
        article_id = int(id)
    except:
        return abort(404)

    article = Article.get_article_by_id(id)

    # The id not exist, url error
    if not article:
        abort(404)

    md = markdown.Markdown(extensions=['codehilite'])
    article.content = Markup(md.convert(article.content))

    labels, has_login = _prepare_base_data()
    return render_template('/frontend/article.html',
                            labels=labels,
                            article=article,
                            has_login=has_login
                        )