コード例 #1
0
ファイル: post.py プロジェクト: hit9/zhiz
def preview():
    title = request.form["title"]
    title_pic = request.form["title_pic"]
    body = request.form["body"]

    if not title:
        flashx.warning("Title is empty!")

    post = dict(
        title=title, title_pic=title_pic, html=markdown.render(body), datetime=datetime.now(), id=None  # !preview
    )

    return render_public("post.html", post=post)
コード例 #2
0
ファイル: post.py プロジェクト: hit9/zhiz
def post(id):
    post = Post.at(id).getone()

    if post is None:
        abort(404)

    setattr(post, "html", markdown.render(post.body))

    query = Post.where(
        Post.id._in(Post.where(Post.id > id).select(fn.min(Post.id)), Post.where(Post.id < id).select(fn.max(Post.id)))
    ).select(Post.id, Post.title)

    setattr(post, "next", None)
    setattr(post, "prev", None)

    for pst in query:  # execute query
        if pst.id > id:
            post.next = pst
        elif pst.id < id:
            post.prev = pst

    return render_public("post.html", post=post)
コード例 #3
0
ファイル: models.py プロジェクト: hit9/zhiz
 def summary(self):
     return markdown.render(self.body[:150])