예제 #1
0
def render_markdown(mapper: Type[sa.orm.Mapper],
                    connection: sa.engine.Connection,
                    target: sa.orm.Mapper) -> None:
    if not target.slug:
        target.slug = slugify(target.title)
    if not target.date:
        target.date = datetime.utcnow()
    target.html = markdown(target.content)
    target.toc = markdown.renderer.render_toc()
    target.url = "/{}/{}".format(target.date.strftime("%Y/%m-%d"), target.slug)
예제 #2
0
def init_url(mapper, connection: sa.engine.Connection,
             target: sa.orm.Mapper) -> None:
    if target.slug:
        return
    target.slug = slugify(target.title)