Esempio n. 1
0
def tag(tag_name):
    _start = 0
    _end = 0
    if request.args.get('_start', '') != '':
        _start = int(request.args.get('_start', ''))
    _end = _start + setting.EACH_PAGE_POST_NUM
    posts = operatorDB.get_post_page_tags(
                            tag_name)
    return render_template('tag.html',
                           tags = operatorDB.get_all_tag_name(),
                           posts = posts,
                           BASE_URL = setting.BASE_URL,
                           tag_name = tag_name)
Esempio n. 2
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)
Esempio n. 3
0
def _index(page = 1):
    posts = None
    if request.args.get('_start','') != '' :
        _start = int(request.args.get('_start', ''))
    if request.args.get('cat','') != '' :
        posts = operatorDB.get_post_page_category(request.args.get('cat',''))
    elif request.args.get('tags','') != '' :
        posts = operatorDB.get_post_page_tags(request.args.get('tags',''))
    else:
        posts = operatorDB.get_post_page(page)
    editor_posts = operatorDB.get_editor_post(0,3)
    return render_template('index.html', c=request.args.get('cat',''),
                           t=request.args.get('tags',''),
                           tags = operatorDB.get_all_tag_name(),
                           cats=operatorDB.get_all_cat_name(),
                           links=operatorDB.get_all_links(),
                           posts=posts,
                           BASE_URL=setting.BASE_URL,
                           editor_posts = editor_posts)
Esempio n. 4
0
def _index(page = 1):
    posts = None
    if request.args.get('_start','') != '' :
        _start = int(request.args.get('_start', ''))
    if request.args.get('cat','') != '' :
        posts = operatorDB.get_post_page_category(request.args.get('cat',''))
    elif request.args.get('tags','') != '' :
        posts = operatorDB.get_post_page_tags(request.args.get('tags',''))
    else:
        posts = operatorDB.get_post_page(page)
    editor_posts = operatorDB.get_editor_post(0,3)
    return render_template('index.html', c=request.args.get('cat',''),
                           t=request.args.get('tags',''),
                           tags = operatorDB.get_all_tag_name(),
                           cats=operatorDB.get_all_cat_name(),
                           links=operatorDB.get_all_links(),
                           posts=posts,
                           BASE_URL=setting.BASE_URL,
                           editor_posts = editor_posts)
Esempio n. 5
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. 6
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)
Esempio n. 7
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. 8
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)
Esempio n. 9
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)
Esempio n. 10
0
def _about():
	if request.method == 'POST':
		operatorDB.insertAboutReply(request.form.get('author', ''),request.form.get('email', ''),request.form.get('url', ''),request.form.get('comment', ''))
	aboutReplys = operatorDB.getAboutReplyAll()
	aboutReplysLen = len(aboutReplys)
	return render_template('about.html',coms=operatorDB.get_comments_new(),tags = operatorDB.get_all_tag_name(),cats=operatorDB.get_all_cat_name(),links=operatorDB.get_all_links(),sub_category=setting.HEAD_SUBCATEGORY['about'],aboutReplys=aboutReplys,aboutReplysLen=aboutReplysLen,BASE_URL=setting.BASE_URL)
Esempio n. 11
0
def _timeline():
	_data = operatorDB.getTimelineData()
	rs = u'{"timeline":{"headline":"c-house的时间线","type":"default","text":"始于2012年7月","date": [%s]}}' % _data.timeline_data
	return render_template('timeline.html',rs=rs,coms=operatorDB.get_comments_new(),tags = operatorDB.get_all_tag_name(),cats=operatorDB.get_all_cat_name(),links=operatorDB.get_all_links())
Esempio n. 12
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)))
Esempio n. 13
0
def download():
	return render_template('download.html',coms=operatorDB.get_comments_new(),tags = operatorDB.get_all_tag_name(),cats=operatorDB.get_all_cat_name(),links=operatorDB.get_all_links())
Esempio n. 14
0
def _index():
	posts = None
	_newer = False
	_older = False
	_start = 0
	_end = 0
	if request.args.get('_start','')!='' :
		_start = int(request.args.get('_start',''))
	_end = _start+setting.EACH_PAGE_POST_NUM
	if request.args.get('cat','')!='' :
		posts,_newer,_older = operatorDB.get_post_page_category(_start,_end,request.args.get('cat',''))
	elif request.args.get('tags','')!='' :
		posts,_newer,_older = operatorDB.get_post_page_tags(_start,_end,request.args.get('tags',''))
	else :
		posts,_newer,_older = operatorDB.get_post_page(_start,_end)
	return render_template('index.html',c=request.args.get('cat',''),t=request.args.get('tags',''),coms=operatorDB.get_comments_new(),tags = operatorDB.get_all_tag_name(),cats=operatorDB.get_all_cat_name(),links=operatorDB.get_all_links(),_newstart=_start-setting.EACH_PAGE_POST_NUM,_oldstart=_end,_newer=_newer,_older=_older,posts=posts,BASE_URL=setting.BASE_URL)
Esempio n. 15
0
def download():
	return render_template('download.html',coms=operatorDB.get_comments_new(),tags = operatorDB.get_all_tag_name(),cats=operatorDB.get_all_cat_name(),links=operatorDB.get_all_links())
Esempio n. 16
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)))
Esempio n. 17
0
def _timeline():
	_data = operatorDB.getTimelineData()
	rs = u'{"timeline":{"headline":"c-house的时间线","type":"default","text":"始于2012年7月","date": [%s]}}' % _data.timeline_data
	return render_template('timeline.html',rs=rs,coms=operatorDB.get_comments_new(),tags = operatorDB.get_all_tag_name(),cats=operatorDB.get_all_cat_name(),links=operatorDB.get_all_links())