Esempio n. 1
0
def write_index_page(builder):
    use_pagination = builder.config.root_get("modules.blog.use_pagination", True)
    per_page = builder.config.root_get("modules.blog.per_page", 10)
    entries = get_all_entries(builder)
    pagination = Pagination(builder, entries, 1, per_page, "blog_index")
    while 1:
        with builder.open_link_file("blog_index", page=pagination.page) as f:
            rv = builder.render_template(
                "blog/index.html", {"pagination": pagination, "show_pagination": use_pagination}
            )
            f.write(rv.encode("utf-8") + "\n")
            if not use_pagination or not pagination.has_next:
                break
            pagination = pagination.get_next()
Esempio n. 2
0
def write_index_page(builder):
    use_pagination = builder.config.root_get('modules.blog.use_pagination', True)
    per_page = builder.config.root_get('modules.blog.per_page', 10)
    entries = get_all_entries(builder)
    pagination = Pagination(builder, entries, 1, per_page, 'blog_index')
    while 1:
        with builder.open_link_file('blog_index', page=pagination.page) as f:
            rv = builder.render_template('blog/index.html', {
                'pagination':       pagination,
                'show_pagination':  use_pagination
            })
            f.write(rv.encode('utf-8') + '\n')
            if not use_pagination or not pagination.has_next:
                break
            pagination = pagination.get_next()
Esempio n. 3
0
def write_index_page(builder):
    use_pagination = builder.config.root_get('modules.blog.use_pagination', True)
    per_page = builder.config.root_get('modules.blog.per_page', 10)
    entries = get_all_entries(builder)
    pagination = Pagination(builder, entries, 1, per_page, 'blog_index')
    while 1:
        with builder.open_link_file('blog_index', page=pagination.page) as f:
            rv = builder.render_template('blog/index.html', {
                'pagination':       pagination,
                'show_pagination':  use_pagination
            })
            f.write(rv.encode('utf-8') + '\n')
            if not use_pagination or not pagination.has_next:
                break
            pagination = pagination.get_next()
Esempio n. 4
0
def write_author_page(builder, author):
    use_pagination = builder.config.root_get('modules.blog.use_pagination', True)
    per_page = builder.config.root_get('modules.blog.per_page', 10)
    entries = get_authored_entries(builder, author)
    entries.sort(key=lambda x: x.pub_date, reverse=True)
    pagination = Pagination(
        builder, entries, 1, per_page, 'author', {'author': author.name})
    while True:
        with builder.open_link_file(
                'author', author=author.name, page=pagination.page) as f:
            rv = builder.render_template('author.html', {
                'author':           author,
                'pagination':       pagination,
                'show_pagination':  use_pagination,
            })
            f.write(rv.encode('utf-8') + '\n')
            if not use_pagination or not pagination.has_next:
                break
            pagination = pagination.get_next()
Esempio n. 5
0
def write_author_page(builder, author):
    use_pagination = builder.config.root_get('modules.blog.use_pagination',
                                             True)
    per_page = builder.config.root_get('modules.blog.per_page', 10)
    entries = get_authored_entries(builder, author)
    entries.sort(key=lambda x: x.pub_date, reverse=True)
    pagination = Pagination(builder, entries, 1, per_page, 'author',
                            {'author': author.name})
    while True:
        with builder.open_link_file('author',
                                    author=author.name,
                                    page=pagination.page) as f:
            rv = builder.render_template(
                'author.html', {
                    'author': author,
                    'pagination': pagination,
                    'show_pagination': use_pagination,
                })
            f.write(rv.encode('utf-8') + '\n')
            if not use_pagination or not pagination.has_next:
                break
            pagination = pagination.get_next()