How to use the summer.model.entry.Entry.get_published_page function in summer

To help you get started, we’ve selected a few summer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gaowhen / summer / summer / view / build / build.py View on Github external
def build_index():
    lookup = TemplateLookup(directories=[TEMPLATE_DIR])
    template = Template(
        filename=TEMPLATE_DIR + '/index.html', lookup=lookup)

    page = 1
    perpage = 5
    entries = Entry.get_published_page(page)

    total = len(Entry.get_all_published())

    html_content = template.render(
        entries=entries, total=total, page=page, perpage=perpage)

    dist = os.path.join(BASE_DIR, 'index.html')

    with codecs.open(dist, 'w', 'utf-8-sig') as f:
        f.write(html_content)