예제 #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 initialize(self):
     self.init()
     self.mpost = MPost()
     self.mcat = MCatalog()
     self.cats = self.mcat.query_all()
     self.mpost2catalog = MPost2Catalog()
     self.ysearch = yunsearch()
예제 #3
0
파일: modef.py 프로젝트: hitrustnet/TorCMS
    def render(self, *args, **kwargs):
        self.mpost2catalog = MPost2Catalog()
        self.mcat = MCatalog()

        cat_slug = args[0]
        current = int(args[1])
        # cat_slug 分类
        # current 当前页面

        cat_rec = self.mcat.get_by_slug(cat_slug)
        num_of_cat = self.mpost2catalog.catalog_record_number(cat_rec.uid)

        tmp_page_num = int(num_of_cat / config.page_num)

        page_num = tmp_page_num if abs(
            tmp_page_num -
            num_of_cat / config.page_num) < 0.1 else tmp_page_num + 1

        kwd = {
            'page_home': False if current <= 1 else True,
            'page_end': False if current >= page_num else True,
            'page_pre': False if current <= 1 else True,
            'page_next': False if current >= page_num else True,
        }

        print(kwd)

        return self.render_string(
            '{0}/modules/catalog_pager.html'.format(
                config.torlite_template_name),
            kwd=kwd,
            cat_slug=cat_slug,
            pager_num=page_num,
            page_current=current,
        )
예제 #4
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()
예제 #5
0
 def render(self, post_id):
     self.mpost2cat = MPost2Catalog()
     current_record = self.mpost2cat.query_catalog(post_id)
     outstr = ''
     for uu in current_record:
         tmp_str = '''<a href="/category/{0}">{1}</a>'''.format(uu.catalog.slug, uu.catalog.name)
         outstr += tmp_str
     return outstr
예제 #6
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'
예제 #7
0
 def render(self, signature):
     self.mapp2tag = MPost2Catalog()
     tag_infos = self.mapp2tag.query_by_app_uid(signature)
     out_str = ''
     ii = 1
     for tag_info in tag_infos:
         tmp_str = '<a href="/category/{0}" class="tag{1}">{2}</a>'.format(
             tag_info.catalog.slug, ii, tag_info.catalog.name)
         out_str += tmp_str
         ii += 1
     return out_str
예제 #8
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, )
예제 #9
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.mpost2catalog = MPost2Catalog()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
예제 #10
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
예제 #11
0
    def initialize(self):
        # analyzer = ChineseAnalyzer()
        # schema = Schema(title=TEXT(stored=True, analyzer = analyzer), path=ID(stored=True), content=TEXT(stored=True, analyzer=analyzer))
        # ix = config.ix
        # self.searcher = config.searcher
        # self.parser = config.parser
        # self.parser = QueryParser("content", schema=ix.schema)

        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
예제 #12
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,
        )
예제 #13
0
__author__ = 'bukun'

import sys

from torlite.model.mcatalog import MCatalog
from maplet.model.app2catalog_model import MApp2Catalog
from torlite.model.mpost2catalog import MPost2Catalog

if __name__ == '__main__':
    mapp2tag = MApp2Catalog()
    mpost2cat = MPost2Catalog()
    mcat = MCatalog()
    for x in mapp2tag.query_count():
        mcat.update_app_catalog_num(x.catalog.uid, x.num)

    for x in mpost2cat.query_count():
        print(x.catalog.uid, x.num)
        mcat.update_post_catalog_num(x.catalog.uid, x.num)