예제 #1
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(
            '{0}/modules/showout_list.html'.format(
                config.torlite_template_name),
            recs=recs,
            unescape=tornado.escape.xhtml_unescape,
            kwd=kwd,
        )
예제 #2
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('tplite/modules/post_list.html', recs=recs, kwd=kwd)
예제 #3
0
 def render(self, current_id):
     self.mpost = MPost()
     prev_record = self.mpost.get_previous_record(current_id)
     if prev_record is None:
         outstr = '已经是最后一篇了'
     else:
         outstr = '''<a href="/post/{0}.html">上一篇</a>'''.format(prev_record.uid, prev_record.title)
     return outstr
예제 #4
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
예제 #5
0
 def render(self, current_id):
     self.mpost = MPost()
     next_record = self.mpost.get_next_record(current_id)
     if next_record is None:
         outstr = '已经是最新一篇了'
     else:
         outstr = '''<a href="/post/{0}.html">下一篇</a>'''.format(next_record.uid)
     return outstr
예제 #6
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('tplite/modules/post_list.html', recs=recs, kwd=kwd)
예제 #7
0
    def initialize(self):

        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost2catalog = MPost2Catalog()
def do1():
    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:green;">[文档]</span>',
                            link='/post/{0}.html'.format(rec.uid),
                            content=text2)
예제 #9
0
 def initialize(self):
     self.init()
     self.mpost = MPost()
     self.mcat = MCatalog()
     self.cats = self.mcat.query_all()
     self.mpost_hist = MPostHist()
     self.mpost2catalog = MPost2Catalog()
     self.mpost2reply = MPost2Reply()
     self.mapp2tag = MPost2Label()
     self.mrel = MRelation()
     self.tmpl_router = 'post'
예제 #10
0
 def initialize(self):
     self.muser = MUser()
     self.mpage = MPage()
     self.mdb = MPost()
     self.mcat = MCatalog()
     self.cats = self.mcat.query_all()
     self.mspec = SpesubModel()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
예제 #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('{0}/modules/post_list.html'.format(
         config.torlite_template_name),
                               recs=recs,
                               kwd=kwd)
예제 #12
0
 def render(self, cat_id, num=10, with_catalog=True, with_date=True):
     self.mpost = MPost()
     self.mpost2cat = MPost2Catalog()
     # recs = self.mpost2cat.query_by_catid(cat_id)
     recs = self.mpost.query_cat_recent(cat_id, num)
     kwd = {
         'with_catalog': with_catalog,
         'with_date': with_date,
     }
     return self.render_string('tplite/modules/post_list.html',
                               recs=recs,
                               kwd=kwd, )
예제 #13
0
    def initialize(self):
        self.mapp = MApp()
        self.mpost = MPost()
        self.rel_post2app = MRelPost2App()
        self.rel_app2post = MRelApp2Post()
        self.muser = MUser()

        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
            self.mvip = None
예제 #14
0
def do1():
    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:green;">[文档]</span>',
            link='/post/{0}.html'.format(rec.uid),
            content=text2
        )
예제 #15
0
 def initialize(self):
     self.muser = MUser()
     self.mpost = MPost()
     self.mcat = MCatalog()
     self.cats = self.mcat.query_all()
     self.mspec = SpesubModel()
     self.specs = self.mspec.get_all()
     self.mpost_hist = MPostHist()
     self.mpost2catalog = MPost2Catalog()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
예제 #16
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(
         '{0}/modules/post_list.html'.format(config.torlite_template_name),
         recs=recs,
         unescape=tornado.escape.xhtml_unescape,
         kwd=kwd,
     )
예제 #17
0
def do_for_post(writer):
    mpost = MPost()
    # 下面这个在 PostgreSQL 中出错
    # recs = mpost.query_all()
    recs = mpost.query_recent(2000)
    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:green;" class="glyphicon glyphicon-list-alt">[文档]</span>',
            link='/post/{0}.html'.format(rec.uid),
            content=text2)
예제 #18
0
class showout_recent(tornado.web.UIModule):
    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.mpost2cat.query_by_catid(cat_id)
        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(
            'tplite/modules/showout_list.html',
            recs=recs,
            kwd=kwd,
        )
예제 #19
0
 def initialize(self):
     self.init()
     self.mpost = MPost()
     self.mcat = MCatalog()
     self.cats = self.mcat.query_all()
     self.mpost2catalog = MPost2Catalog()
     self.ysearch = yunsearch()
예제 #20
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('tplite/modules/post_list.html', recs=recs, kwd=kwd)
예제 #21
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('tplite/modules/post_list.html', recs=recs, kwd=kwd)
예제 #22
0
파일: modef.py 프로젝트: vaveee/TorCMS
 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
