diff options
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r-- | pyaggr3g470r/templates/layout.html | 39 | ||||
-rw-r--r-- | pyaggr3g470r/views/feed.py | 15 | ||||
-rw-r--r-- | pyaggr3g470r/views/views.py | 10 |
3 files changed, 36 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 |