예제 #1
0
def api_edit_blog(id):
    check_admin()
    i = ctx.request.input()
    logging.info(i)
    title = i.title.strip()
    content = i.content.strip()
    image = i.image
    tags = i.tags
    try:
        tag_checkbox = ctx.request.gets('tag_checkbox')
    except KeyError:
        tag_checkbox = []
    logging.info("##################")
    logging.info(tag_checkbox)
    if not title:
        raise APIValueError('name', 'name cannot be empty.')
    if not content:
        raise APIValueError('content', 'content cannot be empty.')
    blog = Blog.get(id)
    if not blog:
        raise notfound()
    blog.title = title
    blog.content = content
    if image:
        delete_upload(blog.image)
        filename = upload(image)
        blog.image = filename
    blog.update()
    update_tags(blog, tag_checkbox, tags.split(' '))
    raise seeother('/blog/%s' % blog.id)
예제 #2
0
파일: urls.py 프로젝트: lixiangbest/jblog
def api_edit_blog(id):
    check_admin()
    i = ctx.request.input()
    logging.info(i)
    title = i.title.strip()
    content = i.content.strip()
    image = i.image
    tags = i.tags
    try:
        tag_checkbox = ctx.request.gets('tag_checkbox')
    except KeyError:
        tag_checkbox = []
    logging.info("##################")
    logging.info(tag_checkbox)
    if not title:
        raise APIValueError('name', 'name cannot be empty.')
    if not content:
        raise APIValueError('content', 'content cannot be empty.')
    blog = Blog.get(id)
    if not blog:
        raise notfound()
    blog.title = title
    blog.content = content
    if image:
        delete_upload(blog.image)
        filename = upload(image)
        blog.image = filename
    blog.update()
    update_tags(blog,tag_checkbox,tags.split(' '))
    raise seeother('/blog/%s' % blog.id)
예제 #3
0
def tag_blogs(tag_id, page):
    cate = [{
        "id": "30074",
        "name": "品质女装".decode('utf-8')
    }, {
        "id": "30073",
        "name": "潮流男装".decode('utf-8')
    }, {
        "id": "30117",
        "name": "时尚鞋包".decode('utf-8')
    }, {
        "id": "30071",
        "name": "美妆个护".decode('utf-8')
    }, {
        "id": "30066",
        "name": "运动户外".decode('utf-8')
    }, {
        "id": "30068",
        "name": "家电数码".decode('utf-8')
    }, {
        "id": "30069",
        "name": "居家用品".decode('utf-8')
    }]
    if not tag_id:
        raise notfound()
    blogs = conRedis(tag_id, int(page))
    return dict(blogs=blogs, cate=cate, tag_id=tag_id, page=int(page))
예제 #4
0
파일: urls.py 프로젝트: lixiangbest/jblog
def tag_blogs(tag_id):
    tag = Tag.get(tag_id)
    if not tag:
        raise notfound()
    blogs = get_blogs_from_tag(tag)
    blogs = render_blogs(blogs)
    user = ctx.request.user
    return dict(blogs=blogs,user=user)
예제 #5
0
def members():
    tag = Tag.get("001449249583583e39048657a1c4584960f34e4623e2dae000")
    if not tag:
        raise notfound()
    blogs = get_blogs_from_tag(tag)
    blogs = render_blogs(blogs)
    user = ctx.request.user
    return dict(blogs=blogs,user=user)
예제 #6
0
def research():
    tag = Tag.get("001449249434796934306a1e38243e8b4fde9e013d286fe000")
    if not tag:
        raise notfound()
    blogs = get_blogs_from_tag(tag)
    blogs = render_blogs(blogs)
    user = ctx.request.user
    return dict(blogs=blogs,user=user)
