Permalink
Browse files

Big conversion from only displaying friends comments to showing both …

…friends and public, still separated. Big design changes to comments on blurblogs, as well.
  • Loading branch information...
1 parent 00e8a44 commit a82492f928fa9d9dc210f32f5a44eaee0e25f444 @samuelclay committed Jul 3, 2012
View
@@ -459,8 +459,10 @@ def send_email_for_new_follower(self, follower_user_id):
common_followers, _ = self.common_follows(follower_user_id, direction='followers')
common_followings, _ = self.common_follows(follower_user_id, direction='following')
- common_followers.remove(self.user_id)
- common_followings.remove(self.user_id)
+ if self.user_id in common_followers:
+ common_followers.remove(self.user_id)
+ if self.user_id in common_followings:
+ common_followings.remove(self.user_id)
common_followers = MSocialProfile.profiles(common_followers)
common_followings = MSocialProfile.profiles(common_followings)
@@ -1144,35 +1146,40 @@ def stories_with_comments_and_profiles(cls, stories, user_id, check_all=False, p
friend_key = "F:%s:F" % (user_id)
profile_user_ids = set()
for story in stories:
- story['comments'] = []
+ story['friend_comments'] = []
+ story['public_comments'] = []
if check_all or story['comment_count']:
comment_key = "C:%s:%s" % (story['story_feed_id'], story['guid_hash'])
if check_all:
story['comment_count'] = r.scard(comment_key)
- if public:
- friends_with_comments = r.sdiff(comment_key, friend_key)
- else:
- friends_with_comments = r.sinter(comment_key, friend_key)
+ friends_with_comments = [int(f) for f in r.sinter(comment_key, friend_key)]
+ sharer_user_ids = [int(f) for f in r.smembers(comment_key)]
shared_stories = []
- if friends_with_comments:
+ if sharer_user_ids:
params = {
'story_guid': story['id'],
'story_feed_id': story['story_feed_id'],
- 'user_id__in': friends_with_comments,
+ 'user_id__in': sharer_user_ids,
}
shared_stories = cls.objects.filter(**params)
for shared_story in shared_stories:
comments = shared_story.comments_with_author()
- story['comments'].append(comments)
+ print friends_with_comments, sharer_user_ids, shared_story.user_id
+ if shared_story.user_id in friends_with_comments:
+ story['friend_comments'].append(comments)
+ else:
+ story['public_comments'].append(comments)
if comments.get('source_user_id'):
profile_user_ids.add(comments['source_user_id'])
+ all_comments = story['friend_comments'] + story['public_comments']
+ print all_comments
profile_user_ids = profile_user_ids.union([reply['user_id']
- for c in story['comments']
+ for c in all_comments
for reply in c['replies']])
if story.get('source_user_id'):
profile_user_ids.add(story['source_user_id'])
- story['comment_count_public'] = story['comment_count'] - len(shared_stories)
- story['comment_count_friends'] = len(shared_stories)
+ story['comment_count_friends'] = len(friends_with_comments)
+ story['comment_count_public'] = story['comment_count'] - len(friends_with_comments)
if check_all or story['share_count']:
share_key = "S:%s:%s" % (story['story_feed_id'], story['guid_hash'])
@@ -1202,12 +1209,13 @@ def attach_users_to_stories(stories, profiles):
stories[s]['shared_by_friends'][u] = profiles[user_id]
for u, user_id in enumerate(story['shared_by_public']):
stories[s]['shared_by_public'][u] = profiles[user_id]
- for c, comment in enumerate(story['comments']):
- stories[s]['comments'][c]['user'] = profiles[comment['user_id']]
- if comment['source_user_id']:
- stories[s]['comments'][c]['source_user'] = profiles[comment['source_user_id']]
- for r, reply in enumerate(comment['replies']):
- stories[s]['comments'][c]['replies'][r]['user'] = profiles[reply['user_id']]
+ for comment_set in ['friend_comments', 'public_comments']:
+ for c, comment in enumerate(story[comment_set]):
+ stories[s][comment_set][c]['user'] = profiles[comment['user_id']]
+ if comment['source_user_id']:
+ stories[s][comment_set][c]['source_user'] = profiles[comment['source_user_id']]
+ for r, reply in enumerate(comment['replies']):
+ stories[s][comment_set][c]['replies'][r]['user'] = profiles[reply['user_id']]
return stories
@@ -8,8 +8,8 @@ def render_story_share(story):
'story': story,
}
-@register.inclusion_tag('social/story_comments.xhtml')
-def render_story_comments(story):
+@register.inclusion_tag('social/story_comment.xhtml')
+def render_story_comment(comment):
return {
- 'story': story,
+ 'comment': comment,
}
View
@@ -10,6 +10,7 @@
199.15.249.98 db04 db04.newsblur.com
199.15.249.99 db05 db05.newsblur.com
199.15.249.100 db06 db06.newsblur.com
+199.15.252.50 db07 db07.newsblur.com
199.15.250.231 task01 task01.newsblur.com
199.15.250.250 task02 task02.newsblur.com
199.15.250.233 task03 task03.newsblur.com
@@ -10,11 +10,11 @@ primary_conninfo = 'host=db01 port=5432 user=postgres'
# Specifies a trigger file whose presence should cause streaming replication to
# end (i.e., failover).
-trigger_file = '/var/lib/postgresql/9.0/main/standby.trigger'
+trigger_file = '/var/lib/postgresql/9.1/main/standby.trigger'
# Specifies a command to load archive segments from the WAL archive. If
# wal_keep_segments is a high enough number to retain the WAL segments
# required for the standby server, this may not be necessary. But
# a large workload can cause segments to be recycled before the standby
# is fully synchronized, requiring you to start again from a new base backup.
-restore_command = 'rsync -a db01:/var/lib/postgresql/9.0/archive/%f "%p"'
+restore_command = 'rsync -a db01:/var/lib/postgresql/9.1/archive/%f "%p"'
@@ -38,15 +38,15 @@
# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.
-data_directory = '/var/lib/postgresql/9.0/main' # use data in another directory
+data_directory = '/var/lib/postgresql/9.1/main' # use data in another directory
# (change requires restart)
-hba_file = '/etc/postgresql/9.0/main/pg_hba.conf' # host-based authentication file
+hba_file = '/etc/postgresql/9.1/main/pg_hba.conf' # host-based authentication file
# (change requires restart)
-ident_file = '/etc/postgresql/9.0/main/pg_ident.conf' # ident configuration file
+ident_file = '/etc/postgresql/9.1/main/pg_ident.conf' # ident configuration file
# (change requires restart)
# If external_pid_file is not explicitly set, no extra PID file is written.
-external_pid_file = '/var/run/postgresql/9.0-main.pid' # write an extra PID file
+external_pid_file = '/var/run/postgresql/9.1-main.pid' # write an extra PID file
# (change requires restart)
View
@@ -269,8 +269,8 @@ def setup_db():
setup_db_motd()
copy_task_settings()
setup_memcached()
- # setup_postgres()
- setup_mongo()
+ setup_postgres(standby=False)
+ # setup_mongo()
setup_gunicorn(supervisor=False)
# setup_redis()
setup_db_munin()
@@ -575,7 +575,7 @@ def setup_memcached():
sudo('apt-get -y install memcached')
def setup_postgres(standby=False):
- shmmax = 577060864
+ shmmax = 580126400
sudo('apt-get -y install postgresql postgresql-client postgresql-contrib libpq-dev')
put('config/postgresql%s.conf' % (
('_standby' if standby else ''),
@@ -387,7 +387,6 @@ header {
.NB-story {
background-color: #FAFAFA;
- padding: 0 28px;
max-width: 800px;
border-right: 1px solid #909090;
border-bottom: 1px solid #909090;
@@ -397,7 +396,7 @@ header {
}
.NB-story-content {
- padding: 12px 200px 24px 0;
+ padding: 12px 200px 24px 28px;
position: relative;
}
@media all and (max-width: 800px) {
@@ -448,6 +447,9 @@ header {
/* = Shares and Comments = */
/* ======================= */
+.NB-story-comments-container {
+}
+
.NB-story-comments a {
text-decoration: none;
}
@@ -458,30 +460,30 @@ header {
border: none;
}
.NB-story-comments {
- margin: 0 0 32px 0;
- padding: 1px 0 0;
max-width: 800px;
- border-top: 2px solid #353535;
- border-bottom: 1px solid #353535;
+ border-top: 2px solid #626262;
+ border-bottom: 1px solid #C6C6C6;
font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
+ border-bottom-left-radius: 4px;
+ border-bottom-right-radius: 4px;
}
.NB-story-comment {
border-top: 1px solid #A6A6A6;
background-color: #FCFCFC;
position: relative;
- padding: 0 12px 2px 54px;
+ padding: 4px 28px 8px 80px;
line-height: 20px;
overflow: hidden;
}
.NB-story-comment .NB-user-avatar {
position: absolute;
- left: 6px;
- top: 6px;
+ left: 28px;
+ top: 10px;
cursor: pointer;
}
.NB-story-comment .NB-user-avatar.NB-story-comment-reshare {
- top: 22px;
- left: 6px;
+ top: 26px;
+ left: 28px;
z-index: 1;
}
.NB-story-comment .NB-user-avatar img {
@@ -500,13 +502,13 @@ header {
}
.NB-story-comment .NB-story-comment-reshares {
position: absolute;
- top: 0;
+ top: 0px;
left: 8px;
z-index: 0;
}
.NB-story-comment .NB-story-comment-reshares .NB-user-avatar {
- top: 8px;
- left: 12px;
+ top: 12px;
+ left: 36px;
}
.NB-story-comment .NB-story-comment-reshares .NB-user-avatar img {
width: 22px;
@@ -645,7 +647,7 @@ header {
font-weight: bold;
text-transform: uppercase;
font-size: 10px;
- padding: 2px 12px;
+ padding: 2px 28px;
overflow: hidden;
-webkit-transition: all .12s ease-out;
-moz-transition: all .12s ease-out;
@@ -656,10 +658,24 @@ header {
background-color: whiteSmoke;
color: #404040;
text-shadow: 0 1px 0 white;
+
+ background-image: -webkit-gradient(
+ linear,
+ left bottom,
+ left top,
+ color-stop(0.10, #EBEBEC),
+ color-stop(0.84, #F5F5F5)
+ );
+ background-image: -moz-linear-gradient(
+ center bottom,
+ #EBEBEC 10%,
+ #F5F5F5 84%
+ );
+
}
.NB-story-comments-shares-teaser-wrapper {
border-top: 0;
- padding-top: 0;
+ padding: 1px 0;
}
.NB-story-comments-shares-teaser {
@@ -670,13 +686,28 @@ header {
font-weight: bold;
text-transform: uppercase;
font-size: 10px;
- padding: 8px 12px 0px;
+/* padding: 8px 14px 0px;*/
+ padding: 8px 28px 0px;
overflow: hidden;
- height: 27px;
+ height: 26px;
-webkit-transition: all .12s ease-out;
-moz-transition: all .12s ease-out;
-o-transition: all .12s ease-out;
-ms-transition: all .12s ease-out;
+
+ background-image: -webkit-gradient(
+ linear,
+ left bottom,
+ left top,
+ color-stop(0.10, #EBEBEC),
+ color-stop(0.84, #F5F5F5)
+ );
+ background-image: -moz-linear-gradient(
+ center bottom,
+ #EBEBEC 10%,
+ #F5F5F5 84%
+ );
+
}
.NB-story-comments-public-teaser-wrapper:hover .NB-story-comments-public-teaser {
@@ -738,15 +769,12 @@ header {
.NB-feed-story-sideoptions-container {
position: absolute;
- right: 0px;
+ right: 28px;
bottom: 32px;
text-align: center;
- width: 172px;
+ width: 162px;
}
-.NB-feed-story-sideoptions-container {
-
-}
.NB-sideoption {
cursor: pointer;
position: relative;
@@ -8,12 +8,19 @@ NEWSBLUR.Models.Story = Backbone.Model.extend({
},
populate_comments: function(story, collection, changes) {
- var comments = this.get('comments');
+ var friend_comments = this.get('friend_comments');
+ var public_comments = this.get('public_comments');
if (!this.get('comment_count')) {
- delete this.comments;
- } else if (comments && comments.length) {
- this.comments = new NEWSBLUR.Collections.Comments(this.get('comments'));
+ delete this.friend_comments;
+ delete this.public_comments;
+ } else {
+ if (friend_comments && friend_comments.length) {
+ this.friend_comments = new NEWSBLUR.Collections.Comments(friend_comments);
+ }
+ if (public_comments && public_comments.length) {
+ this.public_comments = new NEWSBLUR.Collections.Comments(public_comments);
+ }
}
},
@@ -48,7 +55,9 @@ NEWSBLUR.Models.Story = Backbone.Model.extend({
},
change_selected: function(model, selected, changes) {
- model.collection.detect_selected_story(model, selected);
+ if (model.collection) {
+ model.collection.detect_selected_story(model, selected);
+ }
}
});
Oops, something went wrong.

0 comments on commit a82492f

Please sign in to comment.