From bed2475a6c44f954a1d9208cdda2d18a4f4fc5ed Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Sat, 21 Jan 2012 16:12:54 -0800 Subject: [PATCH] Showing blurblogs on the feed list. --- apps/social/models.py | 31 ++++++++++++++++++++++----- media/css/reader.css | 23 ++++++++++++++++++++ media/js/newsblur/reader/reader.js | 34 +++++++++++++++++++++++++++++- templates/reader/feeds.xhtml | 1 + 4 files changed, 83 insertions(+), 6 deletions(-) diff --git a/apps/social/models.py b/apps/social/models.py index 73f6f3b6e..45eeca3db 100644 --- a/apps/social/models.py +++ b/apps/social/models.py @@ -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): diff --git a/media/css/reader.css b/media/css/reader.css index bad19eb43..c7a348d83 100644 --- a/media/css/reader.css +++ b/media/css/reader.css @@ -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 = */ /* ============= */ diff --git a/media/js/newsblur/reader/reader.js b/media/js/newsblur/reader/reader.js index e31ff3204..f46660652 100644 --- a/media/js/newsblur/reader/reader.js +++ b/media/js/newsblur/reader/reader.js @@ -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'); diff --git a/templates/reader/feeds.xhtml b/templates/reader/feeds.xhtml index 55dcd5979..46c97cdc0 100644 --- a/templates/reader/feeds.xhtml +++ b/templates/reader/feeds.xhtml @@ -490,6 +490,7 @@ $(document).ready(function() { +