diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2015-12-17 13:05:26 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2015-12-17 13:05:26 +0100 |
commit | 0312e25586d381cc53935c2fd4912378cd292d6e (patch) | |
tree | b04ad1a26edd4c67701d0d704c8ce8c554b2ae42 /src/web/views/article.py | |
parent | Updated link to Heroku deploy button on the About page. (diff) | |
parent | handling failing feed link (diff) | |
download | newspipe-0312e25586d381cc53935c2fd4912378cd292d6e.tar.gz newspipe-0312e25586d381cc53935c2fd4912378cd292d6e.tar.bz2 newspipe-0312e25586d381cc53935c2fd4912378cd292d6e.zip |
Merge pull request #24 from jaesivsm/master
moving the root of source code from / to /src/
Diffstat (limited to 'src/web/views/article.py')
-rw-r--r-- | src/web/views/article.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/web/views/article.py b/src/web/views/article.py new file mode 100644 index 00000000..bb914a6b --- /dev/null +++ b/src/web/views/article.py @@ -0,0 +1,40 @@ +#! /usr/bin/env python +# -*- coding: utf-8 - + +from flask import Blueprint, g, render_template, redirect + +from web import controllers, utils +from web.lib.view_utils import etag_match +from web.decorators import pyagg_default_decorator + +articles_bp = Blueprint('articles', __name__, url_prefix='/articles') +article_bp = Blueprint('article', __name__, url_prefix='/article') + + +@article_bp.route('/redirect/<int:article_id>', methods=['GET']) +@pyagg_default_decorator +def redirect_to_article(article_id): + article = controllers.ArticleController(g.user.id).get(id=article_id) + return redirect(article.link) + + +@article_bp.route('/<int:article_id>', methods=['GET']) +@pyagg_default_decorator +@etag_match +def article(article_id=None): + """ + Presents the content of an article. + """ + article = controllers.ArticleController(g.user.id).get(id=article_id) + previous_article = article.previous_article() + if previous_article is None: + previous_article = article.source.articles[0] + next_article = article.next_article() + if next_article is None: + next_article = article.source.articles[-1] + + return render_template('article.html', + head_titles=[utils.clear_string(article.title)], + article=article, + previous_article=previous_article, + next_article=next_article) |