aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-04-11 16:14:19 +0200
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-04-12 14:31:06 +0200
commit21da20f5d592aabcb60096768dcac76baa626315 (patch)
treef5381a80073726450be90acae594369ef01b982d
parentregrouping favorties and home, redoing the tab selection jscode (diff)
downloadnewspipe-21da20f5d592aabcb60096768dcac76baa626315.tar.gz
newspipe-21da20f5d592aabcb60096768dcac76baa626315.tar.bz2
newspipe-21da20f5d592aabcb60096768dcac76baa626315.zip
first take on redoing the menu
-rw-r--r--pyaggr3g470r/templates/layout.html39
-rw-r--r--pyaggr3g470r/views/feed.py15
-rw-r--r--pyaggr3g470r/views/views.py10
-rwxr-xr-xrunserver.py1
4 files changed, 37 insertions, 28 deletions
diff --git a/pyaggr3g470r/templates/layout.html b/pyaggr3g470r/templates/layout.html
index f9b51127..d15d99d8 100644
--- a/pyaggr3g470r/templates/layout.html
+++ b/pyaggr3g470r/templates/layout.html
@@ -9,10 +9,10 @@
<title>pyAggr3g470r{% if head_title %} - {{ head_title }}{% 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" />
+ <link href="{{ url_for('static', filename='css/bootstrap.css') }}" rel="stylesheet" media="screen" />
<!-- Add custom CSS here -->
- <link href="{{ url_for('static', filename = 'css/customized-bootstrap.css') }}" rel="stylesheet" media="screen" />
- <link href="{{ url_for('static', filename = 'css/side-nav.css') }}" rel="stylesheet" media="screen" />
+ <link href="{{ url_for('static', filename='css/customized-bootstrap.css') }}" rel="stylesheet" media="screen" />
+ <link href="{{ url_for('static', filename='css/side-nav.css') }}" rel="stylesheet" media="screen" />
{% endblock %}
</head>
<body>
@@ -25,36 +25,39 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
- <a class="navbar-brand" href="/">pyAggr3g470r</a><span class="navbar-brand">{% if head_title %}-  {{ head_title }}{% endif %}</span>
+ <a class="navbar-brand" href="/">pyAggr3g470r</a>
+ <span class="navbar-brand">{% if head_title %} - {{ head_title }}{% endif %}</span>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav navbar-right">
{% if g.user.is_authenticated() %}
+ <li><a href="{{ url_for("feed.form") }}"><span class="glyphicon glyphicon-plus-sign"></span>{{ _('Add a feed') }}</a></li>
+ <li><a accesskey="f" href="/favorites"><span class="glyphicon glyphicon-star"></span> {{ _('Favorites') }}</a></li>
+ {% if conf.ON_HEROKU and g.user.is_admin() %}
+ <li><a accesskey="r" href="/fetch"><span class="glyphicon glyphicon-import"></span>{{ _('Fetch') }}</a></li>
+ {% endif %}
<li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ _('Articles') }} <b class="caret"></b></a>
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ _('Feed') }} <b class="caret"></b></a>
<ul class="dropdown-menu">
- <li><a accesskey="r" href="/fetch">{{ _('Fetch') }}</a></li>
- <li><a href="/mark_as/read">{{ _('Mark all as read') }}</a></li>
+ <li><a href="{{ url_for("feeds.update", action="read") }}">{{ _('Mark all as read') }}</a></li>
<li role="presentation" class="divider"></li>
- <li><a href="{{ url_for("feed.form") }}">{{ _('Add a feed') }}</a></li>
+ <li><a accesskey="i" href="/inactives">{{ _('Inactive') }}</a></li>
+ <li><a href="/history">{{ _('History') }}</a></li>
+ <li><a href="{{ url_for("feeds.feeds") }}">{{ _('All') }}</a></li>
</ul>
</li>
<li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-filter"></span> {{ _('Filter') }} <b class="caret"></b></a>
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ _('Tools') }} <b class="caret"></b></a>
<ul class="dropdown-menu">
- <li><a accesskey="f" href="/favorites">{{ _('Favorites') }}</a></li>
- <li><a accesskey="i" href="/inactives">{{ _('Inactive feeds') }}</a></li>
- <li><a href="{{ url_for("feeds.feeds") }}">{{ _('All feeds') }}</a></li>
- <li><a href="/history">{{ _('History') }}</a></li>
+ <li><a accesskey="m" href="/management"><span class="glyphicon glyphicon-cog"></span> {{ _('Management') }}</a></li>
+ {% if g.user.is_admin() %}
+ <li><a href="{{ url_for('dashboard') }}"><span class="glyphicon glyphicon-dashboard"></span> {{ _('Dashboard') }}</a></li>
+ {% endif %}
+ <li><a href="/about"><span class="glyphicon glyphicon-question-sign"></span>{{ _('About') }}</a></li>
</ul>
</li>
- <li><a accesskey="m" href="/management"><span class="glyphicon glyphicon-cog"></span> {{ _('Management') }}</a></li>
- {% if g.user.is_admin() %}
- <li><a href="{{ url_for('dashboard') }}"><span class="glyphicon glyphicon-dashboard"></span> {{ _('Dashboard') }}</a></li>
- {% endif %}
- <li><a href="/about">{{ _('About') }}</a></li>
<li><a href="{{ url_for('logout') }}"><span class="glyphicon glyphicon-log-out"></span> {{ _('Logout') }}</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py
index f0e35e4b..e4c0dc9a 100644
--- a/pyaggr3g470r/views/feed.py
+++ b/pyaggr3g470r/views/feed.py
@@ -112,15 +112,16 @@ def read(feed_id):
return redirect(request.referrer or url_for('home'))
-@feed_bp.route('/update/<int:feed_id>/<action>', methods=['GET', 'POST'])
+@feed_bp.route('/update/<action>/<int:feed_id>', methods=['GET', 'POST'])
+@feeds_bp.route('/update/<action>', methods=['GET', 'POST'])
@login_required
-def update(feed_id, action):
+def update(action, feed_id=None):
readed = action == 'read'
- ArticleController(g.user.id).update({'readed__ne': readed,
- 'feed_id': feed_id},
- {'readed': readed})
- flash(gettext('Feed successfully updated.',
- feed_title=feed.title), 'success')
+ filters = {'readed__ne': readed}
+ if feed_id:
+ filters['feed_id'] = feed_id
+ ArticleController(g.user.id).update(filters, {'readed': readed})
+ flash(gettext('Feed successfully updated.'), 'success')
return redirect(request.referrer or url_for('home'))
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index 623cf5d4..3d3c47f6 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -224,13 +224,11 @@ def signup():
return render_template('signup.html', form=form)
@app.route('/')
-@app.route('/favorites')
@login_required
-def home():
+def home(favorites=False):
"""
Home page for connected users. Displays by default unread articles.
"""
- favorites = request.path.startswith('/favorites')
head_title = gettext('Favorites') if favorites else ''
feed_contr = FeedController(g.user.id)
arti_contr = ArticleController(g.user.id)
@@ -271,6 +269,12 @@ def home():
default_max_error = conf.DEFAULT_MAX_ERROR)
+@app.route('/favorites')
+@login_required
+def favorties():
+ return home(favorites=True)
+
+
@app.route('/fetch', methods=['GET'])
@app.route('/fetch/<int:feed_id>', methods=['GET'])
@login_required
diff --git a/runserver.py b/runserver.py
index d1f5702c..a80b0c39 100755
--- a/runserver.py
+++ b/runserver.py
@@ -34,6 +34,7 @@ def month_name(month_number):
return calendar.month_name[month_number]
application.jinja_env.filters['month_name'] = month_name
application.jinja_env.filters['datetime'] = format_datetime
+application.jinja_env.globals['conf'] = conf
# Views
from flask.ext.restful import Api
bgstack15