示例#1
0
文件: views.py 项目: dmdm/PySite
 def _view_tag(self):
     if len(self._sp) == 1:
         data = self.cache.list_tags()
         fn = os.path.join(safepath(self.context.site.rc['blog.theme']),
             'list_page.jinja2')
         html = self._page.get_page(fn, jjglobals={
             'data': data,
             'list_kind': 'Tags',
             'url_prefix': 'tag/'
         })
         return Response(html)
     else:
         try:
             n = int(self._sp[-1])
         except ValueError:
             self._sp.append('1')
             n = 1
         tag = '/'.join(self._sp[1:-1])
         data = self.cache.get_tag_page(tag, n)
         self._render_data(data)
         fn = os.path.join(safepath(self.context.site.rc['blog.theme']),
             'index_page.jinja2')
         link_prev, link_next = self._build_prev_next_links(self._sp[:])
         html = self._page.get_page(fn, jjglobals={
             'data': data,
             'index_kind': 'Tag',
             'index_name': tag,
             'index_page': n,
             'link_prev': link_prev,
             'link_next': link_next
         })
         return Response(html)
示例#2
0
文件: views.py 项目: dmdm/PySite
 def _view_article(self):
     data = self.cache.get_article_by_slugparts(self._sp)
     self._render_data(data)
     fn = os.path.join(safepath(self.context.site.rc['blog.theme']),
         'article.jinja2')
     html = self._page.get_page(fn, jjglobals={'data': data})
     return Response(html)
示例#3
0
文件: models.py 项目: dmdm/PySite
    def __init__(self, parent, site, name):
        self.__parent__ = parent
        self.__name__ = name
        self.site = site
        self.rc = {}
        self.dir_ = os.path.join(site.dir_, safepath(site.rc['blog.theme']))

        if parent == site:
            self.slugparts = ['index', '1']
        else:
            sp = [name]
            o = parent
            while o != site:
                sp.append(o.__name__)
                o = o.__parent__
            self.slugparts = list(reversed(sp[:-1]))