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.count_of_certain_catalog(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, } return self.render_string( 'doc/modules/catalog_pager.html', kwd=kwd, cat_slug=cat_slug, pager_num=page_num, page_current=current, )
def render(self, post_id): tmpl_str = '''<a href="/category/{0}">{1}</a>''' format_arr = [ tmpl_str.format(uu.catalog.slug, uu.catalog.name) for uu in MPost2Catalog().query_entry_catalog(post_id) ] return ', '.join(format_arr)
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.mpost2label = MPost2Label() self.mrel = MRelation()
def render(self, signature): self.mapp2tag = MPost2Catalog() tag_infos = self.mapp2tag.query_by_entry_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
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( 'doc/modules/post_list.html', recs=recs, unescape=tornado.escape.xhtml_unescape, kwd=kwd, )
def initialize(self): self.init() self.mpost = MPost() self.mcat = MCatalog() self.cats = self.mcat.query_all() self.mpost2catalog = MPost2Catalog()