mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding inline classifiers for tags. Saves single tag classifier, refreshing single feed, and updates intelligence colors dynamically.
This commit is contained in:
parent
f6e06259b7
commit
80cbe2c127
4 changed files with 139 additions and 27 deletions
|
@ -227,8 +227,11 @@ def load_feeds_iphone(request):
|
|||
def refresh_feeds(request):
|
||||
start = datetime.datetime.utcnow()
|
||||
user = get_user(request)
|
||||
feed_ids = request.REQUEST.getlist('feed_id')
|
||||
feeds = {}
|
||||
user_subs = UserSubscription.objects.select_related('feed').filter(user=user, active=True)
|
||||
if feed_ids:
|
||||
user_subs = user_subs.filter(feed__in=feed_ids)
|
||||
UNREAD_CUTOFF = datetime.datetime.utcnow() - datetime.timedelta(days=settings.DAYS_OF_UNREAD)
|
||||
favicons_fetching = [int(f) for f in request.POST.getlist('favicons_fetching') if f]
|
||||
|
||||
|
|
|
@ -1654,6 +1654,7 @@ background: transparent;
|
|||
height: 14px;
|
||||
}
|
||||
#story_pane .NB-feed-story-tag {
|
||||
/* Grey */
|
||||
float: left;
|
||||
font-weight: normal;
|
||||
font-size: 9px;
|
||||
|
@ -1665,30 +1666,74 @@ background: transparent;
|
|||
border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#story_pane .NB-feed-story-title .NB-score-1 {
|
||||
color: #34912E;
|
||||
}
|
||||
#story_pane .NB-feed-story-title .NB-score--1 {
|
||||
color: #A90103;
|
||||
}
|
||||
#story_pane .NB-feed-story-author.NB-score-1 {
|
||||
color: #34912E;
|
||||
}
|
||||
#story_pane .NB-feed-story-author.NB-score--1 {
|
||||
color: #A90103;
|
||||
}
|
||||
#story_pane .NB-feed-story-tag.NB-score-1 {
|
||||
background-color: #34912E;
|
||||
color: white;
|
||||
text-shadow: 0 1px 0 #000;
|
||||
opacity: .4;
|
||||
/* Green */
|
||||
background-color: #34912E;
|
||||
color: white;
|
||||
text-shadow: 0 1px 0 #000;
|
||||
opacity: .4;
|
||||
}
|
||||
#story_pane .NB-feed-story-tag.NB-score--1 {
|
||||
background-color: #A90103;
|
||||
color: white;
|
||||
text-shadow: 0 1px 0 #000;
|
||||
opacity: .4;
|
||||
/* Red */
|
||||
background-color: #A90103;
|
||||
color: white;
|
||||
text-shadow: 0 1px 0 #000;
|
||||
opacity: .4;
|
||||
}
|
||||
#story_pane .NB-feed-story-tag:hover {
|
||||
/* Gray, active -> [Light] Green */
|
||||
background-color: #89AE6E;
|
||||
text-shadow: 0 1px 0 #000;
|
||||
color: white;
|
||||
opacity: .4;
|
||||
}
|
||||
#story_pane .NB-feed-story-tag.NB-score-1:hover {
|
||||
/* Green, active -> [Light] Red */
|
||||
background-color: #E35356;
|
||||
color: white;
|
||||
text-shadow: 0 1px 0 #000;
|
||||
}
|
||||
#story_pane .NB-feed-story-tag.NB-score--1:hover {
|
||||
/* Red, active -> [Light] Grey */
|
||||
background-color: #E2E2E2;
|
||||
color: #A7A399;
|
||||
text-shadow: 0 1px 0 #E9E9E9;
|
||||
opacity: 1;
|
||||
}
|
||||
#story_pane .NB-feed-story-tag.NB-score-now-0:hover {
|
||||
/* Grey, active */
|
||||
background-color: #DBDBDB;
|
||||
color: #9D9A95;
|
||||
text-shadow: 0 1px 0 #E9E9E9;
|
||||
opacity: 1;
|
||||
}
|
||||
#story_pane .NB-feed-story-tag.NB-score-now-1.NB-score-1:hover {
|
||||
/* Green, active */
|
||||
background-color: #34912E;
|
||||
color: white;
|
||||
text-shadow: 0 1px 0 #000;
|
||||
}
|
||||
#story_pane .NB-feed-story-tag.NB-score-now--1.NB-score--1:hover {
|
||||
/* Red, active */
|
||||
background-color: #A90103;
|
||||
color: white;
|
||||
text-shadow: 0 1px 0 #000;
|
||||
opacity: .4;
|
||||
}
|
||||
|
||||
#story_pane .NB-feed-story-title .NB-score-1 {
|
||||
color: #34912E;
|
||||
}
|
||||
#story_pane .NB-feed-story-title .NB-score--1 {
|
||||
color: #A90103;
|
||||
}
|
||||
#story_pane .NB-feed-story-author.NB-score-1 {
|
||||
color: #34912E;
|
||||
}
|
||||
#story_pane .NB-feed-story-author.NB-score--1 {
|
||||
color: #A90103;
|
||||
}
|
||||
#story_pane .NB-feed-story-header .NB-feed-story-date {
|
||||
position: absolute;
|
||||
|
|
|
@ -334,7 +334,7 @@ NEWSBLUR.AssetModel.Reader.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
refresh_feeds: function(callback, has_unfetched_feeds) {
|
||||
refresh_feeds: function(callback, has_unfetched_feeds, feed_id) {
|
||||
var self = this;
|
||||
|
||||
var pre_callback = function(data) {
|
||||
|
@ -353,6 +353,9 @@ NEWSBLUR.AssetModel.Reader.prototype = {
|
|||
data['favicons_fetching'] = favicons_fetching;
|
||||
}
|
||||
}
|
||||
if (feed_id) {
|
||||
data['feed_id'] = feed_id;
|
||||
}
|
||||
|
||||
if (NEWSBLUR.Globals.is_authenticated) {
|
||||
this.make_request('/reader/refresh_feeds', data, pre_callback);
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
this.counts = {
|
||||
'feature_page': 0,
|
||||
'unfetched_feeds': 0,
|
||||
'fetched_feeds': 0
|
||||
'fetched_feeds': 0,
|
||||
'page_fill_outs': 0
|
||||
};
|
||||
this.cache = {
|
||||
'iframe_stories': {},
|
||||
|
@ -1340,6 +1341,10 @@
|
|||
'last_feed_view_story_feed_id': null
|
||||
});
|
||||
|
||||
$.extend(this.counts, {
|
||||
'page_fill_outs': 0
|
||||
});
|
||||
|
||||
this.active_feed = null;
|
||||
this.active_story = null;
|
||||
this.cache.$feed_in_feed_list = null;
|
||||
|
@ -2697,7 +2702,12 @@
|
|||
($last.length == 0 ||
|
||||
($('#story_titles').scrollTop() == 0 &&
|
||||
$last.position().top + $last.height() < container_height))) {
|
||||
_.delay(_.bind(this.load_page_of_feed_stories, this), 250);
|
||||
if (this.counts['page_fill_outs'] < 8) {
|
||||
this.counts['page_fill_outs'] += 1;
|
||||
_.delay(_.bind(this.load_page_of_feed_stories, this), 250);
|
||||
} else {
|
||||
this.append_story_titles_endbar();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -3033,11 +3043,52 @@
|
|||
_.map(story.story_tags, function(tag) {
|
||||
var score = feed_tags[tag];
|
||||
return $.make('div', {
|
||||
className: 'NB-feed-story-tag ' + (!!score && 'NB-score-'+score || '')
|
||||
}, tag);
|
||||
className: 'NB-feed-story-tag ' + (!!score && 'NB-score-'+score || '')
|
||||
}, tag).data('tag', tag);
|
||||
}));
|
||||
},
|
||||
|
||||
preserve_classifier_color: function($story, value, score) {
|
||||
var $t;
|
||||
$('.NB-feed-story-tag', $story).each(function() {
|
||||
if ($(this).data('tag') == value) {
|
||||
$t = $(this);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$t.removeClass('NB-score-now-1')
|
||||
.removeClass('NB-score-now--1')
|
||||
.removeClass('NB-score-now-0')
|
||||
.addClass('NB-score-now-'+score)
|
||||
.one('mouseleave', function() {
|
||||
$t.removeClass('NB-score-now-'+score);
|
||||
});
|
||||
_.defer(function() {
|
||||
$t.one('mouseenter', function() {
|
||||
$t.removeClass('NB-score-now-'+score);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
save_classifier: function(type, value, score, feed_id) {
|
||||
var data = {
|
||||
'feed_id': feed_id
|
||||
};
|
||||
if (score == 0) {
|
||||
data['remove_like_'+type] = value;
|
||||
} else if (score == 1) {
|
||||
data['like_'+type] = value;
|
||||
} else if (score == -1) {
|
||||
data['dislike_'+type] = value;
|
||||
}
|
||||
|
||||
this.model.classifiers[type+'s'][value] = score;
|
||||
this.model.save_classifier_publisher(data, _.bind(function(resp) {
|
||||
this.force_feeds_refresh(null, true, feed_id);
|
||||
}, this));
|
||||
this.recalculate_story_scores(feed_id);
|
||||
},
|
||||
|
||||
show_correct_feed_in_feed_title_floater: function(story) {
|
||||
var $story, $header;
|
||||
|
||||
|
@ -4259,7 +4310,7 @@
|
|||
}, refresh_interval);
|
||||
},
|
||||
|
||||
force_feeds_refresh: function(callback, update_all) {
|
||||
force_feeds_refresh: function(callback, update_all, feed_id) {
|
||||
if (callback) {
|
||||
this.cache.refresh_callback = callback;
|
||||
} else {
|
||||
|
@ -4270,7 +4321,7 @@
|
|||
|
||||
this.model.refresh_feeds(_.bind(function(updated_feeds) {
|
||||
this.post_feed_refresh(updated_feeds, update_all);
|
||||
}, this), this.flags['has_unfetched_feeds']);
|
||||
}, this), this.flags['has_unfetched_feeds'], feed_id);
|
||||
},
|
||||
|
||||
post_feed_refresh: function(updated_feeds, update_all) {
|
||||
|
@ -4829,6 +4880,16 @@
|
|||
|
||||
if (story_prevent_bubbling) return false;
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-feed-story-tag' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
var $story = $t.closest('.NB-feed-story');
|
||||
var feed_id = $story.data('feed_id');
|
||||
var tag = $t.data('tag');
|
||||
var score = $t.hasClass('NB-score-1') ? -1 : $t.hasClass('NB-score--1') ? 0 : 1;
|
||||
self.save_classifier('tag', tag, score, feed_id);
|
||||
self.preserve_classifier_color($story, tag, score);
|
||||
});
|
||||
|
||||
$.targetIs(e, { tagSelector: '.story' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
var story_id = $('.story_id', $t).text();
|
||||
|
|
Loading…
Add table
Reference in a new issue