コード例 #1
0
ファイル: admin.py プロジェクト: yangzilong1986/saepy-log
    def post(self):
        self.set_header('Content-Type','application/json')
        rspd = {'status': 201, 'msg':'ok'}

        try:
            tf = {'true':1,'false':0}
            timestamp = int(time())
            post_dic = {
                'category': self.get_argument("cat"),
                'title': self.get_argument("tit"),
                'content': self.get_argument("con"),
                'tags': self.get_argument("tag",'').replace(u',',','),
                'closecomment': self.get_argument("clo",'0'),
                'password': self.get_argument("password",''),
                'add_time': timestamp,
                'edit_time': timestamp,
                'archive': genArchive(),
            }
            if post_dic['tags']:
                tagslist = set([x.strip() for x in post_dic['tags'].split(',')])
                try:
                    tagslist.remove('')
                except:
                    pass
                if tagslist:
                    post_dic['tags'] = ','.join(tagslist)
            post_dic['closecomment'] = tf[post_dic['closecomment'].lower()]
        except:
            rspd['status'] = 500
            rspd['msg'] = '错误: 注意必填的三项'
            self.write(json.dumps(rspd))
            return

        postid = Article.add_new_article(post_dic)
        if postid:
            keyname = 'pv_%s' % (str(postid))
            set_count(keyname,0,0)
            
            Category.add_postid_to_cat(post_dic['category'], str(postid))
            Archive.add_postid_to_archive(genArchive(), str(postid))
            increment('Totalblog')
            if post_dic['tags']:
                Tag.add_postid_to_tags(post_dic['tags'].split(','), str(postid))

            rspd['status'] = 200
            rspd['msg'] = '完成: 你已经成功添加了一篇文章 <a href="/t/%s" target="_blank">查看</a>' % str(postid)
            clear_cache_by_pathlist(['/', 'cat:%s' % quoted_string(post_dic['category'])])

            if not debug:
                add_task('default', '/task/pingrpctask')

            self.write(json.dumps(rspd))
            return
        else:
            rspd['status'] = 500
            rspd['msg'] = '错误: 未知错误,请尝试重新提交'
            self.write(json.dumps(rspd))
            return
コード例 #2
0
    def post(self):
        self.set_header('Content-Type', 'application/json')
        rspd = {'status': 201, 'msg': 'ok'}

        try:
            tf = {'true': 1, 'false': 0}
            timestamp = int(time())
            post_dic = {
                'category': self.get_argument("cat"),
                'title': self.get_argument("tit"),
                'content': self.get_argument("con"),
                'tags': self.get_argument("tag", '').replace(u',', ','),
                'closecomment': self.get_argument("clo", '0'),
                'password': self.get_argument("password", ''),
                'add_time': timestamp,
                'edit_time': timestamp,
            }
            if post_dic['tags']:
                tagslist = set(
                    [x.strip() for x in post_dic['tags'].split(',')])
                try:
                    tagslist.remove('')
                except:
                    pass
                if tagslist:
                    post_dic['tags'] = ','.join(tagslist)
            post_dic['closecomment'] = tf[post_dic['closecomment'].lower()]
        except:
            rspd['status'] = 500
            rspd['msg'] = '错误: 注意必填的三项'
            self.write(json.dumps(rspd))
            return

        postid = Article.add_new_article(post_dic)
        if postid:
            Category.add_postid_to_cat(post_dic['category'], str(postid))
            if post_dic['tags']:
                Tag.add_postid_to_tags(post_dic['tags'].split(','),
                                       str(postid))

            rspd['status'] = 200
            rspd[
                'msg'] = '完成: 你已经成功添加了一篇文章 <a href="/t/%s" target="_blank">查看</a>' % str(
                    postid)
            clear_cache_by_pathlist(
                ['/', 'cat:%s' % quoted_string(post_dic['category'])])

            if not debug:
                add_task('default', '/task/pingrpctask')

            self.write(json.dumps(rspd))
            return
        else:
            rspd['status'] = 500
            rspd['msg'] = '错误: 未知错误,请尝试重新提交'
            self.write(json.dumps(rspd))
            return
