aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views/feed.py
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-08-03 23:55:46 +0200
committerCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-08-03 23:55:46 +0200
commitcdbd573500a365e290e88b50d7b0c2355b7f7e19 (patch)
tree25ede52ae4b02a2377ae40d2c146c7ed2e9abe2a /pyaggr3g470r/views/feed.py
parentThe numver ov values of the splited string is variable (sometimes the charset... (diff)
parentsqlalchemy was requesting icons everytime feed where listed (diff)
downloadnewspipe-cdbd573500a365e290e88b50d7b0c2355b7f7e19.tar.gz
newspipe-cdbd573500a365e290e88b50d7b0c2355b7f7e19.tar.bz2
newspipe-cdbd573500a365e290e88b50d7b0c2355b7f7e19.zip
Merged in jaesivsm/pyaggr3g470r (pull request #20)
perf improvement
Diffstat (limited to 'pyaggr3g470r/views/feed.py')
-rw-r--r--pyaggr3g470r/views/feed.py21
1 files changed, 4 insertions, 17 deletions
diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py
index fb3ea4c7..afb51903 100644
--- a/pyaggr3g470r/views/feed.py
+++ b/pyaggr3g470r/views/feed.py
@@ -14,6 +14,7 @@ from flask.ext.login import login_required
import conf
from pyaggr3g470r import utils
+from pyaggr3g470r.lib.view_utils import etag_match
from pyaggr3g470r.lib.feed_utils import construct_feed_from
from pyaggr3g470r.forms import AddFeedForm
from pyaggr3g470r.controllers import FeedController, ArticleController
@@ -24,6 +25,7 @@ feed_bp = Blueprint('feed', __name__, url_prefix='/feed')
@feeds_bp.route('/', methods=['GET'])
@login_required
+@etag_match
def feeds():
"Lists the subscribed feeds in a table."
art_contr = ArticleController(g.user.id)
@@ -35,6 +37,7 @@ def feeds():
@feed_bp.route('/<int:feed_id>', methods=['GET'])
@login_required
+@etag_match
def feed(feed_id=None):
"Presents detailed information about a feed."
feed = FeedController(g.user.id).get(id=feed_id)
@@ -138,6 +141,7 @@ def update(action, feed_id=None):
@feed_bp.route('/create', methods=['GET'])
@feed_bp.route('/edit/<int:feed_id>', methods=['GET'])
@login_required
+@etag_match
def form(feed_id=None):
action = gettext("Add a feed")
head_titles = [action]
@@ -196,20 +200,3 @@ def process_form(feed_id=None):
flash(gettext("Downloading articles for the new feed..."), 'info')
return redirect(url_for('feed.form', feed_id=new_feed.id))
-
-
-@feed_bp.route('/icon/<int:feed_id>', methods=['GET'])
-@login_required
-def icon(feed_id):
- icon = FeedController(None if g.user.is_admin() else g.user.id)\
- .get(id=feed_id).icon
- etag = md5(icon.encode('utf8')).hexdigest()
- headers = {'Cache-Control': 'max-age=86400', 'etag': etag}
- if request.headers.get('if-none-match') == etag:
- return Response(status=304, headers=headers)
- if '\n' in icon:
- content_type, *_, icon = icon.split()
- headers['content-type'] = content_type
- else:
- headers['content-type'] = 'application/image'
- return Response(base64.b64decode(icon), headers=headers)
bgstack15