예제 #7
0
파일: urls.py 프로젝트: tjlygdx/jblog
def tag_blogs(tag_id):
    tag = Tag.get(tag_id)
    if not tag:
        raise notfound()
    blogs = get_blogs_from_tag(tag)
    blogs = render_blogs(blogs)
    user = ctx.request.user
    return dict(blogs=blogs, user=user)
예제 #8
0
파일: urls.py 프로젝트: lixiangbest/jblog
def delete_blog(id):
    check_admin()
    blog = Blog.get(id)
    if not blog:
        raise notfound()
    tags = get_tags_from_blog(blog)
    remove = [tag.id for tag in tags]
    remove_blogtag(blog,remove)
    delete_upload(blog.image)
    blog.delete()
    return {'data':'/'}
예제 #9
0
파일: urls.py 프로젝트: lixiangbest/jblog
def blog(id):
    blog = Blog.get(id)
    if not blog:
        raise notfound()
    blog.content = markdown2.markdown(blog.content,extras=["code-friendly"])
    if 'SERVER_SOFTWARE' not in os.environ:
        blog.image = '/'+blog.image
    tags = get_tags_from_blog(blog)
    blog.tags = tags
    tags = all_tags()
    return dict(blog=blog,user=ctx.request.user,tags=tags)
예제 #10
0
def delete_blog(id):
    check_admin()
    blog = Blog.get(id)
    if not blog:
        raise notfound()
    tags = get_tags_from_blog(blog)
    remove = [tag.id for tag in tags]
    remove_blogtag(blog, remove)
    delete_upload(blog.image)
    blog.delete()
    return {'data': '/'}
예제 #11
0
def blog(id):
    blog = Blog.get(id)
    if not blog:
        raise notfound()
    blog.content = markdown2.markdown(blog.content,extras=["code-friendly"])
    if 'SERVER_SOFTWARE' not in os.environ:
        blog.image = '/'+blog.image
    tags = get_tags_from_blog(blog)
    blog.tags = tags
    tags = all_tags()
    return dict(blog=blog,user=ctx.request.user,tags=tags)
예제 #12
0
파일: urls.py 프로젝트: ZhQYuan/jblog
def blog(id):
    blog = Blog.get(id)
    if not blog:
        raise notfound()
    blog.content = markdown2.markdown(blog.content, extras=["code-friendly"])
    if "SERVER_SOFTWARE" not in os.environ:
        blog.image = "/" + blog.image
    tags = get_tags_from_blog(blog)
    blog.tags = tags
    blog.click = kv.get(id)
    if not blog.click:
        kv.add(id, 0)
        blog.click = 0
    counter_queue.add(Task("/tasks/counter", "blog_id=%s" % id))
    tags = all_tags()
    return dict(blog=blog, user=ctx.request.user, tags=tags)
예제 #13
0
파일: urls.py 프로젝트: tjlygdx/jblog
def blog(id):
    blog = Blog.get(id)
    if not blog:
        raise notfound()
    blog.content = markdown2.markdown(blog.content, extras=["code-friendly"])
    if 'SERVER_SOFTWARE' not in os.environ:
        blog.image = '/' + blog.image
    tags = get_tags_from_blog(blog)
    blog.tags = tags
    blog.click = kv.get(id)
    if not blog.click:
        kv.add(id, 0)
        blog.click = 0
    counter_queue.add(Task('/tasks/counter', "blog_id=%s" % id))
    tags = all_tags()
    return dict(blog=blog, user=ctx.request.user, tags=tags)
예제 #14
0
파일: urls.py 프로젝트: lixiangbest/jblog
def edit_blog(id):
    blog = Blog.get(id)
    if not blog:
        raise notfound()
    tags = get_tags_from_blog(blog)
    return dict(blog=blog,user=ctx.request.user,tags=tags)
예제 #15
0
def edit_blog(id):
    blog = Blog.get(id)
    if not blog:
        raise notfound()
    tags = get_tags_from_blog(blog)
    return dict(blog=blog, user=ctx.request.user, tags=tags)