Showing blurblogs on the feed list.

This commit is contained in:
Samuel Clay 2012-01-21 16:12:54 -08:00
parent d1f5213d33
commit bed2475a6c
4 changed files with 83 additions and 6 deletions

View file

@ -202,7 +202,7 @@ class MSocialProfile(mongo.Document):
@classmethod
def profile_feeds(cls, user_ids):
profiles = cls.objects.filter(user_id__in=user_ids, shared_stories_count__gte=1)
profiles = dict((p.username, p) for p in profiles)
profiles = dict((p.user_id, p.feed()) for p in profiles)
return profiles
@classmethod
@ -220,7 +220,14 @@ class MSocialProfile(mongo.Document):
redis_conn.sadd(following_key, user_id)
follower_key = "F:%s:f" % (user_id)
redis_conn.sadd(follower_key, self.user_id)
def feed(self):
params = self.to_json(compact=True)
params.update({
'feed_title': params['username'] + '\'s blurblog'
})
return params
def to_json(self, compact=False, full=False):
if compact:
params = {
@ -342,10 +349,24 @@ class MSocialSubscription(mongo.Document):
def feeds(cls, *args, **kwargs):
user_id = kwargs['user_id']
social_subs = cls.objects.filter(user_id=user_id)
social_user_ids = [s.subscription_user_id for s in social_subs]
social_subs = dict((s.subscription_user_id, s.to_json()) for s in social_subs)
social_user_ids = social_subs.keys()
social_profiles = MSocialProfile.profile_feeds(social_user_ids)
return social_profiles
social_feeds = {}
for user_id, social_sub in social_subs.items():
social_feeds[user_id] = dict(social_sub.items() + social_profiles[user_id].items())
return social_feeds
def to_json(self):
return {
'user_id': self.user_id,
'subscription_user_id': self.subscription_user_id,
'nt': self.unread_count_neutral + 2,
'ps': self.unread_count_positive + 3,
'ng': self.unread_count_negative,
'is_trained': self.is_trained,
}
class MSocialServices(mongo.Document):

View file

@ -351,6 +351,29 @@ body.NB-theme-serif #story_pane .NB-feed-story-content {
overflow-x: hidden !important;
}
/* =============== */
/* = Friend List = */
/* =============== */
.NB-socialfeeds {
overflow-y: auto;
overflow-x: hidden;
font-size: 11px;
list-style: none;
margin: 0;
padding: 0;
width: auto !important;
height: auto !important;
border-bottom: 1px solid #A0A0A0;
}
.NB-feedlist .NB-socialfeeds .feed {
background-color: #E6DABC;
border-top-color: #E6DABC;
border-bottom-color: #E6DABC;
}
/* ============= */
/* = Feed List = */
/* ============= */

View file

@ -12,6 +12,7 @@
this.$s = {
$body: $('body'),
$feed_list: $('#feed_list'),
$social_feeds: $('.NB-socialfeeds'),
$story_titles: $('#story_titles'),
$content_pane: $('.content-pane'),
$story_taskbar: $('#story_taskbar'),
@ -1025,7 +1026,10 @@
$('.NB-callout-ftux .NB-callout-text').text('Loading feeds...');
this.$s.$feed_link_loader.css({'display': 'block'});
this.flags['favicons_downloaded'] = false;
this.model.load_feeds($.rescope(this.make_feeds, this));
this.model.load_feeds(_.bind(function() {
this.make_feeds();
this.make_social_feeds();
}, this));
}
},
@ -1085,6 +1089,28 @@
this.load_router();
},
make_social_feeds: function() {
var social_feeds = this.model.social_feeds;
var $social_feeds = this.$s.$social_feeds;
$social_feeds.empty();
var $feeds = "";
_.each(social_feeds, _.bind(function(feed) {
console.log(["social feed", feed]);
var $feed = this.make_feed_title_template(feed, 'feed', 0);
$feeds += $feed;
}, this));
$social_feeds.css({
'display': 'block',
'opacity': 0
});
$social_feeds.html($feeds);
$social_feeds.animate({'opacity': 1}, {'duration': 700});
},
load_router: function() {
NEWSBLUR.router = new NEWSBLUR.Router;
var route_found = Backbone.history.start({pushState: true});
@ -1728,6 +1754,7 @@
this.$s.$river_header.removeClass('NB-selected');
this.$s.$tryfeed_header.removeClass('NB-selected');
$('.NB-selected', this.$s.$feed_list).removeClass('NB-selected');
$('.NB-selected', this.$s.$social_feeds).removeClass('NB-selected');
this.$s.$body.removeClass('NB-view-river');
$('.task_view_page', this.$s.$taskbar).removeClass('NB-disabled');
$('.task_view_page', this.$s.$taskbar).removeClass('NB-task-return');
@ -5317,6 +5344,7 @@
switch_feed_view_unread_view: function(unread_view) {
if (!_.isNumber(unread_view)) unread_view = this.model.preference('unread_view');
var $feed_list = this.$s.$feed_list;
var $social_feeds = this.$s.$social_feeds;
var unread_view_name = this.get_unread_view_name(unread_view);
var $next_story_button = $('.task_story_next_unread');
var $story_title_indicator = $('.NB-story-title-indicator', this.$story_titles);
@ -5326,6 +5354,10 @@
.removeClass('unread_view_neutral')
.removeClass('unread_view_negative')
.addClass('unread_view_'+unread_view_name);
$social_feeds.removeClass('unread_view_positive')
.removeClass('unread_view_neutral')
.removeClass('unread_view_negative')
.addClass('unread_view_'+unread_view_name);
if (NEWSBLUR.Preferences['hide_read_feeds'] == 1) {
$hidereadfeeds_button.attr('title', 'Show all sites');

View file

@ -490,6 +490,7 @@ $(document).ready(function() {
</div>
</div>
<ul class="NB-socialfeeds"></ul>
<ul class="folder NB-feedlist" id="feed_list"></ul>
</div>