예제 #23
0
파일: modef.py 프로젝트: vaveee/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>已经是最后一篇了</a>'
     else:
         outstr = '''<a href="/post/{0}.html">上一篇</a>'''.format(prev_record.uid, prev_record.title)
     return outstr
예제 #24
0
파일: modef.py 프로젝트: vaveee/TorCMS
 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('{0}/modules/post_list.html'.format(config.torlite_template_name), recs=recs, kwd=kwd)
예제 #25
0
 def initialize(self):
     self.mpost = MPost()
     self.mcat = MCatalog()
     self.muser = MUser()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
예제 #26
0
파일: modef.py 프로젝트: vaveee/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>已经是最新一篇了</a>'
     else:
         outstr = '''<a href="/post/{0}.html">下一篇</a>'''.format(next_record.uid)
     return outstr
예제 #27
0
class post_most_view(tornado.web.UIModule):
    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,
        }
        return self.render_string('tplite/modules/post_list.html', recs=recs, kwd=kwd)
예제 #28
0
class previous_post_link(tornado.web.UIModule):
    def render(self, current_id):
        self.mpost = MPost()
        prev_record = self.mpost.get_previous_record(current_id)
        if prev_record is None:
            outstr = '已经是最后一篇了'
        else:
            outstr = '''<a href="/post/{0}.html">上一篇</a>'''.format(prev_record.uid, prev_record.title)
        return outstr
예제 #29
0
파일: index_app.py 프로젝트: wyf379/maplet
 def initialize(self):
     self.mpost = MPost()
     self.mcat = MCatalog()
     self.muser = MUser()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
     self.tmpl_sig = app_template_name
예제 #30
0
파일: modef.py 프로젝트: vaveee/TorCMS
class post_cat_random(tornado.web.UIModule):
    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('{0}/modules/post_list.html'.format(config.torlite_template_name), recs=recs, kwd=kwd)
예제 #31
0
    def initialize(self):
        self.init()
        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        self.mpost2reply = MPost2Reply()
        self.mapp2tag = MPost2Label()
        self.mrel = MRelation()

        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
예제 #32
0
class next_post_link(tornado.web.UIModule):
    def render(self, current_id):
        self.mpost = MPost()
        next_record = self.mpost.get_next_record(current_id)
        if next_record is None:
            outstr = '已经是最新一篇了'
        else:
            outstr = '''<a href="/post/{0}.html">下一篇</a>'''.format(next_record.uid)
        return outstr
예제 #33
0
class post_most_view(tornado.web.UIModule):
    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,
        }
        return self.render_string('tplite/modules/post_list.html', recs=recs, kwd=kwd)
예제 #34
0
class IndexHandler(tornado.web.RequestHandler):
    def initialize(self):
        self.mpost = MPost()
        self.mcat = MCatalog()

    def get(self, input=''):
        if input == '':
            self.index()
        else:
            self.render('/html/404.html')

    def index(self):
        dbdata = self.mpost.query_cat_recent(5, 16)
        recent = self.mpost.query_recent(8)
        self.render('tplite/index/index.html',
                    view=dbdata,
                    recent=recent,
                    unescape=tornado.escape.xhtml_unescape,
                    format_yr=tools.format_yr)
예제 #35
0
class next_post_link(tornado.web.UIModule):
    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
예제 #36
0
class previous_post_link(tornado.web.UIModule):
    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
예제 #37
0
파일: index.py 프로젝트: maplet/TorCMS
    def initialize(self):
        self.mpost = MPost()
        self.mapp = torapp.model.app_model.MApp()

        self.mcat = MCatalog()
        self.muser = MUser()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
예제 #38
0
 def initialize(self):
     self.init()
     self.muser = MUser()
     self.mequa = MPost()
     self.mtag = MLabel()
     self.mapp2tag = MPost2Label()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
예제 #39
0
 def initialize(self):
     self.init()
     self.muser = MUser()
     self.mpost = MPost()
     self.mcat = MCatalog()
     self.cats = self.mcat.query_all()
     self.mpost2catalog = MPost2Catalog()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
예제 #40
0
파일: modef.py 프로젝트: vaveee/TorCMS
 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('{0}/modules/post_list.html'.format(config.torlite_template_name),
                               recs=recs,
                               unescape=tornado.escape.xhtml_unescape,
                               kwd=kwd, )
예제 #41
0
 def initialize(self):
     self.muser = MUser()
     self.mpage = MPage()
     self.mdb = MPost()
     self.mcat = MCatalog()
     self.cats = self.mcat.query_all()
     self.mspec = SpesubModel()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
예제 #42
0
 def initialize(self):
     self.init()
     self.mpost = MPost()
     self.mcat = MCatalog()
     self.cats = self.mcat.query_all()
     self.mpost_hist = MPostHist()
     self.mpost2catalog = MPost2Catalog()
     self.mpost2reply = MPost2Reply()
     self.mapp2tag = MPost2Label()
     self.mrel = MRelation()
     self.tmpl_router = 'post'
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()

    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()
