示例#1
0
 def _mkUL(self, n, exclude, depth):
     if not depth is None and depth <= 0:
         return
     itms = []
     if self.currentActive:
         rootpath = [state.page]
     else:
         rootpath = list(self._indexPathToRoot(state.page, exclude))
     for p in n:
         if p in exclude:
             continue
         if p.title:
             if p in rootpath:
                 klass = self.activeClass
             else:
                 klass = self.inactiveClass
             if p.internal:
                 itms.append(html.LI(html.A(p.title), _class=klass))
             else:
                 itms.append(html.LI(model.LinkTo(p), _class=klass))
         if p.children:
             if not depth is None:
                 d = self._mkUL(p.children, exclude, depth - 1)
             else:
                 d = self._mkUL(p.children, exclude, None)
             if d:
                 itms.append(d)
     return html.UL(itms)
示例#2
0
 def __str__(self):
     trail = self.node.pathToRoot()
     trailList = []
     for crumb in trail:
         if crumb.structural:
             if crumb.internal:
                 trailList.append(crumb.name)
             else:
                 trailList.append(unicode(model.LinkTo(crumb.path)))
     trailList.reverse()
     return " -> ".join(trailList)
示例#3
0
 def _makeList(self, posts, num, title):
     monthyear = None
     output = html.DIV(_class=self.CSS_PREFIX)
     output.addChild(html.H2(title))
     postlst = []
     for i in posts:
         if not num:
             break
         if not i.url:
             postlst.append(
                 html.Group(
                     html.SPAN(model.LinkTo(i),
                               _class="%s-post" % self.CSS_PREFIX), " ",
                     html.SPAN(i.time.strftime("%d %b %Y"),
                               _class="%s-date" % self.CSS_PREFIX)))
             num -= 1
     if postlst:
         output.addChild(html.UL(postlst))
         return output
     else:
         return ""
示例#4
0
 def _getArchive(self):
     monthyear = None
     output = html.DIV(_class="archive")
     postlst = []
     for i in self.blog.blogdir.sortedPosts():
         if "draft" in i.options:
             continue
         my = i.time.strftime("%B %Y")
         if my != monthyear:
             if postlst:
                 output.addChild(html.UL(postlst))
                 postlst = []
             monthyear = my
             output.addChild(html.H1(monthyear))
         postlst.append(
             html.Group(
                 html.SPAN(model.LinkTo(i), _class="archive-post"), " ",
                 html.SPAN(i.time.strftime("%d %b %Y"),
                           _class="archive-date")))
     if postlst:
         output.addChild(html.UL(postlst))
     return output
示例#5
0
    def __unicode__(self):
        with utils.InDir(os.path.dirname(self.src)):
            if self.post.url:
                title = html.A(self.post.title, href=self.post.url)
            else:
                title = model.LinkTo(self.post)
            posttime = self.post.time.strftime("%d %B %Y")
            links = Links(self.post.findAttr("markup"))
            postbody = template.Template(self.post.findAttr("markup"),
                                         self.post.data,
                                         links=links)
            postfixes = self.postfixes
            t = template.Template(
                None,
                file(utils.data.path("resources/post.html")).read(),
                title=title,
                posttime=posttime,
                postdata=postbody,
                by=self.post.by,
                postfixes=[i() for i in postfixes])

            return unicode(t)