コード例 #1
0
ファイル: script_edit_diff.py プロジェクト: alphachoi/TorCMS
def get_diff_str(*args):
    mpost = MPost()
    mposthist = MPostHist()
    diff_str = ''

    for key in router_post.keys():
        recent_posts = mpost.query_recent_edited(tools.timestamp() -
                                                 time_limit,
                                                 kind=key)
        for recent_post in recent_posts:
            hist_rec = mposthist.get_last(recent_post.uid)
            if hist_rec:
                raw_title = hist_rec.title
                new_title = recent_post.title

                infobox = diff_table(raw_title, new_title)
                # infobox = test[start:end] + '</table>'
                # if ('diff_add' in infobox) or ('diff_chg' in infobox) or ('diff_sub' in infobox):
                diff_str = diff_str + '<h2 style="color:red; font-size:larger; font-weight:70;">TITLE: {0}</h2>'.format(
                    recent_post.title) + infobox

                infobox = diff_table(hist_rec.cnt_md, recent_post.cnt_md)

                diff_str = diff_str + '<h3>CONTENT:{0}</h3>'.format(
                    recent_post.title) + infobox + '</hr>'
            else:
                continue
    return diff_str
コード例 #2
0
def do_cabpost():
    print('==============================')
    print('For Post ... ')
    from model_ent.post_model import MPost as MPostOld
    mpost_old = MPostOld()

    from torcms.model.post_model import MPost

    mpost = MPost()
    post_recs = mpost_old.query_all()
    for post_rec in post_recs:
        # print(post_rec.uid)

        if post_rec.uid.startswith('m') or post_rec.uid.startswith('g'):
            pass
            # continue
        post_data = {
            'title': post_rec.title,
            'user_name': post_rec.user_name,
            'logo': post_rec.logo,
            'cnt_md': unescape(unescape(post_rec.cnt_md)),
            'keywords': post_rec.keywords,
            'time_create': post_rec.time_create,
            'time_update': post_rec.time_update,
            'kind': '1',
            'valid': 1,
        }
        print(post_rec.uid)
        mpost.add_or_update(buqi_postid(post_rec.uid), post_data)
コード例 #3
0
ファイル: test_post_hist.py プロジェクト: Silentsoul04/TorCMS
    def test_create_post_history(self):
        self.tearDown()

        p_d = {
            'title': 'qqqii',
            'cnt_md': 'qwqwqw',
            'time_create': '1999',
            'time_update': '2019',
            'user_name': 'max',
            'view_count': '1',
            'logo': 'opps',
            'memo': '',
            'order': '1',
            'kind': '1',
            'valid': 1,
        }
        MPost().add_meta(self.post_id, p_d)
        aa = MPost.get_by_uid(self.post_id)
        tf = MPostHist.create_post_history(aa, aa)
        assert tf
        His = MPostHist.query_by_postid(self.post_id)

        self.uid = His[0].uid
        assert His[0].cnt_md == p_d['cnt_md']
        self.tearDown()
コード例 #4
0
ファイル: script_init_env.py プロジェクト: daodaoliang/TorCMS
def build_whoosh_database():
    analyzer = ChineseAnalyzer()
    schema = Schema(title=TEXT(stored=True, analyzer=analyzer),
                    type=TEXT(stored=True),
                    link=ID(stored=True),
                    content=TEXT(stored=True, analyzer=analyzer))
    ix = create_in(whoosh_database, schema)

    writer = ix.writer()

    uu = MInfor()

    tt = uu.get_all()
    for rec in tt:
        text2 = html2text.html2text(tornado.escape.xhtml_unescape(
            rec.cnt_html))
        writer.add_document(
            title=rec.title,
            type='<span style="color:red;">[信息]</span>',
            link='/info/{0}'.format(rec.uid),
            content=text2,
        )

    mpost = MPost()
    recs = mpost.query_all()
    for rec in recs:
        text2 = html2text.html2text(tornado.escape.xhtml_unescape(
            rec.cnt_html))
        print(text2)
        writer.add_document(title=rec.title,
                            type='<span style="color:blue;">[文档]</span>',
                            link='/post/{0}.html'.format(rec.uid),
                            content=text2)

    writer.commit()
コード例 #5
0
 def render(self, cat_id, list_num):
     self.mpost = MPost()
     recs = self.mpost.query_by_cat(cat_id, list_num)
     out_str = ''
     for rec in recs:
         tmp_str = '''<li><a href="/{0}">{1}</a></li>'''.format(rec.title, rec.title)
         out_str += tmp_str
     return out_str
