Exemple #1
0
def detailpost(post_id):
	if request.method == 'POST':
		operatorDB.add_new_comment(post_id,request.form.get('author', ''),request.form.get('email', ''),request.form.get('url', ''),1,request.form.get('comment', ''))
	_article = operatorDB.detail_post_by_id(post_id)
	comments = operatorDB.get_post_comments(post_id)
	comLen = len(comments)
	_older,_newer = operatorDB.get_post_older_newer(post_id)
	return render_template('detailpost.html',_older=_older,_newer=_newer,coms=operatorDB.get_comments_new(),tags = operatorDB.get_all_tag_name(),cats=operatorDB.get_all_cat_name(),links=operatorDB.get_all_links(),post_id=post_id,comLen=comLen,comments=comments,obj=_article,add_time=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(_article._add_time)))
Exemple #2
0
def detailpost(post_id):
    if request.method == 'POST':
		operatorDB.add_new_comment(post_id,request.form.get('author', ''),request.form.get('email', ''),request.form.get('url', ''),1,request.form.get('comment', ''))
    _article = operatorDB.detail_post_by_id(post_id)
    comments = operatorDB.get_post_comments(post_id)
    comLen = len(comments)
    _older,_newer = operatorDB.get_post_older_newer(post_id)
    if request.args.get('weixin', '') != '':
        return render_template('detailpost_weixin.html',post_id=post_id,obj=_article,add_time=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(_article._add_time)))
    else:
	   return render_template('detailpost.html',_older=_older,_newer=_newer,coms=operatorDB.get_comments_new(),tags = operatorDB.get_all_tag_name(),cats=operatorDB.get_all_cat_name(),links=operatorDB.get_all_links(),post_id=post_id,comLen=comLen,comments=comments,obj=_article,add_time=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(_article._add_time)))
Exemple #3
0
def admin_editpost():
	_article = None
	if request.method == 'POST':
		if request.form.get('act', '')=='editpost':
			_tags = request.form.get('tags', '').replace(u',',',')
			tagslist = set([x.strip() for x in _tags.split(',')])
			try:
				tagslist.remove('')
			except:
				pass
			if tagslist:
				_tags = ','.join(tagslist)
			operatorDB.update_article(request.form.get('id', ''),request.form.get('category', ''),request.form.get('title', ''),request.form.get('content', ''),_tags,request.form.get('password', ''),shorten_content(request.form.get('content', '')))
		post_id = request.form.get('id', '')
		_article = operatorDB.detail_post_by_id(post_id)
	cats = operatorDB.get_all_cat_name()
	tags = operatorDB.get_all_tag_name()
	return render_template('admin/editpost_admin.html',obj=_article,cats=cats,tags=tags,SITE_TITLE=setting.SITE_TITLE,BASE_URL=setting.BASE_URL)
Exemple #4
0
def admin_editpost():
    _article = None
    if request.method == 'POST':
        post_id = request.form.get('id', '')
        if request.form.get('act', '')=='editpost':
            _post_type = request.form.get('post_type', '')
            if _post_type == '':
                _post_type = 0
            _tags = request.form.get('tags', '').replace(u',',',')
            tagslist = set([x.strip() for x in _tags.split(',')])
            try:
                tagslist.remove('')
            except:
                pass
            if tagslist:
                _tags = ','.join(tagslist)
            imgsrc = re.search("img src=(\S*)", request.form.get('content', ''))
            imgthumbnail = ''
            if imgsrc:
                imgext = re.search("(\.\w*)$", imgsrc.group(1))
                if imgext:
                    logging.error(">>admin_addpost: %s" % imgsrc.group(1)+"_thumbnail"+ imgext.group(1))
                    imgthumbnail = imgsrc.group(1)+"_thumbnail"+ imgext.group(1)
            operatorDB.update_article(request.form.get('id', ''),
                                      request.form.get('category', ''),
                                      request.form.get('title', ''),
                                      request.form.get('content', ''),
                                      _tags,request.form.get('password', ''),
                                      shorten_content(request.form.get('content', '')),
                                      imgthumbnail, _post_type,
                                      request.form.get('editor_title', '')
                                              )
            if _tags!='':
                operatorDB.add_postid_to_tags(_tags.split(','), str(post_id))
            operatorDB.add_postid_to_cat(request.form.get('category', ''),str(post_id))
            
        
        _article = operatorDB.detail_post_by_id(post_id)
        
    cats = operatorDB.get_all_cat_name()
    tags = operatorDB.get_all_tag_name()
    return render_template('admin/editpost_admin.html',obj=_article,cats=cats,tags=tags,SITE_TITLE=setting.SITE_TITLE,BASE_URL=setting.BASE_URL)
Exemple #5
0
def admin_editpost():
    _article = None
    if request.method == 'POST':
        post_id = request.form.get('id', '')
        if request.form.get('act', '')=='editpost':
            _post_type = request.form.get('post_type', '')
            if _post_type == '':
                _post_type = 0
            _tags = request.form.get('tags', '').replace(u',',',')
            tagslist = set([x.strip() for x in _tags.split(',')])
            try:
                tagslist.remove('')
            except:
                pass
            if tagslist:
                _tags = ','.join(tagslist)
            imgsrc = re.search("img src=(\S*)", request.form.get('content', ''))
            imgthumbnail = ''
            if imgsrc:
                imgext = re.search("(\.\w*)$", imgsrc.group(1))
                if imgext:
                    logging.error(">>admin_addpost: %s" % imgsrc.group(1)+"_thumbnail"+ imgext.group(1))
                    imgthumbnail = imgsrc.group(1)+"_thumbnail"+ imgext.group(1)
            operatorDB.update_article(request.form.get('id', ''),
                                      request.form.get('category', ''),
                                      request.form.get('title', ''),
                                      request.form.get('content', ''),
                                      _tags,request.form.get('password', ''),
                                      shorten_content(request.form.get('content', '')),
                                      imgthumbnail, _post_type,
                                      request.form.get('editor_title', '')
                                              )
            if _tags!='':
                operatorDB.add_postid_to_tags(_tags.split(','), str(post_id))
            operatorDB.add_postid_to_cat(request.form.get('category', ''),str(post_id))
            
        
        _article = operatorDB.detail_post_by_id(post_id)
        
    cats = operatorDB.get_all_cat_name()
    tags = operatorDB.get_all_tag_name()
    return render_template('admin/editpost_admin.html',obj=_article,cats=cats,tags=tags,SITE_TITLE=setting.SITE_TITLE,BASE_URL=setting.BASE_URL)