Esempio n. 1
0
def searchtagname(page=1):
    if 'tagname' not in request.args:
        return render_template('tag.html',
                               allposst=[],
                               pagecount=0,
                               currentpage=1,
                               tagname="")
    tagname = urllib.unquote(request.args['tagname']).decode('utf-8')

    allpost = Post.all().filter('saveonly', False)
    tagnamelist = tagname.split(',')
    for eachtag in tagnamelist:
        eachtag = eachtag.strip()
        allpost.filter('tags', eachtag)
    #.filter('tags',tagname)
    pagecount = allpost.count() / User.SHOW_TAGSEARCH_NUMBER + 1
    if allpost.count() % User.SHOW_TAGSEARCH_NUMBER == 0:
        pagecount = pagecount - 1
    allpost = allpost.fetch(User.SHOW_TAGSEARCH_NUMBER,
                            (page - 1) * User.SHOW_TAGSEARCH_NUMBER)
    if allpost:
        return render_template('tag.html',
                               allpost=allpost,
                               pagecount=pagecount,
                               currentpage=page,
                               tagname=tagname)
    else:
        return render_template('error/tag_not_found.html', tagname=tagname)
Esempio n. 2
0
def getpost(post_id):
	'''
	if there is no such post return post_id=-1 
	'''
	post=Post.all().filter('post_id',post_id).get()
	if post and post.saveonly==False:
		return post.getjson()
	else:
		return json.dumps({'post_id':-1})
Esempio n. 3
0
def getpost(post_id):
    '''
	if there is no such post return post_id=-1 
	'''
    post = Post.all().filter('post_id', post_id).get()
    if post and post.saveonly == False:
        return post.getjson()
    else:
        return json.dumps({'post_id': -1})
Esempio n. 4
0
def deletepage():
	form=request.form
	pagelist=[]
	for item in form:
		pagelist.append(int(item))
	for item in pagelist:
		post=Post.all().filter('post_id',item).get()
		if post:
			post.remove()
	Tag.updatecache()
	Post.updatecache()
	return json.dumps({'status':1})
Esempio n. 5
0
def deletepage():
    form = request.form
    pagelist = []
    for item in form:
        pagelist.append(int(item))
    for item in pagelist:
        post = Post.all().filter('post_id', item).get()
        if post:
            post.remove()
    Tag.updatecache()
    Post.updatecache()
    return json.dumps({'status': 1})
Esempio n. 6
0
def setting():
    if request.method == 'GET':
        post_id = User.POST_ID
        postnumberhome = User.PER_PAGE_IN_HOME
        postnumberadmin = User.PER_PAGE_IN_ADMIN
        showtagnumber = User.SHOW_TAG_NUMBER
        showtagsearchnumber = User.SHOW_TAGSEARCH_NUMBER
        showlinknumber = User.SHOW_LINK_NUMBER
        mediainadmin = User.MEDIA_IN_ADMIN
        commentinadmin = User.COMMENT_IN_ADMIN
        commentinsidebar = User.COMMENT_IN_SIDEBAR
        announcelength = User.ANNOUNCELENGTH
        return render_template('admin/setting.html',
                               post_id=post_id,
                               postnumberhome=postnumberhome,
                               postnumberadmin=postnumberadmin,
                               showtagnumber=showtagnumber,
                               showtagsearchnumber=showtagsearchnumber,
                               showlinknumber=showlinknumber,
                               mediainadmin=mediainadmin,
                               commentinadmin=commentinadmin,
                               commentinsidebar=commentinsidebar,
                               announcelength=announcelength)
    else:
        needupdate = False
        form = request.form
        one = User.all().get()
        one.postnumberhome = int(form['postnumberhome'])
        one.postnumberadmin = int(form['postnumberadmin'])
        one.showtagnumber = int(form['showtagnumber'])
        one.showmediaadmin = int(form['mediainadmin'])
        one.commentinadmin = int(form['commentinadmin'])
        one.commentinsidebar = int(form['commentinsidebar'])
        one.announcelength = int(form['announcelength'])
        if int(form['showtagsearchnumber']) != one.showtagsearchnumber:
            needupdate = True
        one.showtagsearchnumber = int(form['showtagsearchnumber'])
        one.showlinknumber = int(form['showlinknumber'])
        one.post_id = int(form['post_id'])
        another = Post.all().filter('post_id', int(form['post_id'])).get()
        if not another:
            one.post_id = -1

        one.put()
        User.updatecache(one)
        Tag.updatecache()
        Comment.updatecache()
        Link.updatecache()

        return json.dumps({'message': 'success'})
Esempio n. 7
0
def searchtagname(page=1):
	if 'tagname' not in request.args:
		return render_template('tag.html',allposst=[],pagecount=0,currentpage=1,tagname="")
	tagname=urllib.unquote(request.args['tagname']).decode('utf-8')

	allpost=Post.all().filter('saveonly',False)
	tagnamelist=tagname.split(',')
	for eachtag in tagnamelist:
		eachtag=eachtag.strip()
		allpost.filter('tags',eachtag)
	#.filter('tags',tagname)
	pagecount=allpost.count()/User.SHOW_TAGSEARCH_NUMBER+1
	if allpost.count()%User.SHOW_TAGSEARCH_NUMBER==0:
		pagecount=pagecount-1
	allpost=allpost.fetch(User.SHOW_TAGSEARCH_NUMBER,(page-1)*User.SHOW_TAGSEARCH_NUMBER)
	if allpost:
		return render_template('tag.html',allpost=allpost,pagecount=pagecount,currentpage=page,tagname=tagname)
	else:
		return render_template('error/tag_not_found.html',tagname=tagname)
Esempio n. 8
0
def leavecomment(post_id=0):
    if (not g.isadmin) and (not g.isguest):
        status = 0
        message = "please login first"
    elif post_id == 0:
        status = 0
        message = "comment to the wrong page"
    elif Post.all().filter('post_id', post_id).get().allowcomment == False:
        status = 0
        message = "comment is not allowded here"
    else:
        comment = Comment(post_id=post_id,
                          email=g.user.email(),
                          nickname=g.user.nickname(),
                          comment=urllib.unquote(request.data).decode('utf-8'),
                          create_date=int(time.time()),
                          ip=request.remote_addr)
        comment.comment_id = Comment.properid()
        comment.put()
        status = 1
        message = ""
    Comment.updatecache()
    return json.dumps({"status": status, "message": message})