コード例 #6
0
 def render(self, num, recent, with_date=True, with_catalog=True):
     self.mpost = MPost()
     recs = self.mpost.query_recent_most(num, recent)
     kwd = {
         'with_date': with_date,
         'with_catalog': with_catalog,
     }
     return self.render_string('modules/post/post_list.html', recs=recs, kwd=kwd)
コード例 #7
0
 def render(self, current_id):
     self.mpost = MPost()
     prev_record = self.mpost.get_previous_record(current_id)
     if prev_record is None:
         outstr = '<a>已经是最后一篇了</a>'
     else:
         outstr = '''<a href="/post/{0}.html">上一篇</a>'''.format(prev_record.uid, prev_record.title)
     return outstr
コード例 #8
0
 def render(self, current_id):
     self.mpost = MPost()
     next_record = self.mpost.get_next_record(current_id)
     if next_record is None:
         outstr = '<a>已经是最新一篇了</a>'
     else:
         outstr = '''<a href="/post/{0}.html">下一篇</a>'''.format(next_record.uid)
     return outstr
コード例 #9
0
ファイル: base_modules.py プロジェクト: isunspot/TorCMS
 def render(self, current_id):
     self.mpost = MPost()
     prev_record = self.mpost.get_previous_record(current_id)
     if prev_record is None:
         outstr = '<a>The last post.</a>'
     else:
         outstr = '''<a href="/post/{0}">Previous Post</a>'''.format(prev_record.uid, prev_record.title)
     return outstr
コード例 #10
0
ファイル: base_modules.py プロジェクト: isunspot/TorCMS
 def render(self, current_id):
     self.mpost = MPost()
     next_record = self.mpost.get_next_record(current_id)
     if next_record is None:
         outstr = '<a>The newest post.</a>'
     else:
         outstr = '''<a href="/post/{0}">Next Post</a>'''.format(next_record.uid)
     return outstr
コード例 #11
0
 def render(self, cat_id, num, with_date=True, with_catalog=True):
     self.mpost = MPost()
     recs = self.mpost.query_cat_random(cat_id, num)
     kwd = {
         'with_date': with_date,
         'with_catalog': with_catalog,
     }
     return self.render_string('modules/post/post_list.html',
                               recs=recs, kwd=kwd)
コード例 #12
0
    def setup(self):
        print('setup 方法执行于本类中每条用例之前')
        self.post = MPost()
        self.user = MUser()
        self.reply = MReply()

        self.post_title = 'ccc'
        self.username = '******'
        self.uid = tools.get_uu4d()
コード例 #13
0
ファイル: base_modules.py プロジェクト: isunspot/TorCMS
 def render(self, num, with_date=True, with_catalog=True):
     self.mpost = MPost()
     recs = self.mpost.query_most(num)
     kwd = {
         'with_date': with_date,
         'with_catalog': with_catalog,
         'router': router_post['1'],
     }
     return self.render_string('modules/post/post_list.html', recs=recs, kwd=kwd)
コード例 #14
0
def gen_post_map():
    mpost = MPost()
    with open(sitemap_file, 'a') as fo:
        for kind_key in router_post:
            recent_posts = mpost.query_all(kind=kind_key)
            for recent_post in recent_posts:
                url = os.path.join(SITE_CFG['site_url'],
                                   router_post[recent_post.kind],
                                   recent_post.uid)
                fo.write('{url}\n'.format(url=url))
コード例 #15
0
ファイル: test_usage.py プロジェクト: Silentsoul04/TorCMS
    def setup(self):
        print('setup 方法执行于本类中每条用例之前')

        self.postid = '12345'
        self.userid = ''
        self.uid = ''
        self.tag_id = '87hy'
        self.slug = 'qwqqq'
        self.postid2 = 'qqqew'
        self.uu = MPost()
コード例 #16
0
ファイル: post_handler.py プロジェクト: 662d7/TorCMS
 def initialize(self):
     self.init()
     self.mpost = MPost()
     self.mcat = MCategory()
     self.cats = self.mcat.query_all()
     self.mpost_hist = MPostHist()
     self.mpost2catalog = MPost2Catalog()
     self.mpost2reply = MPost2Reply()
     self.mpost2label = MPost2Label()
     self.mrel = MRelation()
コード例 #17
0
ファイル: test_relation.py プロジェクト: cherishing99/TorCMS
    def setup(self):
        print('setup 方法执行于本类中每条用例之前')
        self.uu = MPost()
        self.m2c = MPost2Catalog()

        self.app_f = 'ddss'
        self.app_t = '6122'

        self.tag_id = '6654'
        self.uid = ''
        self.slug = 'huio'