예제 #44
0
파일: modef.py 프로젝트: daimon99/TorCMS
 def render(self, cat_id, num=10, with_catalog=True, with_date=True):
     self.mpost = MPost()
     self.mpost2cat = MPost2Catalog()
     recs = self.mpost.query_cat_recent(cat_id, num)
     kwd = {
         'with_catalog': with_catalog,
         'with_date': with_date,
     }
     return self.render_string('{0}/modules/post_list.html'.format(config.torlite_template_name),
                               recs=recs,
                               kwd=kwd, )
예제 #45
0
    def initialize(self):
        self.mapp = MApp()
        self.mpost = MPost()
        self.rel_post2app = MRelPost2App()
        self.rel_app2post = MRelApp2Post()
        self.muser = MUser()

        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
            self.mvip = None
예제 #46
0
class post_most_view(tornado.web.UIModule):
    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,
        }
        return self.render_string('{0}/modules/post_list.html'.format(
            config.torlite_template_name),
                                  recs=recs,
                                  kwd=kwd)
예제 #47
0
 def render(self, cat_id, num=10, with_catalog=True, with_date=True):
     self.mpost = MPost()
     self.mpost2cat = MPost2Catalog()
     # recs = self.mpost2cat.query_by_catid(cat_id)
     recs = self.mpost.query_cat_recent(cat_id, num)
     kwd = {
         'with_catalog': with_catalog,
         'with_date': with_date,
     }
     return self.render_string('tplite/modules/post_list.html',
                               recs=recs,
                               kwd=kwd, )
예제 #48
0
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()

    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()
예제 #49
0
class CategoryHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost2catalog = MPost2Catalog()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None

    def get(self, input=''):
        if len(input) > 0:
            ip_arr = input.split(r'/')
        if input == '':
            pass
        elif len(ip_arr) == 1:
            self.list_catalog(input)
        elif len(ip_arr) == 2:
            self.list_catalog(ip_arr[0], ip_arr[1])
        else:
            self.render('html/404.html')

    def list_catalog(self, cat_slug, cur_p=''):
        if cur_p == '':
            current_page_num = 1
        else:
            current_page_num = int(cur_p)

        cat_rec = self.mcat.get_by_slug(cat_slug)
        num_of_cat = self.mpost2catalog.catalog_record_number(cat_rec.uid)
        page_num = int(num_of_cat / config.page_num) + 1
        cat_name = cat_rec.name
        kwd = {
            'cat_name': cat_name,
            'cat_slug': cat_slug,
            'unescape': tornado.escape.xhtml_unescape,
            'title': cat_name,
        }

        self.render('{0}/catalog/list.html'.format(self.tmpl_name),
                    infos=self.mpost2catalog.query_pager_by_slug(cat_slug, current_page_num),
                    pager=tools.gen_pager_purecss('/category/{0}'.format(cat_slug), page_num, current_page_num),
                    userinfo=self.userinfo,
                    kwd=kwd)

    def get_random(self):
        return self.mpost.query_random()
예제 #50
0
파일: extends.py 프로젝트: ironhot/maplet
    def render(self, uid, num, ):
        self.mpost = MPost()
        self.relation = MRelApp2Post()
        kwd = {
            'app_f': app_url_name,
            'app_t': 'post',
            'uid': uid,
        }
        rel_recs = self.relation.get_app_relations(uid, num)

        rand_recs = self.mpost.query_random(num - rel_recs.count() + 2)

        return self.render_string('app_theme/modules/relation_app2post.html',
                                  relations= rel_recs,
                                  rand_recs = rand_recs,
                                  kwd=kwd, )
예제 #51
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.mpost2cat.query_by_catid(cat_id)
        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('tplite/modules/showout_list.html',
                                  recs=recs,
                                  kwd=kwd, )
예제 #52
0
파일: modef.py 프로젝트: vaveee/TorCMS
    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('{0}/modules/showout_list.html'.format(config.torlite_template_name),
                                  recs=recs,
                                  unescape=tornado.escape.xhtml_unescape,
                                  kwd=kwd, )
