aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyaggr3g470r/templates/layout.html9
-rwxr-xr-xpyaggr3g470r/utils.py21
-rw-r--r--pyaggr3g470r/views/article.py2
-rw-r--r--pyaggr3g470r/views/feed.py2
-rw-r--r--pyaggr3g470r/views/views.py17
5 files changed, 30 insertions, 21 deletions
diff --git a/pyaggr3g470r/templates/layout.html b/pyaggr3g470r/templates/layout.html
index fba29ae3..1be20f35 100644
--- a/pyaggr3g470r/templates/layout.html
+++ b/pyaggr3g470r/templates/layout.html
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="pyAggr3g470r is a web-based news aggregator." />
<meta name="author" content="" />
- <title>pyAggr3g470r{% if head_title %} - {{ head_title }}{% endif %}</title>
+ <title>pyAggr3g470r{% if head_titles %} - {{ ' - '.join(head_titles) }}{% endif %}</title>
<link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}" />
<!-- Bootstrap core CSS -->
<link href="{{ url_for('static', filename='css/bootstrap.css') }}" rel="stylesheet" media="screen" />
@@ -26,7 +26,12 @@
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ url_for("home") }}">pyAggr3g470r</a>
- <span class="navbar-brand">{% if head_title %} - {{ head_title }}{% endif %}</span>
+ {% if head_titles %}
+ {% for head_title in head_titles %}
+ <span class="navbar-brand"> - </span>
+ <span class="navbar-brand">{{ head_title }}</span>
+ {% endfor %}
+ {% endif %}
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py
index ea8a87bf..628703d2 100755
--- a/pyaggr3g470r/utils.py
+++ b/pyaggr3g470r/utils.py
@@ -172,7 +172,7 @@ def import_json(email, json_content):
description="",
link=feed["link"],
site_link=feed["site_link"],
- created_date=datetime.datetime.\
+ created_date=datetime.datetime.
fromtimestamp(int(feed["created_date"])),
enabled=feed["enabled"])
user.feeds.append(new_feed)
@@ -191,10 +191,10 @@ def import_json(email, json_content):
title=article["title"],
content=article["content"],
readed=article["readed"],
- like=article["like"], \
- retrieved_date=datetime.datetime.\
+ like=article["like"],
+ retrieved_date=datetime.datetime.
fromtimestamp(int(article["retrieved_date"])),
- date=datetime.datetime.\
+ date=datetime.datetime.
fromtimestamp(int(article["date"])),
user_id=user.id,
feed_id=user_feed.id)
@@ -228,7 +228,7 @@ def open_url(url):
if conf.HTTP_PROXY == "":
proxy = {}
else:
- proxy = {"http" : conf.HTTP_PROXY}
+ proxy = {"http": conf.HTTP_PROXY}
opener = urllib.request.FancyURLopener(proxy)
try:
opener = urllib.request.build_opener()
@@ -236,27 +236,28 @@ def open_url(url):
return (True, opener.open(url))
except urllib.error.HTTPError as e:
# server couldn't fulfill the request
- error = (url, e.code, \
- http.server.BaseHTTPRequestHandler.responses[e.code][1])
+ error = (url, e.code,
+ http.server.BaseHTTPRequestHandler.responses[e.code][1])
return (False, error)
except urllib.error.URLError as e:
# failed to reach the server
if type(e.reason) == str:
error = (url, e.reason, e.reason)
- #pyaggr3g470r_log.error(url + " " + e.reason)
else:
error = (url, e.reason.errno, e.reason.strerror)
return (False, error)
+
def clear_string(data):
"""
Clear a string by removing HTML tags, HTML special caracters
and consecutive white spaces (more that one).
"""
- p = re.compile('<[^>]+>') # HTML tags
- q = re.compile('\s') # consecutive white spaces
+ p = re.compile('<[^>]+>') # HTML tags
+ q = re.compile('\s') # consecutive white spaces
return p.sub('', q.sub(' ', data))
+
def load_stop_words():
"""
Load the stop words and return them in a list.
diff --git a/pyaggr3g470r/views/article.py b/pyaggr3g470r/views/article.py
index 08c92686..75360485 100644
--- a/pyaggr3g470r/views/article.py
+++ b/pyaggr3g470r/views/article.py
@@ -49,7 +49,7 @@ def article(article_id=None):
next_article = article.source.articles[-1]
return render_template('article.html',
- head_title=utils.clear_string(article.title),
+ head_titles=[utils.clear_string(article.title)],
article=article,
previous_article=previous_article,
next_article=next_article)
diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py
index 159dce64..bc75aa29 100644
--- a/pyaggr3g470r/views/feed.py
+++ b/pyaggr3g470r/views/feed.py
@@ -53,7 +53,7 @@ def feed(feed_id=None):
elapsed = today - last_article
return render_template('feed.html',
- head_title=utils.clear_string(feed.title),
+ head_titles=[utils.clear_string(feed.title)],
feed=feed, tag_cloud=tag_cloud,
first_post_date=first_article,
end_post_date=last_article,
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index 9f4ef0b7..f344ad61 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -228,15 +228,19 @@ def signup():
flash(gettext('Problem while sending activation email') + ': ' + str(e), 'danger')
return redirect(url_for('home'))
- flash(gettext('Your account has been created. Check your mail to confirm it.'), 'success')
+ flash(gettext('Your account has been created. '
+ 'Check your mail to confirm it.'), 'success')
return redirect(url_for('home'))
return render_template('signup.html', form=form)
-def render_home(filters=None, head_title='', page_to_render='home', **kwargs):
+def render_home(filters=None, head_titles=None,
+ page_to_render='home', **kwargs):
if filters is None:
filters = {}
+ if head_titles is None:
+ head_titles = []
feed_contr = FeedController(g.user.id)
arti_contr = ArticleController(g.user.id)
feeds = {feed.id: feed.title for feed in feed_contr.read()}
@@ -255,8 +259,7 @@ def render_home(filters=None, head_title='', page_to_render='home', **kwargs):
filters['readed'] = filter_ == 'read'
if feed_id:
filters['feed_id'] = feed_id
- head_title = "%s%s" % (feed_contr.get(id=feed_id).title,
- (' - %s' % head_title) if head_title else '')
+ head_titles.append(feed_contr.get(id=feed_id).title)
sort_param = {"feed": Article.title.desc(),
"date": Article.date.desc(),
@@ -286,7 +289,7 @@ def render_home(filters=None, head_title='', page_to_render='home', **kwargs):
return render_template('home.html', gen_url=gen_url, feed_id=feed_id,
filter_=filter_, limit=limit, feeds=feeds,
unread=unread, articles=articles, in_error=in_error,
- head_title=head_title, sort_=sort_, **kwargs)
+ head_titles=head_titles, sort_=sort_, **kwargs)
@app.route('/')
@@ -299,7 +302,7 @@ def home():
@app.route('/favorites')
@login_required
def favorites():
- return render_home({'like': True}, gettext('Favorites'), 'favorites')
+ return render_home({'like': True}, [gettext('Favorites')], 'favorites')
@app.route('/search', methods=['GET'])
@@ -319,7 +322,7 @@ def search():
filters['content__like'] = "%%%s%%" % query
if len(filters) > 1:
filters = {"__or__": filters}
- return render_home(filters, "%s %s" % (gettext('Search:'), query),
+ return render_home(filters, ["%s %s" % (gettext('Search:'), query)],
'search', search_query=query, search_title=search_title,
search_content=search_content)
bgstack15