コード例 #18
0
 def render(self, num=10, with_catalog=True, with_date=True):
     self.mpost = MPost()
     recs = self.mpost.query_recent(num)
     kwd = {
         'with_date': with_date,
         'with_catalog': with_catalog,
     }
     return self.render_string('modules/post/post_list.html',
                               recs=recs,
                               unescape=tornado.escape.xhtml_unescape,
                               kwd=kwd, )
コード例 #19
0
 def initialize(self):
     self.init()
     self.mpost = MPost()
     self.mcat = MCategory()
     self.cats = self.mcat.query_all()
     self.mpost_hist = MPostHist()
     self.mpost2catalog = MPost2Catalog()
     # self.mpost2reply = MPost2Reply()
     self.mpost2label = MPost2Label()
     self.mrel = MRelation()
     self.tmpl_dir = 'admin'
     self.tmpl_router = 'post_ajax'
コード例 #20
0
 def initialize(self):
     self.init()
     self.mpost = MPost()
     self.mcat = MCategory()
     self.cats = self.mcat.query_all()
     self.mpost_hist = MPostHist()
     self.mpost2catalog = MPost2Catalog()
     self.mpost2label = MPost2Label()
     self.mrel = MRelation()
     self.tmpl_dir = 'doc'
     self.kind = '1'
     self.tmpl_router = 'post'
コード例 #21
0
    def setup(self):
        print('setup 方法执行于本类中每条用例之前')
        self.post = MPost()
        self.user = MUser()
        self.reply = MReply()
        self.r2u = MReply2User()

        self.post_title = 'fwwgccc'
        self.username = '******'
        self.user_uid = ''
        self.reply_uid = ''
        self.post_uid = '998h'
        self.password = '******'
コード例 #22
0
    def post_recent(**kwargs):
        # return "{0}".format(kwargs)

        mpost = MPost()
        recs = mpost.query_recent_most(kwargs['num'])
        kwd = {}
        #     'with_date': with_date,
        #     'with_catalog': with_catalog,
        #     'router': router_post['1'],
        # }
        # return  'Hee'
        return render_template('modules/post/post_list.html',
                               recs=recs,
                               kwd=kwd)
コード例 #23
0
 def setup(self):
     print('setup 方法执行于本类中每条用例之前')
     self.uu = MPost()
     self.m2c = MPost2Catalog()
     self.ml = MLabel()
     self.m2l = MPost2Label()
     self.labeluid = '9999'
     self.raw_count = self.uu.get_counts()
     self.post_title = 'ccc'
     self.uid = tools.get_uu4d()
     self.post_id = '66565'
     self.tag_id = '2342'
     self.post_id2 = '89898'
     self.slug = 'huio'
コード例 #24
0
ファイル: base_modules.py プロジェクト: isunspot/TorCMS
 def render(self, cat_id, num=10, with_catalog=True, with_date=True):
     self.mcat = MCategory()
     self.mpost = MPost()
     self.mpost2cat = MPost2Catalog()
     catinfo = self.mcat.get_by_uid(cat_id)
     recs = self.mpost.query_cat_recent(cat_id, num, kind = catinfo.kind)
     kwd = {
         'with_catalog': with_catalog,
         'with_date': with_date,
         'router': router_post[catinfo.kind],
     }
     return self.render_string('modules/post/post_list.html',
                               recs=recs,
                               unescape=tornado.escape.xhtml_unescape,
                               kwd=kwd, )
コード例 #25
0
    def render(self, cat_id, num=10, with_catalog=True, with_date=True, width=160, height=120):
        self.mpost = MPost()
        self.mpost2cat = MPost2Catalog()
        recs = self.mpost.query_cat_recent(cat_id, num)

        kwd = {
            'with_catalog': with_catalog,
            'with_date': with_date,
            'width': width,
            'height': height,
        }

        return self.render_string('modules/post/showout_list.html',
                                  recs=recs,
                                  unescape=tornado.escape.xhtml_unescape,
                                  kwd=kwd, )