コード例 #3
0
ファイル: admin.py プロジェクト: biggtfish/pyWeiXin_SAElog
    def post(self):
        self.set_header("Content-Type", "application/json")
        rspd = {"status": 201, "msg": "ok"}

        try:
            tf = {"true": 1, "false": 0}
            timestamp = int(time())
            post_dic = {
                "category": self.get_argument("cat"),
                "title": self.get_argument("tit"),
                "content": self.get_argument("con"),
                "tags": self.get_argument("tag", "").replace(u",", ","),
                "closecomment": self.get_argument("clo", "0"),
                "password": self.get_argument("password", ""),
                "add_time": timestamp,
                "edit_time": timestamp,
            }
            if post_dic["tags"]:
                tagslist = set([x.strip() for x in post_dic["tags"].split(",")])
                try:
                    tagslist.remove("")
                except:
                    pass
                if tagslist:
                    post_dic["tags"] = ",".join(tagslist)
            post_dic["closecomment"] = tf[post_dic["closecomment"].lower()]
        except:
            rspd["status"] = 500
            rspd["msg"] = "错误: 注意必填的三项"
            self.write(json.dumps(rspd))
            return

        postid = Article.add_new_article(post_dic)
        if postid:
            Category.add_postid_to_cat(post_dic["category"], str(postid))
            if post_dic["tags"]:
                Tag.add_postid_to_tags(post_dic["tags"].split(","), str(postid))

            rspd["status"] = 200
            rspd["msg"] = '完成: 你已经成功添加了一篇文章 <a href="/t/%s" target="_blank">查看</a>' % str(postid)
            clear_cache_by_pathlist(["/", "cat:%s" % quoted_string(post_dic["category"])])

            if not debug:
                add_task("default", "/task/pingrpctask")

            self.write(json.dumps(rspd))
            return
        else:
            rspd["status"] = 500
            rspd["msg"] = "错误: 未知错误,请尝试重新提交"
            self.write(json.dumps(rspd))
            return
コード例 #4
0
ファイル: admin.py プロジェクト: yobin/saepy-log
    def post(self):
        self.set_header('Content-Type', 'application/json')
        rspd = {'status': 201, 'msg': 'ok'}

        secret = self.get_argument("s", "")

        if secret <> getAttr('MOVE_SECRET'):
            user = False
            rspd['status'] = 403
            rspd['msg'] = 'secret code err.'
            self.write(json.dumps(rspd))
            return

        try:
            tf = {'true': 1, 'false': 0}
            timestamp = int(time())
            #print timestamp
            post_dic = {
                'category': self.get_argument("cat"),
                'title': self.get_argument("tit"),
                'content': self.get_argument("con"),
                'tags': self.get_argument("tag", '').replace(u',', ','),
                'closecomment': self.get_argument("clo", 'false'),
                'password': self.get_argument("p", ''),
                'add_time': self.get_argument("addtime", timestamp),
                'edit_time': self.get_argument("edit_time", timestamp),
                'archive': self.get_argument("archive", genArchive()),
                'pv': int(self.get_argument("pv", 0)),
            }
            if post_dic['tags']:
                tagslist = set(
                    [x.strip() for x in post_dic['tags'].split(',')])
                try:
                    tagslist.remove('')
                except:
                    pass
                if tagslist:
                    post_dic['tags'] = ','.join(tagslist)
            print '====================='
            print post_dic['pv']
            post_dic['closecomment'] = tf[post_dic['closecomment'].lower()]
        except:
            rspd['status'] = 500
            rspd['msg'] = 'Para err.'
            self.write(json.dumps(rspd))
            return

        postid = Article.add_new_article(post_dic)
        if postid:
            Category.add_postid_to_cat(post_dic['category'], str(postid))
            Archive.add_postid_to_archive(post_dic['archive'], str(postid))
            keyname = 'pv_%s' % (str(postid))
            set_count(keyname, 0, post_dic['pv'])
            increment('Totalblog')
            if post_dic['tags']:
                Tag.add_postid_to_tags(post_dic['tags'].split(','),
                                       str(postid))

            rspd['status'] = 200
            #rspd['msg'] = '完成: 你已经成功添加了一篇文章 <a href="/t/%s" target="_blank">查看</a>' % str(postid)
            #clear_cache_by_pathlist(['/', 'cat:%s' % quoted_string(post_dic['category'])])

            #if not debug:
            #    #add_task('default', '/task/pingrpctask')

            self.write(json.dumps(rspd))
            return
        else:
            rspd['status'] = 500
            rspd['msg'] = 'Unknown err.'
            self.write(json.dumps(rspd))
            return
