def index(): posts = {} for post in data.get_posts(data.POST_ACTUALITIES, end=4): timestamp = post[data.TIMESTAMP] posts[timestamp] = post return render_template("index.html", body_id="index", name=data.POST_ACTUALITIES, posts=posts)
def admin(name): if name not in data.POSTS: abort(404) posts = {} for state in data.STATES: posts[state] = state_posts = {} for post in data.get_posts(name, state): timestamp = post[data.TIMESTAMP] state_posts[timestamp] = post return render_template("admin.html", body_id="admin", posts=posts, title=data.POSTS[name], name=name)
def feed(name): if name not in data.POSTS: abort(404) entries = [] for post in data.get_posts(name, data.STATE_PUBLISHED, end=50): timestamp = post[data.TIMESTAMP] post['link'] = url_for( 'post', name=name, timestamp=timestamp, _external=True ) entries.append({'content': post}) title = f'{data.POSTS[name]} AFPy.org' return render_template( 'rss.xml', entries=entries, title=title, description=title, link=url_for('feed', name=name, _external=True), )
def feed(name): if name not in data.POSTS: abort(404) entries = [] for post in data.get_posts(name, data.STATE_PUBLISHED, end=50): post["timestamp"] = post[data.TIMESTAMP] post["link"] = url_for("post", name=name, timestamp=post["timestamp"], _external=True) entries.append({"content": post}) title = f"{data.POSTS[name]} AFPy.org" return render_template( "rss.xml", entries=entries, title=title, description=title, link=url_for("feed", name=name, _external=True), )
def posts(name, page=1): if name not in data.POSTS: abort(404) end = page * PAGINATION start = end - PAGINATION total_pages = (data.count_posts(name, data.STATE_PUBLISHED) // PAGINATION) + 1 posts = {} for post in data.get_posts(name, data.STATE_PUBLISHED, start=start, end=end): timestamp = post[data.TIMESTAMP] posts[timestamp] = post return render_template( "posts.html", body_id=name, posts=posts, title=data.POSTS[name], name=name, page=page, total_pages=total_pages, )