コード例 #26
0
def do_for_post(writer, rand=True):
    mpost = MPost()
    if rand:
        recs = mpost.query_random(50)
    else:
        recs = mpost.query_recent(50)
    doc_type = '<span style="color:green;" class="glyphicon glyphicon-list-alt">[{0}]</span>'.format(
        '文档')
    print(recs.count())
    for rec in recs:
        # sleep(0.1)
        text2 = rec.title + ',' + html2text.html2text(
            tornado.escape.xhtml_unescape(rec.cnt_html))
        # writer.update_document(path=u"/a",content="Replacement for the first document")
        writer.update_document(title=rec.title,
                               type=doc_type,
                               link='/post/{0}.html'.format(rec.uid),
                               content=text2)
コード例 #27
0
def do_for_post(writer, rand=True, doc_type=''):

    mpost = MPost()
    if rand:
        recs = mpost.query_random(50)
    else:
        recs = mpost.query_recent(50)

    print(recs.count())
    for rec in recs:
        # sleep(0.1)
        text2 = rec.title + ',' + html2text.html2text(
            tornado.escape.xhtml_unescape(rec.cnt_html))
        # writer.update_document(path=u"/a",content="Replacement for the first document")
        writer.update_document(title=rec.title,
                               catid='0000',
                               type=doc_type,
                               link='/post/{0}'.format(rec.uid),
                               content=text2)
コード例 #28
0
def do_tabapp():
    print('==============================')
    print('For Infor ... ')
    from torcms.model.post_model import MPost
    from torcms.model.infor2catalog_model import MInfor2Catalog
    mpost = MPost()
    mpost2tag = MInfor2Catalog()

    from model_ent.infor_model import MInfor
    minfor = MInfor()
    info_recs = minfor.query_all(20000)
    for info_rec in info_recs:
        # print(info_rec.uid)
        # info_tag = mpost2tag.get_entry_catalog(info_rec.uid).uid
        extinfo = info_rec.extinfo
        if 'def_cat_uid' in extinfo:
            old_cat_id = extinfo['def_cat_uid']
            extinfo['def_cat_uid'] = retag(old_cat_id)
            extinfo['def_cat_pid'] = retag(old_cat_id)[:2] + '00'
        # print(extinfo['def_cat_uid'])

        post_data = {
            'title': info_rec.title,
            'user_name': info_rec.user_name,
            'logo': info_rec.logo,
            'cnt_md': unescape(info_rec.cnt_md),
            'keywords': info_rec.keywords,
            'kind': '2',
            'extinfo': extinfo,
            # 'time_create': info_rec.time_create,
            'time_update': info_rec.time_update,
        }
        # mpost.insert_data('m' + info_rec.uid, post_data)
        # print(info_rec.uid)
        mpost.add_or_update(info_rec.uid, post_data)
        if 'def_cat_uid' in extinfo:
            try:
                mpost2tag.add_record(info_rec.uid, extinfo['def_cat_uid'], 1)
            except:
                print(info_rec.title)
コード例 #29
0
ファイル: test_post_hist.py プロジェクト: Silentsoul04/TorCMS
    def addHis(self, **kwargs):
        p_d = {
            'title': kwargs.get('title', 'iiiii'),
            'cnt_md': kwargs.get('cnt_md', 'grgr'),
            'time_create': kwargs.get('time_create', '1992'),
            'time_update': kwargs.get('time_update', '1996070600'),
            'user_name': kwargs.get('user_name', 'yuanyuan'),
            'view_count': kwargs.get('view_count', 1),
            'logo': kwargs.get('logo', 'prprprprpr'),
            'memo': kwargs.get('memo', ''),
            'order': kwargs.get('order', '1'),
            'keywords': kwargs.get('keywords', ''),
            'extinfo': kwargs.get('extinfo', {}),
            'kind': kwargs.get('kind', '1'),
            'valid': kwargs.get('valid', 1),
        }
        MPost().add_meta(self.post_id, p_d)
        aa = MPost.get_by_uid(self.post_id)
        MPostHist.create_post_history(aa, aa)

        His = MPostHist.query_by_postid(self.post_id)

        self.uid = His[0].uid
コード例 #30
0
ファイル: info_modules.py プロジェクト: isunspot/TorCMS
    def render(
        self,
        uid,
        num,
    ):
        self.mpost = MPost()
        self.relation = MRelInfor2Post()
        kwd = {
            'app_f': 'info',
            'app_t': 'post',
            'uid': uid,
        }
        rel_recs = self.relation.get_app_relations(uid, num, kind='1')

        rand_recs = self.mpost.query_random(num - rel_recs.count() + 2,
                                            kind='1')

        return self.render_string(
            'modules/info/relation_app2post.html',
            relations=rel_recs,
            rand_recs=rand_recs,
            kwd=kwd,
        )