コード例 #5
0
ファイル: admin.py プロジェクト: yobin/saepy-log
    def post(self, id=''):
        act = self.get_argument("act", '')
        if act == 'findid':
            eid = self.get_argument("id", '')
            self.redirect('%s/admin/edit_post/%s' % (BASE_URL, eid))
            return

        self.set_header('Content-Type', 'application/json')
        rspd = {'status': 201, 'msg': 'ok'}
        oldobj = Article.get_article_by_id_edit(id)

        content = self.get_argument("con")
        if getAttr('MARKDOWN'):
            #content = markdown.markdown(parse_text(content))
            content = content.encode("utf-8")

        try:
            tf = {'true': 1, 'false': 0}
            timestamp = int(time())
            post_dic = {
                'category':
                self.get_argument("cat"),
                'title':
                self.get_argument("tit"),
                'content':
                content,
                'tags':
                self.get_argument("tag", '').replace(u',',
                                                     ',').encode('utf-8'),
                'closecomment':
                self.get_argument("clo", 'false'),
                'password':
                self.get_argument("password", ''),
                'edit_time':
                timestamp,
                'id':
                id
            }

            if MYSQL_TO_KVDB_SUPPORT:
                post_dic['add_time'] = oldobj['add_time']
                post_dic['archive'] = oldobj['archive']
                post_dic['comment_num'] = oldobj['comment_num']

            if post_dic['tags']:
                tagslist = set(
                    [x.strip() for x in post_dic['tags'].split(',')])
                try:
                    tagslist.remove('')
                except:
                    pass
                if tagslist:
                    post_dic['tags'] = ','.join(tagslist)
            post_dic['closecomment'] = tf[post_dic['closecomment'].lower()]

        except:
            rspd['status'] = 500
            rspd['msg'] = '错误: 注意必填的三项'
            self.write(json.dumps(rspd))
            return

        postid = Article.update_post_edit(post_dic)
        if postid:
            if MYSQL_TO_KVDB_SUPPORT:
                oldobj_category = oldobj['category']
                oldobj_tags = oldobj['tags']
            else:
                oldobj_category = oldobj.category
                oldobj_tags = oldobj.tags
            cache_key_list = [
                '/',
                'post:%s' % id,
                'cat:%s' % quoted_string(oldobj_category)
            ]
            if oldobj_category != post_dic['category']:
                #cat changed
                Category.add_postid_to_cat(post_dic['category'], str(postid))
                Category.remove_postid_from_cat(oldobj_category, str(postid))
                cache_key_list.append('cat:%s' %
                                      quoted_string(post_dic['category']))

            if oldobj_tags != post_dic['tags']:
                #tag changed
                old_tags = set(oldobj_tags.split(','))
                new_tags = set(post_dic['tags'].split(','))

                removed_tags = old_tags - new_tags
                added_tags = new_tags - old_tags

                if added_tags:
                    Tag.add_postid_to_tags(added_tags, str(postid))

                if removed_tags:
                    Tag.remove_postid_from_tags(removed_tags, str(postid))

            clear_cache_by_pathlist(cache_key_list)
            rspd['status'] = 200
            rspd[
                'msg'] = '完成: 你已经成功编辑了一篇文章 <a href="/t/%s" target="_blank">查看编辑后的文章</a>' % str(
                    postid)
            self.write(json.dumps(rspd))
            return
        else:
            rspd['status'] = 500
            rspd['msg'] = '错误: 未知错误,请尝试重新提交'
            self.write(json.dumps(rspd))
            return
