Esempio n. 1
0
def admin_addpost():
    if request.method == 'POST':
        _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)
        logging.error(request.form.get('content', ''))
        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)
        _article = operatorDB.add_new_article(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', '')
                                              )
        
        postId = _article._id

        if _tags!='':
            operatorDB.add_postid_to_tags(_tags.split(','), str(postId))
        operatorDB.add_postid_to_cat(request.form.get('category', ''),str(postId))
        if operatorDB.isHasData():
            updateTimelineData(_article)
        else:
            addTimelineData()
    cats = operatorDB.get_all_cat_name()
    tags = operatorDB.get_all_tag_name()
    return render_template('admin/addpost_admin.html',title=u'添加文章',cats=cats,tags=tags,SITE_TITLE=setting.SITE_TITLE,BASE_URL=setting.BASE_URL)
Esempio n. 2
0
def admin_addpost():
    if request.method == 'POST':
        _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)
        logging.error(request.form.get('content', ''))
        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)
        _article = operatorDB.add_new_article(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', '')
                                              )
        
        postId = _article._id

        if _tags!='':
            operatorDB.add_postid_to_tags(_tags.split(','), str(postId))
        operatorDB.add_postid_to_cat(request.form.get('category', ''),str(postId))
        if operatorDB.isHasData():
            updateTimelineData(_article)
        else:
            addTimelineData()
    cats = operatorDB.get_all_cat_name()
    tags = operatorDB.get_all_tag_name()
    return render_template('admin/addpost_admin.html',title=u'添加文章',cats=cats,tags=tags,SITE_TITLE=setting.SITE_TITLE,BASE_URL=setting.BASE_URL)
Esempio n. 3
0
def admin_addpost():
	if request.method == 'POST':
		_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)
		_article = operatorDB.add_new_article(request.form.get('category', ''),request.form.get('title', ''),request.form.get('content', ''),_tags,request.form.get('password', ''),shorten_content(request.form.get('content', '')))
		postId = _article._id
		if _tags!='':
			operatorDB.add_postid_to_tags(_tags.split(','), str(postId))
		operatorDB.add_postid_to_cat(request.form.get('category', ''),str(postId))
		if operatorDB.isHasData():
			updateTimelineData(_article)
		else:
			addTimelineData()
	cats = operatorDB.get_all_cat_name()
	tags = operatorDB.get_all_tag_name()
	return render_template('admin/addpost_admin.html',title=u'添加文章',cats=cats,tags=tags,SITE_TITLE=setting.SITE_TITLE,BASE_URL=setting.BASE_URL)