Ejemplo n.º 1
0
    def build_categories(self):
        """No paging
        """
        for category in self._categories:
            posts = self._posts.re_group(group_by_category(category))

            # insert sub-category to posts
            cate_node = self._node_list.get('_'.join(['category', category]),
                                            None)
            sub_cates = []
            for node in cate_node._childern:
                if node._type == 'category':
                    cate = {
                        "title":
                        node._title,
                        "permalink":
                        self._router.gen_permalink('category', node._slug)
                    }
                    sub_cates.insert(0, cate)

            current_route, local_path = self._router.gen(
                "category", category, 1)
            local_path += "index.html"

            template = self._env.get_template("categories.html")
            output = template.render(current_route=current_route,
                                     cate_name=category,
                                     sub_cates=sub_cates,
                                     content_list=posts)
            safe_write(local_path, output)
Ejemplo n.º 2
0
    def build_categories(self):
        for category in self._categories:
            posts = self._posts.re_group(group_by_category(category))

            pager = Pager(posts, self._config.archives_page_size)
            total_pages = pager.get_total_pages()

            for current_page, current_list in pager:
                _, local_path = self._router.gen("category", category,
                                                 current_page)
                local_path += "index.html"

                template = self._env.get_template("categories.html")
                output = template.render(cate_name=category,
                                         content_list=current_list,
                                         current_page=current_page,
                                         max_pages=total_pages)
                safe_write(local_path, output)
Ejemplo n.º 3
0
    def build_categories(self):
        for category in self._categories:
            posts = self._posts.re_group(group_by_category(category))

            page_size = self._config.archives_page_size
            total_pages = math.ceil(len(posts) / page_size)

            for page in range(0, total_pages):
                current_list = \
                    posts[page * page_size:min(
                        (page+1)*page_size, len(posts))]

                _, local_path = self._router.gen("category", category,
                                                 page + 1)
                local_path += "index.html"

                template = self._env.get_template("categories.html")
                output = template.render(cate_name=category,
                                         content_list=current_list,
                                         current_page=page + 1,
                                         max_pages=total_pages)
                safe_write(local_path, output)