Example #1
0
def sitemap():
    pages = []
    for p in Post.published():
        pages.append({'url': url_for('.post', slug=p.slug, _external=True),
                      'last_modified': p.utc_pub_date,
                      })
    # FIXME: Be lazy with the semistatic pages and categories for the moment
    awhile_ago = arrow.utcnow().replace(days=-10)
    for cat in Category.query.all():
        pages.append({'url': url_for('.category', slug=cat.title.lower(), _external=True),
                      'last_modified': awhile_ago,
                      })
    for page in ('about', 'projects'):
        pages.append({'url': url_for('.semistatic', page=page, _external=True),
                      'last_modified': awhile_ago,
                      })
    posts = (Post.query
             .filter(Post.utc_pub_date < arrow.utcnow().datetime)
             .filter_by(status=Post.PUBLISHED).count())
    last_pub_date = Post.published().order_by(Post.utc_pub_date.desc())[0].utc_pub_date
    for archive_page in xrange(posts / POSTS_PER_ARCHIVE_PAGE):
        pages.append({'url': url_for('.archive', page=archive_page + 1, _external=True),
                      'last_modified': last_pub_date,
                      })
    return render_template('sitemap.xml', pages=pages)
Example #2
0
def raw_feed():
    feed = AtomFeed('bitquabit', feed_url=request.url,
                    subtitle='Opinionated Rants on Life and Software',
                    url=request.host_url)
    for p in Post.published()[:10]:
        feed.add(p.title, enrich(p.body), content_type='html',
                 url=url_for('.post', slug=p.slug), id=url_for('.post', slug=p.slug),
                 updated=p.utc_pub_date, published=p.utc_pub_date)
    return feed.get_response()
Example #3
0
def index():
    posts = Post.published()[:10]
    return render_template('index.html', posts=posts, isindex=True)