コード例 #6
0
ファイル: admin.py プロジェクト: yobin/saepy-log
    def post(self):
        self.set_header('Content-Type', 'application/json')
        rspd = {'status': 201, 'msg': 'ok'}

        try:
            tf = {'true': 1, 'false': 0}
            timestamp = int(time())
            content = self.get_argument("con")
            if getAttr('MARKDOWN'):
                #content = markdown.markdown(parse_text(content))
                content = content.encode("utf-8")
            post_dic = {
                'category': self.get_argument("cat"),
                'title': self.get_argument("tit"),
                'content': content,
                'tags': self.get_argument("tag", '').replace(u',', ','),
                'closecomment': self.get_argument("clo", '0'),
                'password': self.get_argument("password", ''),
                'add_time': timestamp,
                'edit_time': timestamp,
                'archive': genArchive(),
            }
            if MYSQL_TO_KVDB_SUPPORT:
                post_dic['comment_num'] = '0'

            if post_dic['tags']:
                tagslist = set(
                    [x.strip() for x in post_dic['tags'].split(',')])
                try:
                    tagslist.remove('')
                except:
                    pass
                if tagslist:
                    post_dic['tags'] = ','.join(tagslist)
            post_dic['closecomment'] = tf[post_dic['closecomment'].lower()]
        except:
            rspd['status'] = 500
            rspd['msg'] = '错误: 注意必填的三项'
            self.write(json.dumps(rspd))
            return

        postid = Article.add_new_article(post_dic)
        if postid:
            keyname = 'pv_%s' % (str(postid))
            set_count(keyname, 0, 0)

            Category.add_postid_to_cat(post_dic['category'], str(postid))
            Archive.add_postid_to_archive(genArchive(), str(postid))
            increment('Totalblog')
            if post_dic['tags']:
                Tag.add_postid_to_tags(post_dic['tags'].split(','),
                                       str(postid))

            rspd['status'] = 200
            rspd[
                'msg'] = '完成: 你已经成功添加了一篇文章 <a href="/t/%s" target="_blank">查看</a>' % str(
                    postid)
            #clear_cache_by_pathlist(['/', 'cat:%s' % quoted_string(post_dic['category']), 'post_list_index',])
            clear_all_cache()  #yobin 20160921

            if not debug:
                add_task('default', '/task/pingrpctask')

            self.write(json.dumps(rspd))
            return
        else:
            rspd['status'] = 500
            rspd['msg'] = '错误: 未知错误,请尝试重新提交'
            self.write(json.dumps(rspd))
            return
コード例 #7
0
ファイル: admin.py プロジェクト: cylinderlee/saepy-log
    def post(self, id = ''):
        act = self.get_argument("act",'')
        if act == 'findid':
            eid = self.get_argument("id",'')
            self.redirect('%s/admin/edit_post/%s'% (BASE_URL, eid))
            return

        self.set_header('Content-Type','application/json')
        rspd = {'status': 201, 'msg':'ok'}
        oldobj = Article.get_article_by_id_edit(id)

        try:
            tf = {'true':1,'false':0}
            timestamp = int(time())
            post_dic = {
                'category': self.get_argument("cat"),
                'title': self.get_argument("tit"),
                'content': self.get_argument("con"),
                'tags': self.get_argument("tag",'').replace(u',',','),
                'closecomment': self.get_argument("clo",'0'),
                'password': self.get_argument("password",''),
                'edit_time': timestamp,
                'id': id
            }

            if post_dic['tags']:
                tagslist = set([x.strip() for x in post_dic['tags'].split(',')])
                try:
                    tagslist.remove('')
                except:
                    pass
                if tagslist:
                    post_dic['tags'] = ','.join(tagslist)
            post_dic['closecomment'] = tf[post_dic['closecomment'].lower()]
        except:
            rspd['status'] = 500
            rspd['msg'] = '错误: 注意必填的三项'
            self.write(json.dumps(rspd))
            return

        postid = Article.update_post_edit(post_dic)
        if postid:
            cache_key_list = ['/', 'post:%s'% id, 'cat:%s' % quoted_string(oldobj.category)]
            if oldobj.category != post_dic['category']:
                #cat changed
                Category.add_postid_to_cat(post_dic['category'], str(postid))
                Category.remove_postid_from_cat(post_dic['category'], str(postid))
                cache_key_list.append('cat:%s' % quoted_string(post_dic['category']))

            if oldobj.tags != post_dic['tags']:
                #tag changed
                old_tags = set(oldobj.tags.split(','))
                new_tags = set(post_dic['tags'].split(','))

                removed_tags = old_tags - new_tags
                added_tags = new_tags - old_tags

                if added_tags:
                    Tag.add_postid_to_tags(added_tags, str(postid))

                if removed_tags:
                    Tag.remove_postid_from_tags(removed_tags, str(postid))

            clear_cache_by_pathlist(cache_key_list)
            rspd['status'] = 200
            rspd['msg'] = '完成: 你已经成功编辑了一篇文章 <a href="/t/%s" target="_blank">查看编辑后的文章</a>' % str(postid)
            self.write(json.dumps(rspd))
            return
        else:
            rspd['status'] = 500
            rspd['msg'] = '错误: 未知错误,请尝试重新提交'
            self.write(json.dumps(rspd))
            return
コード例 #8
0
ファイル: admin.py プロジェクト: yangzilong1986/saepy-log
    def post(self):
        self.set_header('Content-Type','application/json')
        rspd = {'status': 201, 'msg':'ok'}

        secret = self.get_argument("s","")

        if secret <> getAttr('MOVE_SECRET'):
            user = False
            rspd['status'] = 403
            rspd['msg'] = 'secret code err.'
            self.write(json.dumps(rspd))
            return

        try:
            tf = {'true':1,'false':0}
            timestamp = int(time())
            #print timestamp
            post_dic = {
                'category': self.get_argument("cat"),
                'title': self.get_argument("tit"),
                'content': self.get_argument("con"),
                'tags': self.get_argument("tag",'').replace(u',',','),
                'closecomment': self.get_argument("clo",'false'),
                'password': self.get_argument("p",''),
                'add_time': self.get_argument("addtime",timestamp),
                'edit_time': self.get_argument("edit_time",timestamp),
                'archive': self.get_argument("archive",genArchive()),
                'pv': int(self.get_argument("pv",0)),
            }
            if post_dic['tags']:
                tagslist = set([x.strip() for x in post_dic['tags'].split(',')])
                try:
                    tagslist.remove('')
                except:
                    pass
                if tagslist:
                    post_dic['tags'] = ','.join(tagslist)
            print '====================='
            print post_dic['pv']
            post_dic['closecomment'] = tf[post_dic['closecomment'].lower()]
        except:
            rspd['status'] = 500
            rspd['msg'] = 'Para err.'
            self.write(json.dumps(rspd))
            return

        postid = Article.add_new_article(post_dic)
        if postid:
            Category.add_postid_to_cat(post_dic['category'], str(postid))
            Archive.add_postid_to_archive(post_dic['archive'], str(postid))
            keyname = 'pv_%s' % (str(postid))
            set_count(keyname,0,post_dic['pv'])
            increment('Totalblog')
            if post_dic['tags']:
                Tag.add_postid_to_tags(post_dic['tags'].split(','), str(postid))

            rspd['status'] = 200
            #rspd['msg'] = '完成: 你已经成功添加了一篇文章 <a href="/t/%s" target="_blank">查看</a>' % str(postid)
            #clear_cache_by_pathlist(['/', 'cat:%s' % quoted_string(post_dic['category'])])

            #if not debug:
            #    #add_task('default', '/task/pingrpctask')

            self.write(json.dumps(rspd))
            return
        else:
            rspd['status'] = 500
            rspd['msg'] = 'Unknown err.'
            self.write(json.dumps(rspd))
            return
コード例 #9
0
ファイル: admin.py プロジェクト: biggtfish/pyWeiXin_SAElog
    def post(self, id=""):
        act = self.get_argument("act", "")
        if act == "findid":
            eid = self.get_argument("id", "")
            self.redirect("%s/admin/edit_post/%s" % (BASE_URL, eid))
            return

        self.set_header("Content-Type", "application/json")
        rspd = {"status": 201, "msg": "ok"}
        oldobj = Article.get_article_by_id_edit(id)

        try:
            tf = {"true": 1, "false": 0}
            timestamp = int(time())
            post_dic = {
                "category": self.get_argument("cat"),
                "title": self.get_argument("tit"),
                "content": self.get_argument("con"),
                "tags": self.get_argument("tag", "").replace(u",", ","),
                "closecomment": self.get_argument("clo", "0"),
                "password": self.get_argument("password", ""),
                "edit_time": timestamp,
                "id": id,
            }

            if post_dic["tags"]:
                tagslist = set([x.strip() for x in post_dic["tags"].split(",")])
                try:
                    tagslist.remove("")
                except:
                    pass
                if tagslist:
                    post_dic["tags"] = ",".join(tagslist)
            post_dic["closecomment"] = tf[post_dic["closecomment"].lower()]
        except:
            rspd["status"] = 500
            rspd["msg"] = "错误: 注意必填的三项"
            self.write(json.dumps(rspd))
            return

        postid = Article.update_post_edit(post_dic)
        if postid:
            cache_key_list = ["/", "post:%s" % id, "cat:%s" % quoted_string(oldobj.category)]
            if oldobj.category != post_dic["category"]:
                # cat changed
                Category.add_postid_to_cat(post_dic["category"], str(postid))
                Category.remove_postid_from_cat(post_dic["category"], str(postid))
                cache_key_list.append("cat:%s" % quoted_string(post_dic["category"]))

            if oldobj.tags != post_dic["tags"]:
                # tag changed
                old_tags = set(oldobj.tags.split(","))
                new_tags = set(post_dic["tags"].split(","))

                removed_tags = old_tags - new_tags
                added_tags = new_tags - old_tags

                if added_tags:
                    Tag.add_postid_to_tags(added_tags, str(postid))

                if removed_tags:
                    Tag.remove_postid_from_tags(removed_tags, str(postid))

            clear_cache_by_pathlist(cache_key_list)
            rspd["status"] = 200
            rspd["msg"] = '完成: 你已经成功编辑了一篇文章 <a href="/t/%s" target="_blank">查看编辑后的文章</a>' % str(postid)
            self.write(json.dumps(rspd))
            return
        else:
            rspd["status"] = 500
            rspd["msg"] = "错误: 未知错误,请尝试重新提交"
            self.write(json.dumps(rspd))
            return
