Probably a bit too much in one commit: allowing categories to be specified in interactions and activities calls so the iPad won't get category types it doesn't know how to handle. Also added twitter/facebook buttons to comment share on blurblogs.
|
@ -1657,12 +1657,16 @@ class MSocialServices(mongo.Document):
|
|||
}
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def get_user(cls, user_id):
|
||||
profile, created = cls.objects.get_or_create(user_id=user_id)
|
||||
if created:
|
||||
profile.save()
|
||||
return profile
|
||||
|
||||
@classmethod
|
||||
def profile(cls, user_id):
|
||||
try:
|
||||
profile = cls.objects.get(user_id=user_id)
|
||||
except cls.DoesNotExist:
|
||||
return {}
|
||||
profile = cls.get_user(user_id=user_id)
|
||||
return profile.to_json()
|
||||
|
||||
def twitter_api(self):
|
||||
|
@ -1898,13 +1902,18 @@ class MInteraction(mongo.Document):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def user(cls, user_id, page=1, limit=None):
|
||||
def user(cls, user_id, page=1, limit=None, categories=None):
|
||||
user_profile = Profile.objects.get(user=user_id)
|
||||
dashboard_date = user_profile.dashboard_date or user_profile.last_seen_on
|
||||
page = max(1, page)
|
||||
limit = int(limit) if limit else 4
|
||||
offset = (page-1) * limit
|
||||
interactions_db = cls.objects.filter(user_id=user_id)[offset:offset+limit+1]
|
||||
|
||||
interactions_db = cls.objects.filter(user_id=user_id)
|
||||
if categories:
|
||||
interactions_db = interactions_db.filter(category__in=categories)
|
||||
interactions_db = interactions_db[offset:offset+limit+1]
|
||||
|
||||
has_next_page = len(interactions_db) > limit
|
||||
interactions_db = interactions_db[offset:offset+limit]
|
||||
with_user_ids = [i.with_user_id for i in interactions_db if i.with_user_id]
|
||||
|
@ -2090,7 +2099,7 @@ class MActivity(mongo.Document):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def user(cls, user_id, page=1, limit=4, public=False):
|
||||
def user(cls, user_id, page=1, limit=4, public=False, categories=None):
|
||||
user_profile = Profile.objects.get(user=user_id)
|
||||
dashboard_date = user_profile.dashboard_date or user_profile.last_seen_on
|
||||
page = max(1, page)
|
||||
|
@ -2098,10 +2107,12 @@ class MActivity(mongo.Document):
|
|||
offset = (page-1) * limit
|
||||
|
||||
activities_db = cls.objects.filter(user_id=user_id)
|
||||
if categories:
|
||||
activities_db = activities_db.filter(category__in=categories)
|
||||
if public:
|
||||
activities_db = activities_db.filter(category__nin=['star', 'feedsub'])
|
||||
|
||||
activities_db = activities_db[offset:offset+limit+1]
|
||||
|
||||
has_next_page = len(activities_db) > limit
|
||||
activities_db = activities_db[offset:offset+limit]
|
||||
with_user_ids = [a.with_user_id for a in activities_db if a.with_user_id]
|
||||
|
|
|
@ -331,7 +331,9 @@ def load_social_page(request, user_id, username=None, **kwargs):
|
|||
user_social_profile = None
|
||||
if user.is_authenticated():
|
||||
user_social_profile = MSocialProfile.get_user(user.pk)
|
||||
user_social_services = MSocialServices.get_user(user.pk)
|
||||
social_profile = MSocialProfile.get_user(social_user_id)
|
||||
|
||||
params = dict(user_id=social_user.pk)
|
||||
if feed_id:
|
||||
params['story_feed_id'] = feed_id
|
||||
|
@ -350,6 +352,7 @@ def load_social_page(request, user_id, username=None, **kwargs):
|
|||
"feeds": {},
|
||||
"social_user": social_user,
|
||||
"social_profile": social_profile,
|
||||
"user_social_services": user_social_services,
|
||||
'user_social_profile' : json.encode(user_social_profile and user_social_profile.page()),
|
||||
}
|
||||
template = 'social/social_page.xhtml'
|
||||
|
@ -386,6 +389,8 @@ def load_social_page(request, user_id, username=None, **kwargs):
|
|||
'stories' : stories,
|
||||
'user_social_profile' : user_social_profile,
|
||||
'user_social_profile_page' : json.encode(user_social_profile and user_social_profile.page()),
|
||||
'user_social_services' : user_social_services,
|
||||
'user_social_services_page' : json.encode(user_social_services and user_social_services.to_json()),
|
||||
'social_profile': social_profile,
|
||||
'feeds' : feeds,
|
||||
'user_profile' : hasattr(user, 'profile') and user.profile,
|
||||
|
@ -735,6 +740,7 @@ def shared_stories_public(request, username):
|
|||
def profile(request):
|
||||
user = get_user(request.user)
|
||||
user_id = request.GET.get('user_id', user.pk)
|
||||
categories = request.GET.getlist('category')
|
||||
include_activities_html = request.REQUEST.get('include_activities_html', None)
|
||||
|
||||
user_profile = MSocialProfile.get_user(user_id)
|
||||
|
@ -743,7 +749,7 @@ def profile(request):
|
|||
profile_ids = set(user_profile['followers_youknow'] + user_profile['followers_everybody'] +
|
||||
user_profile['following_youknow'] + user_profile['following_everybody'])
|
||||
profiles = MSocialProfile.profiles(profile_ids)
|
||||
activities, _ = MActivity.user(user_id, page=1, public=True)
|
||||
activities, _ = MActivity.user(user_id, page=1, public=True, categories=categories)
|
||||
logging.user(request, "~BB~FRLoading social profile: %s" % user_profile['username'])
|
||||
|
||||
payload = {
|
||||
|
@ -1095,11 +1101,13 @@ def load_social_settings(request, social_user_id, username=None):
|
|||
@ajax_login_required
|
||||
def load_interactions(request):
|
||||
user_id = request.REQUEST.get('user_id', None)
|
||||
categories = request.GET.getlist('category')
|
||||
if not user_id:
|
||||
user_id = get_user(request).pk
|
||||
page = max(1, int(request.REQUEST.get('page', 1)))
|
||||
limit = request.REQUEST.get('limit')
|
||||
interactions, has_next_page = MInteraction.user(user_id, page=page, limit=limit)
|
||||
interactions, has_next_page = MInteraction.user(user_id, page=page, limit=limit,
|
||||
categories=categories)
|
||||
format = request.REQUEST.get('format', None)
|
||||
|
||||
data = {
|
||||
|
@ -1117,6 +1125,7 @@ def load_interactions(request):
|
|||
@ajax_login_required
|
||||
def load_activities(request):
|
||||
user_id = request.REQUEST.get('user_id', None)
|
||||
categories = request.GET.getlist('category')
|
||||
if user_id:
|
||||
user_id = int(user_id)
|
||||
user = User.objects.get(pk=user_id)
|
||||
|
@ -1127,7 +1136,8 @@ def load_activities(request):
|
|||
public = user_id != request.user.pk
|
||||
page = max(1, int(request.REQUEST.get('page', 1)))
|
||||
limit = request.REQUEST.get('limit', 4)
|
||||
activities, has_next_page = MActivity.user(user_id, page=page, limit=limit, public=public)
|
||||
activities, has_next_page = MActivity.user(user_id, page=page, limit=limit, public=public,
|
||||
categories=categories)
|
||||
format = request.REQUEST.get('format', None)
|
||||
|
||||
data = {
|
||||
|
|
|
@ -785,8 +785,9 @@ header {
|
|||
color: #404040;
|
||||
font-size: 13px;
|
||||
height: 28px;
|
||||
margin: 8px 0 0;
|
||||
margin: 8px 0 4px;
|
||||
border: 1px solid #C0C0C0;
|
||||
box-shadow: 2px 2px 0 #E3E8EB;
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
|
@ -797,6 +798,7 @@ header {
|
|||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
display: none;
|
||||
}
|
||||
.NB-story-comment-input-form .NB-modal-submit-button {
|
||||
|
@ -804,9 +806,9 @@ header {
|
|||
font-size: 12px;
|
||||
line-height: 19px;
|
||||
padding: 2px 16px;
|
||||
margin: 4px 12px 4px 0;
|
||||
z-index: 0;
|
||||
opacity: 0;
|
||||
margin: 4px 0 4px 0;
|
||||
-webkit-transition: opacity .44s ease-out;
|
||||
-moz-transition: opacity .44s ease-out;
|
||||
-o-transition: opacity .44s ease-out;
|
||||
|
@ -817,6 +819,46 @@ header {
|
|||
opacity: 1;
|
||||
}
|
||||
|
||||
.NB-story-comment-crossposts .NB-story-comment-crosspost-twitter,
|
||||
.NB-story-comment-crossposts .NB-story-comment-crosspost-facebook {
|
||||
float: left;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 10px 0 0 6px;
|
||||
opacity: .4;
|
||||
cursor: pointer;
|
||||
-webkit-filter: grayscale(100%);
|
||||
filter: gray;
|
||||
}
|
||||
.NB-story-comment-crossposts .NB-story-comment-crosspost-twitter:hover,
|
||||
.NB-story-comment-crossposts .NB-story-comment-crosspost-facebook:hover {
|
||||
opacity: .7;
|
||||
-webkit-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
.NB-story-comment-crossposts .NB-story-comment-crosspost-twitter.NB-active,
|
||||
.NB-story-comment-crossposts .NB-story-comment-crosspost-facebook.NB-active {
|
||||
opacity: 1;
|
||||
-webkit-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
.NB-story-comment-crossposts .NB-story-comment-crosspost-twitter {
|
||||
background: transparent url('/media/embed/reader/twitter_icon.png') no-repeat 0 0;
|
||||
}
|
||||
.NB-story-comment-crossposts .NB-story-comment-crosspost-facebook {
|
||||
background: transparent url('/media/embed/reader/facebook_icon.png') no-repeat 0 0;
|
||||
}
|
||||
.NB-story-comment-crossposts .NB-story-comment-crosspost-text {
|
||||
font-size: 9px;
|
||||
text-transform: uppercase;
|
||||
text-align: left;
|
||||
color: #7483A2;
|
||||
text-shadow: 0 1px 0 #FBFBFB;
|
||||
line-height: 16px;
|
||||
float: left;
|
||||
margin: 10px 0 0 8px;
|
||||
}
|
||||
|
||||
/* =================== */
|
||||
/* = Story Share Bar = */
|
||||
/* =================== */
|
||||
|
|
BIN
media/img/reader/facebook_button.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
media/img/reader/facebook_button@2x.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
media/img/reader/facebook_button_on.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
media/img/reader/facebook_button_on@2x.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
media/img/reader/twitter_button.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
media/img/reader/twitter_button@2x.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
media/img/reader/twitter_button_on.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
media/img/reader/twitter_button_on@2x.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
|
@ -1203,6 +1203,7 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
fetch_friends: function(callback) {
|
||||
this.make_request('/social/load_user_friends', null, _.bind(function(data) {
|
||||
this.user_profile.set(data.user_profile);
|
||||
this.social_services = data.services;
|
||||
this.follower_profiles = new NEWSBLUR.Collections.Users(data.follower_profiles);
|
||||
this.following_profiles = new NEWSBLUR.Collections.Users(data.following_profiles);
|
||||
callback(data);
|
||||
|
|
|
@ -61,7 +61,9 @@ NEWSBLUR.SocialPageAssets = Backbone.Router.extend({
|
|||
NEWSBLUR.Preferences[preference] = value;
|
||||
var preferences = {};
|
||||
preferences[preference] = value;
|
||||
this.make_request('/profile/set_preference', preferences, callback, null);
|
||||
this.make_request('/profile/set_preference', preferences, null, null, {
|
||||
request_type: 'POST'
|
||||
});
|
||||
},
|
||||
|
||||
mark_story_as_shared: function(params, callback, error_callback) {
|
||||
|
|
|
@ -11,7 +11,9 @@ NEWSBLUR.Views.SocialPageStory = Backbone.View.extend({
|
|||
"focus .NB-story-comment-input" : "focus_comment_input",
|
||||
// "blur .NB-story-comment-input" : "blur_comment_input"
|
||||
"keyup .NB-story-comment-input" : "keypress_comment_input",
|
||||
"click .NB-story-comment-save" : "mark_story_as_shared"
|
||||
"click .NB-story-comment-save" : "mark_story_as_shared",
|
||||
"click .NB-story-comment-crosspost-twitter" : "toggle_twitter",
|
||||
"click .NB-story-comment-crosspost-facebook" : "toggle_facebook"
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
|
@ -226,6 +228,25 @@ NEWSBLUR.Views.SocialPageStory = Backbone.View.extend({
|
|||
}, this));
|
||||
},
|
||||
|
||||
check_crosspost_buttons: function() {
|
||||
var $twitter = this.$('.NB-story-comment-crosspost-twitter');
|
||||
var $facebook = this.$('.NB-story-comment-crosspost-facebook');
|
||||
|
||||
if (!NEWSBLUR.user_social_services) return;
|
||||
|
||||
if (NEWSBLUR.user_social_services.twitter &&
|
||||
NEWSBLUR.user_social_services.twitter.twitter_uid) {
|
||||
$twitter.removeClass('NB-hidden');
|
||||
}
|
||||
if (NEWSBLUR.user_social_services.facebook &&
|
||||
NEWSBLUR.user_social_services.facebook.facebook_uid) {
|
||||
$facebook.removeClass('NB-hidden');
|
||||
}
|
||||
|
||||
$twitter.toggleClass('NB-active', !!NEWSBLUR.assets.preference('post_to_twitter'));
|
||||
$facebook.toggleClass('NB-active', !!NEWSBLUR.assets.preference('post_to_facebook'));
|
||||
},
|
||||
|
||||
// ==========
|
||||
// = Events =
|
||||
// ==========
|
||||
|
@ -265,7 +286,9 @@ NEWSBLUR.Views.SocialPageStory = Backbone.View.extend({
|
|||
// $form.toggleClass('NB-active', $input.is(':focus'));
|
||||
$buttons.css('display', 'block');
|
||||
$form.addClass('NB-active');
|
||||
this.check_crosspost_buttons();
|
||||
this.keypress_comment_input();
|
||||
this.reset_posting_label();
|
||||
},
|
||||
|
||||
blur_comment_input: function() {
|
||||
|
@ -295,6 +318,66 @@ NEWSBLUR.Views.SocialPageStory = Backbone.View.extend({
|
|||
|
||||
var input_width = $input.innerWidth();
|
||||
// Perform auto-height expansion
|
||||
},
|
||||
|
||||
toggle_twitter: function() {
|
||||
var $twitter_button = this.$('.NB-story-comment-crosspost-twitter');
|
||||
|
||||
if (NEWSBLUR.assets.preference('post_to_twitter')) {
|
||||
NEWSBLUR.assets.preference('post_to_twitter', false);
|
||||
} else {
|
||||
NEWSBLUR.assets.preference('post_to_twitter', true);
|
||||
}
|
||||
|
||||
$twitter_button.toggleClass('NB-active', NEWSBLUR.assets.preference('post_to_twitter'));
|
||||
this.reset_posting_label();
|
||||
},
|
||||
|
||||
toggle_facebook: function() {
|
||||
var $facebook_button = this.$('.NB-story-comment-crosspost-facebook');
|
||||
|
||||
if (NEWSBLUR.assets.preference('post_to_facebook')) {
|
||||
NEWSBLUR.assets.preference('post_to_facebook', false);
|
||||
} else {
|
||||
NEWSBLUR.assets.preference('post_to_facebook', true);
|
||||
}
|
||||
|
||||
$facebook_button.toggleClass('NB-active', NEWSBLUR.assets.preference('post_to_facebook'));
|
||||
this.reset_posting_label();
|
||||
},
|
||||
|
||||
show_twitter_posting_label: function() {
|
||||
this.show_posting_label(true, false);
|
||||
},
|
||||
|
||||
show_facebook_posting_label: function() {
|
||||
this.show_posting_label(false, true);
|
||||
},
|
||||
|
||||
reset_posting_label: function() {
|
||||
this.show_posting_label();
|
||||
},
|
||||
|
||||
show_posting_label: function(twitter, facebook) {
|
||||
var social_services = NEWSBLUR.user_social_services || {};
|
||||
var $text = this.$('.NB-story-comment-crosspost-text');
|
||||
twitter = twitter || (social_services.twitter && social_services.twitter.twitter_uid && NEWSBLUR.assets.preference('post_to_twitter'));
|
||||
facebook = facebook || (social_services.facebook && social_services.facebook.facebook_uid && NEWSBLUR.assets.preference('post_to_facebook'));
|
||||
|
||||
if (twitter || facebook) {
|
||||
var message = "Post to ";
|
||||
if (twitter && !facebook) {
|
||||
message += "Twitter";
|
||||
} else if (!twitter && facebook) {
|
||||
message += "Facebook";
|
||||
} else {
|
||||
message += "Twitter & FB";
|
||||
}
|
||||
|
||||
$text.text(message);
|
||||
} else {
|
||||
$text.text("");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
{% block body %}Say hello to your newest follower: {{ 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 }}
|
||||
|
||||
{% if common_followers %}
|
||||
You follow {{ common_followers|length }} {{ common_followers|pluralize:"person,people" }} who follow{{ common_followers|pluralize:"s," }} {{ follower_profile.username }}:
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
'MEDIA_URL' : "{{ MEDIA_URL }}",
|
||||
};
|
||||
NEWSBLUR.user_social_profile = {{ user_social_profile_page|safe }};
|
||||
NEWSBLUR.user_social_services = {{ user_social_services_page|safe }};
|
||||
NEWSBLUR.Preferences = {};
|
||||
NEWSBLUR.Models = {};
|
||||
NEWSBLUR.Collections = {};
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
<div class="NB-story-comment-buttons">
|
||||
<div class="NB-modal-submit-button NB-modal-submit-green NB-story-comment-save">Share this story</div>
|
||||
<div class="NB-modal-submit-button NB-modal-submit-red NB-story-comment-delete NB-hidden">Delete</div>
|
||||
<div class="NB-story-comment-crossposts">
|
||||
<div class="NB-story-comment-crosspost-twitter NB-hidden"></div>
|
||||
<div class="NB-story-comment-crosspost-facebook NB-hidden"></div>
|
||||
<div class="NB-story-comment-crosspost-text"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|