Exemplo n.º 1
0
def edit_text_ajax(slugid, year=None, month=None, day=None, slug=None):
    meta = Meta()
    try:
        text_post = TextPost.objects(slugid=slugid).get()
    except:
        return abort(404)
    if (slug == None or year == None or month == None or day == None):
        return redirect(url_for('edit_text_ajax', slugid=slugid,\
            slug=text_post.slug, year=text_post.created.year,\
            month=text_post.created.month, day=text_post.created.day))
    return render_template("add_text_post.html", meta=meta,\
            text_post=text_post)
Exemplo n.º 2
0
def add_text__content(slugid):
    """Ajax event & markdown for content"""
    try:
        text_post = TextPost.objects(slugid=slugid).get()
    except:
        return abort(404)
    if request.method == "PUT" or request.method == 'POST':
        content = request.values.get('content')
        text_post.content = content
        text_post.html_content = markdown(content, extensions)
        text_post.updated.append(datetime.datetime.now())
        text_post.save()
        return text_post.html_content
    elif request.method == "GET":
        try:
            return text_post.content
        except:
            return abort(500)
Exemplo n.º 3
0
def add_text__title(slugid):
    """Ajax event to title"""
    try:
        text_post = TextPost.objects(slugid=slugid).first()
    except:
        return abort(404)
    if request.method == "PUT" or request.method == "POST":
        title = request.values.get('title', type=unicode)
        text_post.title = title
        if text_post.updated:
            text_post.updated.append(datetime.datetime.now())
        else:
            text_post.updated = [datetime.datetime.now()]
        text_post.slug = slugfy(unicode(title))
        text_post.save()
        return text_post.title
    elif request.method == "GET":
        return text_post.title
Exemplo n.º 4
0
def post_by_slug(slug):
    meta = Meta()
    text_post = TextPost.objects(slug=slug).first()
    text_post["created"] = datetime.datetime.strftime(text_post.created, "%Y-%m-%d @ %H:%M")
    return render_template("text_post.html", meta=meta, text_post=text_post)
Exemplo n.º 5
0
def single_text_post(year, month, day, slugid, slug=None):
    meta = Meta()
    text_post = TextPost.objects(slugid=slugid).get()
    return dict(meta=meta, text_post=text_post)