예제 #53
0
class CategoryHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mpost2catalog = MPost2Catalog()


    def get(self, url_str=''):
        url_arr = self.parse_url(url_str)

        if len(url_arr) == 1:
            self.list_catalog(url_str)
        elif len(url_arr) == 2:
            self.list_catalog(url_arr[0], url_arr[1])
        else:
            self.render('html/404.html')

    def list_catalog(self, cat_slug, cur_p=''):
        if cur_p == '':
            current_page_num = 1
        else:
            current_page_num = int(cur_p)

        current_page_num = 1 if current_page_num < 1 else current_page_num
        cat_rec = self.mcat.get_by_slug(cat_slug)
        num_of_cat = self.mpost2catalog.catalog_record_number(cat_rec.uid)
        page_num = int(num_of_cat / config.page_num) + 1
        cat_name = cat_rec.name
        kwd = {
            'cat_name': cat_name,
            'cat_slug': cat_slug,
            'unescape': tornado.escape.xhtml_unescape,
            'title': cat_name,
            'current_page': current_page_num
        }

        self.render('{0}/catalog/list.html'.format(self.tmpl_name),
                    infos=self.mpost2catalog.query_pager_by_slug(cat_slug, current_page_num),
                    pager=tools.gen_pager_purecss('/category/{0}'.format(cat_slug), page_num, current_page_num),
                    userinfo=self.userinfo,
                    cfg = config.cfg,
                    kwd=kwd)

    def get_random(self):
        return self.mpost.query_random()
예제 #54
0
    def initialize(self):
        self.init()
        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        self.mpost2reply = MPost2Reply()
        self.mapp2tag = MPost2Label()
        self.mrel = MRelation()
        self.tmpl_router = 'post'

        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
예제 #55
0
class CatHandler(BaseHandler):
    def initialize(self):

        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost2catalog = MPost2Catalog()

    def get(self, input=''):
        if len(input) > 0:
            ip_arr = input.split(r'/')
        if input == '':
            pass
        elif len(ip_arr) == 1 :
            self.list_catalog(input)
        elif len(ip_arr) == 2:
            self.list_catalog(ip_arr[0], ip_arr[1])
        else:
            self.render('/html/404.html')

    def list_catalog(self, cat_slug, cur_p = ''):
        if cur_p == '':
            current_page_num = 1
        else:
            current_page_num = int(cur_p)

        cat_rec = self.mcat.get_by_slug(cat_slug)
        num_of_cat = self.mpost2catalog.catalog_record_number(cat_rec.uid)
        page_num = int(num_of_cat / config.page_num ) + 1
        cat_name = cat_rec.name
        kwd = {
             'cat_name': cat_name,
             'cat_slug': cat_slug,
             'unescape':  tornado.escape.xhtml_unescape,
             'title': cat_name,
        }

        self.render('tplite/catalog/list.html',
                    infos=self.mpost2catalog.query_pager_by_slug(cat_slug,current_page_num),
                    pager = tools.gen_pager(cat_slug, page_num, current_page_num),
                    kwd=kwd)

    # def view_cat_old(self, cat_slug, cur_p=''):
    #     if cur_p == '':
    #         current = 1
    #     else:
    #         current = int(cur_p)
    #
    #     cat_rec = self.mcat.get_by_slug(cat_slug)
    #     num_of_cat = self.mpost.get_num_by_cat(cat_rec.id_cat)
    #     page_num = int(num_of_cat / config.page_num ) + 1
    #
    #     cat_name = cat_rec.name
    #     kwd = {
    #         'cat_name': cat_name,
    #         'cat_slug': cat_slug,
    #         'unescape':  tornado.escape.xhtml_unescape,
    #         'pager': tools.gen_pager(cat_slug, page_num, current),
    #         'title': cat_name,
    #     }
    #     for x in self.cats:
    #         if x.slug == cat_slug:
    #             search_str = ',{0},'.format(x.id_cat)
    #     dbdata = self.mpost.query_cat_by_pager(search_str, current)
    #     self.render('tplite/post/all.html',
    #                 kwd = kwd,
    #                 view=dbdata,
    #                 rand_recs = self.get_random(),
    #                 format_date = tools.format_date)



    def get_random(self):
        return self.mpost.query_random()
예제 #56
0
            u = u.strip()
            if len(u) > 0:
                tt = u.split()
                out_arr.append(tt)
    return (out_arr)

def do_for_x(rec):
    kw_dic = get_dic()
    out_dic = {}
    for kw in kw_dic:
        count = rec.title.count(kw[0])
        count2 = rec.cnt_md.count(kw[0])
        if count > 0:
            out_dic[kw[0]] = count * .3 + count2 * .2 + int(kw[1]) * .5
    out_dic2 = sorted(out_dic.items(), key = lambda asd:asd[1], reverse=True)
    return (out_dic2[:8])

if __name__ == '__main__':
    mpost = MPost()
    uu = mpost.query_keywords_empty()
    if uu.count() > 0: 
        for x in uu:
            tt = (do_for_x(x))
            vv = [x[0] for x in tt]
            if len(vv) > 0:
                print(','.join(vv))
                mpost.update_keywords(x.uid, ','.join(vv))
            else:
                mpost.update_keywords(x.uid, '开放地理空间实验室')