コード例 #10
0
ファイル: admin.py プロジェクト: yobin/saepy-log
    def post(self):
        self.set_header("Content-Type", "application/json")
        rspd = {"status": 201, "msg": "ok"}

        secret = self.get_argument("s", "")

        if secret <> getAttr("MOVE_SECRET"):
            user = False
            rspd["status"] = 403
            rspd["msg"] = "secret code err."
            self.write(json.dumps(rspd))
            return

        try:
            tf = {"true": 1, "false": 0}
            timestamp = int(time())
            # print timestamp
            post_dic = {
                "category": self.get_argument("cat"),
                "title": self.get_argument("tit"),
                "content": self.get_argument("con"),
                "tags": self.get_argument("tag", "").replace(u",", ","),
                "closecomment": self.get_argument("clo", "false"),
                "password": self.get_argument("p", ""),
                "add_time": self.get_argument("addtime", timestamp),
                "edit_time": self.get_argument("edit_time", timestamp),
                "archive": self.get_argument("archive", genArchive()),
                "pv": int(self.get_argument("pv", 0)),
            }
            if post_dic["tags"]:
                tagslist = set([x.strip() for x in post_dic["tags"].split(",")])
                try:
                    tagslist.remove("")
                except:
                    pass
                if tagslist:
                    post_dic["tags"] = ",".join(tagslist)
            print "====================="
            print post_dic["pv"]
            post_dic["closecomment"] = tf[post_dic["closecomment"].lower()]
        except:
            rspd["status"] = 500
            rspd["msg"] = "Para err."
            self.write(json.dumps(rspd))
            return

        postid = Article.add_new_article(post_dic)
        if postid:
            Category.add_postid_to_cat(post_dic["category"], str(postid))
            Archive.add_postid_to_archive(post_dic["archive"], str(postid))
            keyname = "pv_%s" % (str(postid))
            set_count(keyname, 0, post_dic["pv"])
            increment("Totalblog")
            if post_dic["tags"]:
                Tag.add_postid_to_tags(post_dic["tags"].split(","), str(postid))

            rspd["status"] = 200
            # rspd['msg'] = '完成: 你已经成功添加了一篇文章 <a href="/t/%s" target="_blank">查看</a>' % str(postid)
            # clear_cache_by_pathlist(['/', 'cat:%s' % quoted_string(post_dic['category'])])

            # if not debug:
            #    #add_task('default', '/task/pingrpctask')

            self.write(json.dumps(rspd))
            return
        else:
            rspd["status"] = 500
            rspd["msg"] = "Unknown err."
            self.write(json.dumps(rspd))
            return
コード例 #11
0
ファイル: admin.py プロジェクト: yobin/saepy-log
    def post(self):
        self.set_header("Content-Type", "application/json")
        rspd = {"status": 201, "msg": "ok"}

        try:
            tf = {"true": 1, "false": 0}
            timestamp = int(time())
            content = self.get_argument("con")
            if getAttr("MARKDOWN"):
                # content = markdown.markdown(parse_text(content))
                content = content.encode("utf-8")
            post_dic = {
                "category": self.get_argument("cat"),
                "title": self.get_argument("tit"),
                "content": content,
                "tags": self.get_argument("tag", "").replace(u",", ","),
                "closecomment": self.get_argument("clo", "0"),
                "password": self.get_argument("password", ""),
                "add_time": timestamp,
                "edit_time": timestamp,
                "archive": genArchive(),
            }
            if MYSQL_TO_KVDB_SUPPORT:
                post_dic["comment_num"] = "0"

            if post_dic["tags"]:
                tagslist = set([x.strip() for x in post_dic["tags"].split(",")])
                try:
                    tagslist.remove("")
                except:
                    pass
                if tagslist:
                    post_dic["tags"] = ",".join(tagslist)
            post_dic["closecomment"] = tf[post_dic["closecomment"].lower()]
        except:
            rspd["status"] = 500
            rspd["msg"] = "错误: 注意必填的三项"
            self.write(json.dumps(rspd))
            return

        postid = Article.add_new_article(post_dic)
        if postid:
            keyname = "pv_%s" % (str(postid))
            set_count(keyname, 0, 0)

            Category.add_postid_to_cat(post_dic["category"], str(postid))
            Archive.add_postid_to_archive(genArchive(), str(postid))
            increment("Totalblog")
            if post_dic["tags"]:
                Tag.add_postid_to_tags(post_dic["tags"].split(","), str(postid))

            rspd["status"] = 200
            rspd["msg"] = '完成: 你已经成功添加了一篇文章 <a href="/t/%s" target="_blank">查看</a>' % str(postid)
            # clear_cache_by_pathlist(['/', 'cat:%s' % quoted_string(post_dic['category']), 'post_list_index',])
            clear_all_cache()  # yobin 20160921

            if not debug:
                add_task("default", "/task/pingrpctask")

            self.write(json.dumps(rspd))
            return
        else:
            rspd["status"] = 500
            rspd["msg"] = "错误: 未知错误,请尝试重新提交"
            self.write(json.dumps(rspd))
            return