aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2015-05-27 10:36:27 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2015-05-27 10:36:27 +0200
commitc9c34eedef5a7250cee04af30601c54200021dfa (patch)
tree9c59887e62b3927d8f6253042e671ad279c75684 /pyaggr3g470r
parentTry to fix a problem with Python 3.4.3 and test 'ensure_future' with Python d... (diff)
parentRemoved debug message. (diff)
downloadnewspipe-c9c34eedef5a7250cee04af30601c54200021dfa.tar.gz
newspipe-c9c34eedef5a7250cee04af30601c54200021dfa.tar.bz2
newspipe-c9c34eedef5a7250cee04af30601c54200021dfa.zip
Merge branch 'master' of bitbucket.org:cedricbonhomme/pyaggr3g470r
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/static/js/articles.js20
-rw-r--r--pyaggr3g470r/templates/home.html8
-rw-r--r--pyaggr3g470r/views/views.py13
3 files changed, 24 insertions, 17 deletions
diff --git a/pyaggr3g470r/static/js/articles.js b/pyaggr3g470r/static/js/articles.js
index a5ac82d0..bb31f6d8 100644
--- a/pyaggr3g470r/static/js/articles.js
+++ b/pyaggr3g470r/static/js/articles.js
@@ -24,6 +24,23 @@ if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') }
+function ($) {
+ // Mark an article as read when it is opened in a new table
+ $('.open-article').on('click', function(e) {
+ var feed_id = $(this).parent().parent().attr("data-feed");
+ var filter = $('#filters').attr("data-filter");
+ if (filter == "unread") {
+ $(this).parent().parent().remove();
+ $("#total-unread").text(parseInt($("#total-unread").text()) - 1);
+ if (parseInt($("#unread-"+feed_id).text()) == 1) {
+ $("#unread-"+feed_id).remove();
+ } else {
+ $("#unread-"+feed_id).text(parseInt($("#unread-"+feed_id).text()) - 1);
+ }
+ }
+ });
+
+
+
// Mark an article as read or unread.
$('.readed').on('click', function() {
var article_id = $(this).parent().parent().parent().attr("data-article");
@@ -90,6 +107,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') }
});
});
+
+
// Like or unlike an article
$('.like').on('click', function() {
var article_id = $(this).parent().parent().parent().attr("data-article");
@@ -145,6 +164,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') }
});
+
// Delete all duplicate articles (used in the page /duplicates)
$('.delete-all').click(function(){
var data = [];
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html
index e5db30e1..3d0e3849 100644
--- a/pyaggr3g470r/templates/home.html
+++ b/pyaggr3g470r/templates/home.html
@@ -10,11 +10,7 @@
<ul class="nav sidenav navbar-collapse pre-scrollable" data-offset-top="0" data-offset-bottom="0" style="min-height: 650px;">
<li><a href="{{ gen_url(feed_id=0) }}">
{% if not feed_id %}<b>{% endif %}
- {% if filter_=='all' %}
- {{ _('All feeds') }} <span id="total-unread" class="badge pull-right">{{ unread.items()|sum(attribute="1") }} / {{ articles.__len__() }}</span>
- {% else %}
- {{ _('All feeds') }} <span id="total-unread" class="badge pull-right">{{ articles.__len__() }}</span>
- {% endif %}
+ {{ _('All feeds') }} <span id="total-unread" class="badge pull-right">{{ articles.__len__() }}</span>
{% if not feed_id %}</b>{% endif %}
</a></li>
{% for fid, nbunread in unread|dictsort(by='value')|reverse %}
@@ -97,7 +93,7 @@
{% if filter_ == 'all' %}</b>{% endif %}
{% endif %}
</td>
- <td><a href="/article/redirect/{{ article.id}}" target="_blank">{{ article.source.title|safe }}</a></td>
+ <td><a class="open-article" href="/article/redirect/{{ article.id}}" target="_blank">{{ article.source.title|safe }}</a></td>
<td {%if filter_ == 'all' and article.readed == False %}style='font-weight:bold'{% endif %}>
<a href="/article/{{ article.id }}">{{ article.title|safe }}</a>
</td>
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index 3abc76df..5897bc9e 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -246,6 +246,7 @@ def render_home(filters=None, head_titles=None,
arti_contr = ArticleController(g.user.id)
feeds = {feed.id: feed.title for feed in feed_contr.read()}
+ unread = arti_contr.get_unread()
in_error = {feed.id: feed.error_count for feed in
feed_contr.read(error_count__gt=2)}
@@ -268,19 +269,9 @@ def render_home(filters=None, head_titles=None,
}.get(sort_, Article.date.desc())
articles = arti_contr.read(**filters).order_by(sort_param)
- unread_counter = {}
if limit != 'all':
limit = int(limit)
articles = articles.limit(limit)
- {article.feed_id: 1
- if article.feed_id not in unread_counter and
- not unread_counter.update({article.feed_id: 1})
- else unread_counter[article.feed_id] + 1
- if not unread_counter.update({article.feed_id:
- unread_counter[article.feed_id] + 1})
- else 1
- for article in articles if article.readed==False
- }
def gen_url(filter_=filter_, sort_=sort_, limit=limit, feed_id=feed_id,
**kwargs):
@@ -301,7 +292,7 @@ def render_home(filters=None, head_titles=None,
return render_template('home.html', gen_url=gen_url, feed_id=feed_id,
filter_=filter_, limit=limit, feeds=feeds,
- unread=unread_counter, articles=articles, in_error=in_error,
+ unread=unread, articles=articles, in_error=in_error,
head_titles=head_titles, sort_=sort_, **kwargs)
bgstack15