How to use the summer.model.entry.Entry.get_all_published 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_posts():
    lookup = TemplateLookup(directories=[TEMPLATE_DIR])
    template = Template(
        filename=TEMPLATE_DIR + '/entry.html', lookup=lookup)

    entries = Entry.get_all_published()

    for _entry in entries:
        post_title = _entry['title']
        post_content = markdown(_entry['content'])
        post_slug = _entry['slug']
        date = _entry['date']
        status = _entry['status']

        entry = dict(
            title=post_title,
            content=post_content,
            date=date,
            id=_entry['slug'],
            status=status
        )
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)
github gaowhen / summer / summer / view / build / build.py View on Github external
def build_feed():
    feed = AtomFeed(current_app.config['SITE_NAME'],
                    feed_url=current_app.config['DOMAIN'] + 'rss.xml',
                    url=current_app.config['DOMAIN'],
                    subtitle=current_app.config['SUBTITLE'],
                    author=current_app.config['AUTHOR'],
                    updated=datetime.datetime.now())

    entries = Entry.get_all_published()

    for _entry in entries:
        time = datetime.datetime.strptime(_entry['date'], '%Y-%m-%d %H:%M:%S')

        feed.add(unicode(_entry['title']),
                 unicode(markdown(_entry['content'])),
                 content_type='html',
                 author=current_app.config['AUTHOR'],
                 published=time,
                 updated=time,
                 id=current_app.config['DOMAIN'] + _entry['slug'] + '/',
                 url=current_app.config['DOMAIN'] + 'posts/' + _entry['slug'] + '/'
                 )

    with codecs.open(BASE_DIR + '/rss.xml', 'w', 'utf-8-sig') as f:
        f.write(feed.to_string())
github gaowhen / summer / summer / view / build / build.py View on Github external
def build_pages():
    lookup = TemplateLookup(directories=[TEMPLATE_DIR])
    template = Template(
        filename=TEMPLATE_DIR + '/index.html', lookup=lookup)

    all_entries = Entry.get_all_published(True)
    length = len(all_entries)

    for page in range(1, int(math.ceil(length / float(5))) + 1):
        start = (page - 1) * 5
        end = start + 5

        entries = all_entries[start:end]

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

        page_path = os.path.join(PAGE_DIR, str(page))

        try:
            os.mkdir(page_path)
        except OSError: