mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-11-01 09:09:51 +00:00
Simplifying dashboard by including current user's profile photo, linking to their profile.
This commit is contained in:
parent
43045a85d7
commit
12ec0d1f05
11 changed files with 127 additions and 39 deletions
|
|
@ -95,7 +95,7 @@ def index(request, **kwargs):
|
|||
unmoderated_feeds = RecommendedFeed.objects.filter(is_public=False,
|
||||
declined_date__isnull=True).select_related('feed')[:2]
|
||||
statistics = MStatistics.all()
|
||||
user_statistics = MSocialProfile.user_statistics(user)
|
||||
social_profile = MSocialProfile.get_user(user.pk)
|
||||
|
||||
start_import_from_google_reader = request.session.get('import_from_google_reader', False)
|
||||
if start_import_from_google_reader:
|
||||
|
|
@ -112,7 +112,7 @@ def index(request, **kwargs):
|
|||
'recommended_feeds' : recommended_feeds,
|
||||
'unmoderated_feeds' : unmoderated_feeds,
|
||||
'statistics' : statistics,
|
||||
'user_statistics' : user_statistics,
|
||||
'social_profile' : social_profile,
|
||||
'start_import_from_google_reader': start_import_from_google_reader,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,21 +161,7 @@ class MSocialProfile(mongo.Document):
|
|||
self.save_popular_publishers(feed_publishers=feed_publishers[:-1])
|
||||
|
||||
@classmethod
|
||||
def user_statistics(cls, user):
|
||||
try:
|
||||
profile = cls.objects.get(user_id=user.pk)
|
||||
except cls.DoesNotExist:
|
||||
return None
|
||||
|
||||
values = {
|
||||
'followers': profile.follower_count,
|
||||
'following': profile.following_count,
|
||||
'shared_stories': profile.shared_stories_count,
|
||||
}
|
||||
return values
|
||||
|
||||
@classmethod
|
||||
def profile(cls, user_id):
|
||||
def profile(cls, user_id, include_follows=True):
|
||||
try:
|
||||
profile = cls.objects.get(user_id=user_id)
|
||||
except cls.DoesNotExist:
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ urlpatterns = patterns('',
|
|||
url(r'^feed_trainer', views.social_feed_trainer, name='social-feed-trainer'),
|
||||
url(r'^public_comments/?$', views.story_public_comments, name='story-public-comments'),
|
||||
url(r'^save_comment_reply/?$', views.save_comment_reply, name='social-save-comment-reply'),
|
||||
url(r'^remove_comment_reply/?$', views.remove_comment_reply, name='social-remove-comment-reply'),
|
||||
url(r'^find_friends/?$', views.find_friends, name='social-find-friends'),
|
||||
url(r'^like_comment/?$', views.like_comment, name='social-like-comment'),
|
||||
url(r'^remove_like_comment/?$', views.remove_like_comment, name='social-remove-like-comment'),
|
||||
|
|
|
|||
|
|
@ -463,12 +463,7 @@ def save_comment_reply(request):
|
|||
shared_story.replies.append(reply)
|
||||
shared_story.save()
|
||||
|
||||
comment = shared_story.comments_with_author()
|
||||
profile_user_ids = set([comment['user_id']])
|
||||
reply_user_ids = list(r['user_id'] for r in comment['replies'])
|
||||
profile_user_ids = profile_user_ids.union(reply_user_ids)
|
||||
profiles = MSocialProfile.objects.filter(user_id__in=list(profile_user_ids))
|
||||
profiles = [profile.to_json(compact=True) for profile in profiles]
|
||||
comment, profiles = shared_story.comment_with_author_and_profiles()
|
||||
|
||||
# Interaction for every other replier and original commenter
|
||||
MActivity.new_comment_reply(user_id=request.user.pk,
|
||||
|
|
@ -486,7 +481,8 @@ def save_comment_reply(request):
|
|||
story_id=story_id,
|
||||
story_feed_id=feed_id,
|
||||
story_title=shared_story.story_title)
|
||||
|
||||
|
||||
reply_user_ids = [reply['user_id'] for reply in comment['replies']]
|
||||
for user_id in set(reply_user_ids).difference([comment['user_id']]):
|
||||
if request.user.pk != user_id:
|
||||
MInteraction.new_reply_reply(user_id=user_id,
|
||||
|
|
@ -513,6 +509,76 @@ def save_comment_reply(request):
|
|||
'user_profiles': profiles
|
||||
})
|
||||
|
||||
@ajax_login_required
|
||||
def remove_comment_reply(request):
|
||||
code = 1
|
||||
feed_id = int(request.POST['story_feed_id'])
|
||||
story_id = request.POST['story_id']
|
||||
comment_user_id = request.POST['comment_user_id']
|
||||
reply_id = request.POST.get('reply_id')
|
||||
format = request.REQUEST.get('format', 'json')
|
||||
original_message = None
|
||||
|
||||
shared_story = MSharedStory.objects.get(user_id=comment_user_id,
|
||||
story_feed_id=feed_id,
|
||||
story_guid=story_id)
|
||||
replies = []
|
||||
for story_reply in shared_story.replies:
|
||||
if ((story_reply.user_id == request.user.pk or request.user.is_staff) and
|
||||
story_reply.reply_id == ObjectId(reply_id)):
|
||||
original_message = story_reply.comments
|
||||
# Skip reply
|
||||
else:
|
||||
replies.append(story_reply)
|
||||
shared_story.replies = replies
|
||||
shared_story.save()
|
||||
|
||||
logging.user(request, "~FCRemoving comment reply in ~FM%s: ~SB~FB%s~FM" % (
|
||||
shared_story.story_title[:20], original_message[:30]))
|
||||
|
||||
comment, profiles = shared_story.comment_with_author_and_profiles()
|
||||
|
||||
# # Interaction for every other replier and original commenter
|
||||
# MActivity.new_comment_reply(user_id=request.user.pk,
|
||||
# comment_user_id=comment['user_id'],
|
||||
# reply_content=reply_comments,
|
||||
# original_message=original_message,
|
||||
# story_id=story_id,
|
||||
# story_feed_id=feed_id,
|
||||
# story_title=shared_story.story_title)
|
||||
# if comment['user_id'] != request.user.pk:
|
||||
# MInteraction.new_comment_reply(user_id=comment['user_id'],
|
||||
# reply_user_id=request.user.pk,
|
||||
# reply_content=reply_comments,
|
||||
# original_message=original_message,
|
||||
# story_id=story_id,
|
||||
# story_feed_id=feed_id,
|
||||
# story_title=shared_story.story_title)
|
||||
#
|
||||
# reply_user_ids = [reply['user_id'] for reply in comment['replies']]
|
||||
# for user_id in set(reply_user_ids).difference([comment['user_id']]):
|
||||
# if request.user.pk != user_id:
|
||||
# MInteraction.new_reply_reply(user_id=user_id,
|
||||
# comment_user_id=comment['user_id'],
|
||||
# reply_user_id=request.user.pk,
|
||||
# reply_content=reply_comments,
|
||||
# original_message=original_message,
|
||||
# story_id=story_id,
|
||||
# story_feed_id=feed_id,
|
||||
# story_title=shared_story.story_title)
|
||||
|
||||
if format == 'html':
|
||||
comment = MSharedStory.attach_users_to_comment(comment, profiles)
|
||||
return render_to_response('social/story_comment.xhtml', {
|
||||
'comment': comment,
|
||||
}, context_instance=RequestContext(request))
|
||||
else:
|
||||
return json.json_response(request, {
|
||||
'code': code,
|
||||
'comment': comment,
|
||||
'user_profiles': profiles
|
||||
})
|
||||
|
||||
@render_to('social/mute_story.xhtml')
|
||||
def mute_story(request, secret_token, shared_story_id):
|
||||
user_profile = Profile.objects.get(secret_token=secret_token)
|
||||
|
|
|
|||
|
|
@ -4423,6 +4423,28 @@ form.opml_import_form input {
|
|||
padding-right: 12px;
|
||||
}
|
||||
|
||||
.NB-module-account .NB-module-item-image {
|
||||
position: relative;
|
||||
float: left;
|
||||
}
|
||||
.NB-module-account .NB-module-content-header,
|
||||
.NB-module-account .NB-module-item .NB-module-item-title {
|
||||
clear: none;
|
||||
overflow: hidden;
|
||||
margin-left: 0;
|
||||
}
|
||||
.NB-module-account .NB-module-item .NB-module-item-image img {
|
||||
width: 100px;
|
||||
margin-right: 14px;
|
||||
height: auto;
|
||||
border: none;
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
cursor: pointer;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
/* ======================= */
|
||||
/* = How it Works Module = */
|
||||
/* ======================= */
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ NEWSBLUR.Models.User = Backbone.Model.extend({
|
|||
url = url.replace(/_normal.(\w+)/, '.$1');
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
||||
blurblog_url: function() {
|
||||
return Inflector.sluggify(this.get('username')) + window.location.host.replace('www.', '');
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2231,6 +2231,7 @@
|
|||
},
|
||||
|
||||
open_social_profile_modal: function(user_id) {
|
||||
if (!user_id) user_id = NEWSBLUR.Globals.user_id;
|
||||
if (_.string.contains(user_id, 'social:')) {
|
||||
user_id = parseInt(user_id.replace('social:', ''), 10);
|
||||
}
|
||||
|
|
@ -4940,6 +4941,10 @@
|
|||
e.preventDefault();
|
||||
self.lock_mouse_indicator();
|
||||
});
|
||||
$.targetIs(e, { tagSelector: '.NB-load-user-profile' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.open_social_profile_modal();
|
||||
});
|
||||
$.targetIs(e, { tagSelector: '.NB-progress-close' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.hide_unfetched_feed_progress(true);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ _.extend(NEWSBLUR.ReaderSocialProfile.prototype, {
|
|||
this.$profile = new NEWSBLUR.Views.SocialProfileBadge({
|
||||
model: this.profile,
|
||||
embiggen: true,
|
||||
photo_size: 'large'
|
||||
photo_size: 'large',
|
||||
show_edit_button: true
|
||||
});
|
||||
|
||||
this.$modal = $.make('div', { className: 'NB-modal NB-modal-profile' }, [
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ NEWSBLUR.Views.SocialProfileBadge = Backbone.View.extend({
|
|||
'shared ',
|
||||
Inflector.pluralize('story', profile.get('shared_stories_count')),
|
||||
' · ',
|
||||
$.make('span', { className: 'NB-count' }, profile.get('follower_count')),
|
||||
Inflector.pluralize('follower', profile.get('follower_count'))
|
||||
$.make('a', { href: profile.blurblog_url(), target: "_blank", className: "NB-splash-link" }, profile.blurblog_url())
|
||||
]))
|
||||
])
|
||||
])
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if activity.category == 'comment_reply' %}
|
||||
<img class="NB-interaction-photo" src="/rss_feeds/icon/{{ activity.feed_id }}" data-feed-id="{{ activity.feed_id }}">
|
||||
<img class="NB-interaction-photo" src="{{ activity.photo_url }}" data-feed-id="{{ activity.feed_id }}">
|
||||
<div class="NB-interaction-date">
|
||||
{{ activity.time_since }} ago
|
||||
</div>
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if activity.category == 'feedsub' %}
|
||||
<img class="NB-interaction-photo" src="/rss_feeds/icon/{{ activity.feed_id }}">
|
||||
<img class="NB-interaction-photo" src="{{ activity.photo_url }}">
|
||||
<div class="NB-interaction-date">
|
||||
{{ activity.time_since }} ago
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -249,11 +249,15 @@
|
|||
Welcome, <span class="NB-module-account-username">{{ user.username }}</span>
|
||||
</h5>
|
||||
<div class="NB-module-item {% if train_count == active_count %}NB-last{% endif %}">
|
||||
<div class="NB-module-item-image">
|
||||
{% if user.profile.is_premium %}
|
||||
<img src="{{ MEDIA_URL }}/img/reader/account_premium_{{ account_images|random }}.jpg" />
|
||||
<div class="NB-module-item-image NB-load-user-profile">
|
||||
{% if social_profile.large_photo_url %}
|
||||
<img src="{{ social_profile.large_photo_url }}">
|
||||
{% else %}
|
||||
<img src="{{ MEDIA_URL }}/img/reader/account_standard_{{ account_images|random }}.jpg" />
|
||||
{% if user.profile.is_premium %}
|
||||
<img src="{{ MEDIA_URL }}/img/reader/account_premium_{{ account_images|random }}.jpg" />
|
||||
{% else %}
|
||||
<img src="{{ MEDIA_URL }}/img/reader/account_standard_{{ account_images|random }}.jpg" />
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<h3 class="NB-module-content-header">
|
||||
|
|
@ -266,18 +270,18 @@
|
|||
{% endif %}
|
||||
</h3>
|
||||
<div class="NB-module-item-title">
|
||||
<div class="NB-module-item NB-module-stats NB-module-account-stats {% if not user_statistics.shared_stories %}NB-hidden{% endif %}">
|
||||
<div class="NB-module-item NB-module-stats NB-module-account-stats {% if not social_profile.shared_stories_count %}NB-hidden{% endif %}">
|
||||
<div class="NB-module-stats-count NB-module-stats-count-shared-stories">
|
||||
<div class="NB-module-stats-count-number">{{ user_statistics.shared_stories|commify }}</div>
|
||||
<div class="NB-module-stats-count-description">Shared stor{{ user_statistics.shared_stories|pluralize:"y,ies" }}</div>
|
||||
<div class="NB-module-stats-count-number">{{ social_profile.shared_stories_count|commify }}</div>
|
||||
<div class="NB-module-stats-count-description">Shared stor{{ social_profile.shared_stories_count|pluralize:"y,ies" }}</div>
|
||||
</div>
|
||||
<div class="NB-module-stats-count NB-module-stats-count-following">
|
||||
<div class="NB-module-stats-count-number">{{ user_statistics.following|commify }}</div>
|
||||
<div class="NB-module-stats-count-number">{{ social_profile.following_count|commify }}</div>
|
||||
<div class="NB-module-stats-count-description">Following</div>
|
||||
</div>
|
||||
<div class="NB-module-stats-count NB-module-stats-count-followers">
|
||||
<div class="NB-module-stats-count-number">{{ user_statistics.followers|commify }}</div>
|
||||
<div class="NB-module-stats-count-description">Follower{{ user_statistics.followers|pluralize }}</div>
|
||||
<div class="NB-module-stats-count-number">{{ social_profile.follower_count|commify }}</div>
|
||||
<div class="NB-module-stats-count-description">Follower{{ social_profile.follower_count|pluralize }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue