From 6a6c32df0274b254cc675f8bdac46ef3f3156bc1 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Fri, 26 Oct 2012 18:10:23 -0700 Subject: [PATCH] Adding privacy handling to social_page (blurblog). --- apps/social/templatetags/social_tags.py | 3 ++ media/css/reader.css | 2 +- media/css/social/social_page.css | 46 +++++++++++++++++++ media/js/newsblur/common/router.js | 6 +-- media/js/newsblur/reader/reader.js | 4 +- .../js/newsblur/reader/reader_feedchooser.js | 14 +++--- .../social_page/social_page_comment.js | 8 +++- .../social_page/social_page_comments.js | 3 +- .../newsblur/social_page/social_page_story.js | 3 +- templates/mail/email_base.txt | 4 +- templates/mail/email_follow_request.txt | 4 +- templates/mail/email_follow_request.xhtml | 9 +++- templates/social/social_page.xhtml | 2 + templates/social/story_comment.xhtml | 9 +++- templates/social/story_comments.xhtml | 20 ++++---- 15 files changed, 105 insertions(+), 32 deletions(-) diff --git a/apps/social/templatetags/social_tags.py b/apps/social/templatetags/social_tags.py index a008dcc05..824e6795d 100644 --- a/apps/social/templatetags/social_tags.py +++ b/apps/social/templatetags/social_tags.py @@ -42,10 +42,13 @@ def render_story_comments(context, story): @register.inclusion_tag('social/story_comment.xhtml', takes_context=True) def render_story_comment(context, story, comment): user = context['user'] + MEDIA_URL = settings.MEDIA_URL + return { 'user': user, 'story': story, 'comment': comment, + 'MEDIA_URL': MEDIA_URL, } @register.inclusion_tag('mail/email_story_comment.xhtml') diff --git a/media/css/reader.css b/media/css/reader.css index 6db7fec4b..b8a9193a2 100644 --- a/media/css/reader.css +++ b/media/css/reader.css @@ -6917,7 +6917,7 @@ form.opml_import_form input { background: transparent url('/media/embed/icons/silk/images.png') no-repeat 0 0; } .NB-modal-feedchooser .NB-feedchooser-premium-bullets li.NB-4 .NB-feedchooser-premium-bullet-image { - background: transparent url('/media/embed/icons/silk/magnifier.png') no-repeat 0 0; + background: transparent url('/media/embed/icons/silk/lock.png') no-repeat 0 0; } .NB-modal-feedchooser .NB-feedchooser-premium-bullets li.NB-5 .NB-feedchooser-premium-bullet-image { background: transparent url('/media/embed/icons/silk/lorry.png') no-repeat 0 0; diff --git a/media/css/social/social_page.css b/media/css/social/social_page.css index f4e658642..18a89356d 100644 --- a/media/css/social/social_page.css +++ b/media/css/social/social_page.css @@ -686,6 +686,52 @@ header { .NB-story-comment .NB-story-comment-reply-button:active .NB-story-comment-reply-button-wrapper { background-color: #9F3A00; } +.NB-story-comment .NB-story-comment-reply-button img { + padding-right: 6px; + width: 9px; + height: 9px; + vertical-align: bottom; + float: left; +} +.NB-story-comment .NB-story-comment-likes { + overflow: hidden; + height: 14px; + margin: 3px 2px 0; +} +.NB-story-comment .NB-story-comment-like { + float: left; + width: 16px; + background: transparent url('/media/embed/reader/star_grey.png') no-repeat center 0; + text-transform: uppercase; + padding: 1px 6px 1px 2px; + height: 11px; +} +.NB-story-comment .NB-story-comment-like:hover, +.NB-story-comment .NB-story-comment-like.NB-active { + cursor: pointer; + background: transparent url('/media/embed/reader/star_green.png') no-repeat center 0; +} +.NB-story-comment .NB-story-comment-like:active { + cursor: pointer; +} +.NB-story-comment .NB-story-comment-likes-users { + display: inline-block; +} +.NB-story-comment .NB-story-comment-likes-users .NB-story-share-profile .NB-user-avatar { + width: auto; + height: auto; +} +.NB-story-comment .NB-story-comment-likes-users .NB-story-share-profile .NB-user-avatar img { + width: 12px; + height: 12px; +} +.NB-story-comment .NB-story-comment-error { + float: left; + font-size: 10px; + color: #6A1000; + font-weight: bold; +} + .NB-story-comment-reply { border-top: 1px solid #E0E0E0; diff --git a/media/js/newsblur/common/router.js b/media/js/newsblur/common/router.js index cd4f018ec..02b543ad3 100644 --- a/media/js/newsblur/common/router.js +++ b/media/js/newsblur/common/router.js @@ -30,7 +30,7 @@ NEWSBLUR.Router = Backbone.Router.extend({ }, site: function(site_id, slug) { - // NEWSBLUR.log(["site", site_id, slug]); + NEWSBLUR.log(["site", site_id, slug]); site_id = parseInt(site_id, 10); var feed = NEWSBLUR.assets.get_feed(site_id); if (feed) { @@ -48,7 +48,7 @@ NEWSBLUR.Router = Backbone.Router.extend({ folder: function(folder_name) { folder_name = folder_name.replace(/-/g, ' '); - // NEWSBLUR.log(["folder", folder_name]); + NEWSBLUR.log(["folder", folder_name]); var options = {router: true}; if (folder_name == "everything") { NEWSBLUR.reader.open_river_stories(null, null, options); @@ -63,7 +63,7 @@ NEWSBLUR.Router = Backbone.Router.extend({ }, social: function(user_id, slug) { - // NEWSBLUR.log(["router:social", user_id, slug]); + NEWSBLUR.log(["router:social", user_id, slug]); var feed_id = "social:" + user_id; if (NEWSBLUR.assets.get_feed(feed_id)) { NEWSBLUR.reader.open_social_stories(feed_id, {router: true, force: true}); diff --git a/media/js/newsblur/reader/reader.js b/media/js/newsblur/reader/reader.js index b3972b965..d160688e4 100644 --- a/media/js/newsblur/reader/reader.js +++ b/media/js/newsblur/reader/reader.js @@ -1121,7 +1121,7 @@ var slug = _.string.words(_.string.clean(feed_title.replace(/[^a-z0-9\. ]/ig, ''))).join('-').toLowerCase(); var url = "site/" + feed.id + "/" + slug; if (!_.string.include(window.location.pathname, url)) { - // NEWSBLUR.log(["Navigating to url", url]); + NEWSBLUR.log(["Navigating to url", url]); NEWSBLUR.router.navigate(url); } } @@ -1576,7 +1576,7 @@ if (_.string.include(window.location.pathname, "social/" + feed.get('user_id'))) { params['replace'] = true; } - // NEWSBLUR.log(["Navigating to social", url, window.location.pathname]); + NEWSBLUR.log(["Navigating to social", url, window.location.pathname]); NEWSBLUR.router.navigate(url, params); } } else if (!feed.get('feed_title')) { diff --git a/media/js/newsblur/reader/reader_feedchooser.js b/media/js/newsblur/reader/reader_feedchooser.js index 452a1da43..e7aa4db02 100644 --- a/media/js/newsblur/reader/reader_feedchooser.js +++ b/media/js/newsblur/reader/reader_feedchooser.js @@ -31,7 +31,7 @@ NEWSBLUR.ReaderFeedchooser.prototype = { this.$modal = $.make('div', { className: 'NB-modal-feedchooser NB-modal' }, [ // $.make('h2', { className: 'NB-modal-title' }, 'Choose Your '+this.MAX_FEEDS), - $.make('div', { className: 'NB-feedchooser-type'}, [ + $.make('div', { className: 'NB-feedchooser-type NB-feedchooser-left'}, [ $.make('div', { className: 'NB-feedchooser-info'}, [ $.make('div', { className: 'NB-feedchooser-info-type' }, [ $.make('span', { className: 'NB-feedchooser-subtitle-type-prefix' }, 'Free'), @@ -84,7 +84,7 @@ NEWSBLUR.ReaderFeedchooser.prototype = { ]), $.make('li', { className: 'NB-4' }, [ $.make('div', { className: 'NB-feedchooser-premium-bullet-image' }), - 'First access to future features' + 'Privacy options for your blurblog' ]), $.make('li', { className: 'NB-5' }, [ $.make('div', { className: 'NB-feedchooser-premium-bullet-image' }), @@ -203,13 +203,13 @@ NEWSBLUR.ReaderFeedchooser.prototype = { }, resize_modal: function(previous_height) { - var height = this.$modal.height() + 16; - var parent_height = this.$modal.parent().height(); - if (height > parent_height && previous_height != height) { + var content_height = $('.NB-feedchooser-left', this.$modal).height() + 32; + var container_height = this.$modal.parent().height(); + if (content_height > container_height && previous_height != content_height) { var chooser_height = $('#NB-feedchooser-feeds').height(); - var diff = Math.max(4, height - parent_height); + var diff = Math.max(4, content_height - container_height); $('#NB-feedchooser-feeds').css({'max-height': chooser_height - diff}); - _.defer(_.bind(function() { this.resize_modal(height); }, this), 1); + _.defer(_.bind(function() { this.resize_modal(content_height); }, this), 1); } }, diff --git a/media/js/newsblur/social_page/social_page_comment.js b/media/js/newsblur/social_page/social_page_comment.js index bb32e418b..180b197da 100644 --- a/media/js/newsblur/social_page/social_page_comment.js +++ b/media/js/newsblur/social_page/social_page_comment.js @@ -50,7 +50,13 @@ NEWSBLUR.Views.SocialPageComment = Backbone.View.extend({ open_reply: function(options) { options = options || {}; var current_user = NEWSBLUR.assets.user_profile; - + + if (NEWSBLUR.Globals.blurblog_protected && !NEWSBLUR.Globals.blurblog_following) { + var $error = this.$('.NB-story-comment-error'); + $error.text("You must be following " + NEWSBLUR.Globals.blurblog_username + " to reply"); + return; + } + var $form = $.make('div', { className: 'NB-story-comment-reply NB-story-comment-reply-form' }, [ $.make('img', { className: 'NB-story-comment-reply-photo', src: current_user.get('photo_url') }), $.make('div', { className: 'NB-story-comment-username NB-story-comment-reply-username' }, current_user.get('username')), diff --git a/media/js/newsblur/social_page/social_page_comments.js b/media/js/newsblur/social_page/social_page_comments.js index 8105157e1..0bb66969a 100644 --- a/media/js/newsblur/social_page/social_page_comments.js +++ b/media/js/newsblur/social_page/social_page_comments.js @@ -30,7 +30,8 @@ NEWSBLUR.Views.SocialPageComments = Backbone.View.extend({ story: self.model, story_comments_view: self, story_view: self.story_view, - model: comment + model: comment, + public_comment: $comment.closest(".NB-story-comments-public").length }); self.comment_views.push(comment_view); }); diff --git a/media/js/newsblur/social_page/social_page_story.js b/media/js/newsblur/social_page/social_page_story.js index f00243787..5eb04410a 100644 --- a/media/js/newsblur/social_page/social_page_story.js +++ b/media/js/newsblur/social_page/social_page_story.js @@ -56,7 +56,8 @@ NEWSBLUR.Views.SocialPageStory = Backbone.View.extend({ }); $sideoptions.append($(this.share_view.template({ story: this.model, - social_services: NEWSBLUR.assets.social_services + social_services: NEWSBLUR.assets.social_services, + profile: NEWSBLUR.assets.user_profile }))); }, this), 50); } else { diff --git a/templates/mail/email_base.txt b/templates/mail/email_base.txt index e441cd5b1..c8f11e54b 100644 --- a/templates/mail/email_base.txt +++ b/templates/mail/email_base.txt @@ -1,6 +1,4 @@ -{% load utils_tags %} - -{% block body %}{% endblock body %} +{% load utils_tags %}{% block body %}{% endblock body %} ----------------------------------------------------------------------------- diff --git a/templates/mail/email_follow_request.txt b/templates/mail/email_follow_request.txt index 162c25134..d861c78e2 100644 --- a/templates/mail/email_follow_request.txt +++ b/templates/mail/email_follow_request.txt @@ -1,9 +1,11 @@ {% extends "mail/email_base.txt" %} +{% load utils_tags %} -{% block body %}Somebody wants to follow your Blurblog: {{ follower_profile.username }}. +{% block body %}You have a follow request: {{ follower_profile.username }}. {{ follower_profile.blurblog_url }} - {{ follower_profile.shared_stories_count }} shared {{ follower_profile.shared_stories_count|pluralize:"story,stories" }} - {{ follower_profile.follower_count }} follower{{ follower_profile.follower_count|pluralize }} +Approve or ignore this follow request on NewsBlur: http://{% current_domain %}{{ user.profile.autologin_url }} {% if common_followers %} You follow {{ common_followers|length }} {{ common_followers|pluralize:"person,people" }} who follow{{ common_followers|pluralize:"s," }} {{ follower_profile.username }}: diff --git a/templates/mail/email_follow_request.xhtml b/templates/mail/email_follow_request.xhtml index 912d5cdef..5792b0cb7 100644 --- a/templates/mail/email_follow_request.xhtml +++ b/templates/mail/email_follow_request.xhtml @@ -1,15 +1,20 @@ {% extends "mail/email_base.xhtml" %} +{% load utils_tags %} {% block body %}

- Somebody wants to follow your Blurblog: + You have a follow request:

{{ follower_profile.username }}
{{ follower_profile.shared_stories_count }} shared {{ follower_profile.shared_stories_count|pluralize:"story,stories" }} · {{ follower_profile.follower_count }} follower{{ follower_profile.follower_count|pluralize }}
- + +

+ Approve or ignore this follow request on NewsBlur. +

+ {% if common_followers %}

You follow {{ common_followers|length }} {{ common_followers|pluralize:"person,people" }} who follow{{ common_followers|pluralize:"s," }} {{ follower_profile.username }}:

diff --git a/templates/social/social_page.xhtml b/templates/social/social_page.xhtml index 055867393..e1cb05a21 100644 --- a/templates/social/social_page.xhtml +++ b/templates/social/social_page.xhtml @@ -31,6 +31,8 @@ 'user_id' : "{{ user.pk|safe }}", 'blurblog_user_id' : "{{ social_profile.user_id|safe }}", 'blurblog_username' : "{{ social_profile.username|safe }}", + 'blurblog_protected': {{ social_profile.protected|yesno:"true,false" }}, + 'blurblog_following': {{ user_following_social_profile|yesno:"true,false" }}, 'email' : "{{ user.email|safe }}", 'MEDIA_URL' : "{{ MEDIA_URL }}", }; diff --git a/templates/social/story_comment.xhtml b/templates/social/story_comment.xhtml index 81aab2de1..505662b2f 100644 --- a/templates/social/story_comment.xhtml +++ b/templates/social/story_comment.xhtml @@ -18,13 +18,20 @@ {% endif %}
{{ comment.shared_date }} ago
-
reply
+
+ {% if comment.user.protected %} + + {% endif %} + reply +
{% if comment.user_id == user.pk %}
edit
{% endif %} + {#
#} +
diff --git a/templates/social/story_comments.xhtml b/templates/social/story_comments.xhtml index 058add706..4a6a49529 100644 --- a/templates/social/story_comments.xhtml +++ b/templates/social/story_comments.xhtml @@ -31,17 +31,19 @@
- {% if story.comment_count_public %} -
-
- {{ story.comment_count_public }} public comment{{ story.comment_count_public|pluralize }} +
+ {% if story.comment_count_public %} +
+
+ {{ story.comment_count_public }} public comment{{ story.comment_count_public|pluralize }} +
-
- {% endif %} + {% endif %} - {% for comment in story.public_comments %} - {% render_story_comment story comment %} - {% endfor %} + {% for comment in story.public_comments %} + {% render_story_comment story comment %} + {% endfor %} +