mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Adding /social/activities endpoint for Android and iOS.
This commit is contained in:
parent
9b5d9bdea9
commit
5225395b40
4 changed files with 78 additions and 7 deletions
|
@ -11,6 +11,7 @@ urlpatterns = patterns('',
|
|||
url(r'^save_user_profile/?$', views.save_user_profile, name='save-user-profile'),
|
||||
url(r'^save_blurblog_settings/?$', views.save_blurblog_settings, name='save-blurblog-settings'),
|
||||
url(r'^interactions/?$', views.load_interactions, name='social-interactions'),
|
||||
url(r'^activities/?$', views.load_activities, name='social-activities'),
|
||||
url(r'^follow/?$', views.follow, name='social-follow'),
|
||||
url(r'^unfollow/?$', views.unfollow, name='social-unfollow'),
|
||||
url(r'^feed_trainer', views.social_feed_trainer, name='social-feed-trainer'),
|
||||
|
|
|
@ -800,3 +800,29 @@ def load_interactions(request):
|
|||
context_instance=RequestContext(request))
|
||||
else:
|
||||
return json.json_response(request, data)
|
||||
|
||||
def load_activities(request):
|
||||
user_id = request.REQUEST.get('user_id', None)
|
||||
if user_id:
|
||||
user_id = int(user_id)
|
||||
user = User.objects.get(pk=user_id)
|
||||
else:
|
||||
user = get_user(request)
|
||||
user_id = user.pk
|
||||
|
||||
public = user_id != request.user.pk
|
||||
page = max(1, int(request.REQUEST.get('page', 1)))
|
||||
activities = MActivity.user(user_id, page=page, public=public)
|
||||
format = request.REQUEST.get('format', None)
|
||||
|
||||
data = {
|
||||
'activities': activities,
|
||||
'page': page,
|
||||
'username': (user.username if public else 'You'),
|
||||
}
|
||||
|
||||
if format == 'html':
|
||||
return render_to_response('reader/activities_module.xhtml', data,
|
||||
context_instance=RequestContext(request))
|
||||
else:
|
||||
return json.json_response(request, data)
|
||||
|
|
|
@ -20,9 +20,8 @@ NEWSBLUR.Views.FeedListHeader = Backbone.View.extend({
|
|||
},
|
||||
|
||||
render: function() {
|
||||
if (!this.options.skip_count) {
|
||||
this.count();
|
||||
}
|
||||
this.count();
|
||||
|
||||
var hide_read_feeds = NEWSBLUR.assets.preference('hide_read_feeds');
|
||||
// NEWSBLUR.log(["render feed list header", this.collection.length, this.feeds_count, hide_read_feeds]);
|
||||
var $header = _.template('\
|
||||
|
@ -60,9 +59,7 @@ NEWSBLUR.Views.FeedListHeader = Backbone.View.extend({
|
|||
|
||||
count: function() {
|
||||
this.unread_counts = this.count_unreads_across_all_sites();
|
||||
if (!this.options.skip_sites) {
|
||||
this.feeds_count = this.count_feeds();
|
||||
}
|
||||
this.feeds_count = this.count_feeds();
|
||||
|
||||
if (NEWSBLUR.assets.preference('show_unread_counts_in_title')) {
|
||||
var title = '(';
|
||||
|
@ -87,7 +84,7 @@ NEWSBLUR.Views.FeedListHeader = Backbone.View.extend({
|
|||
|
||||
count_unreads_across_all_sites: function() {
|
||||
return this.collection.reduce(function(m, v) {
|
||||
if (v.get('active')) {
|
||||
if (v.get('active') && v.views && v.views.length) {
|
||||
m['positive'] += v.get('ps');
|
||||
m['neutral'] += v.get('nt');
|
||||
m['negative'] += v.get('ng');
|
||||
|
|
|
@ -341,6 +341,11 @@
|
|||
desc: "List of services to cross-post to. Can be 'twitter' and/or 'facebook'."
|
||||
optional: true
|
||||
example: "['twitter', 'facebook']"
|
||||
- key: format
|
||||
desc: "Return a JSON or HTML template"
|
||||
optional: true
|
||||
default: "json"
|
||||
example: "html"
|
||||
- url: /social/unshare_story
|
||||
method: POST
|
||||
short_desc: "Remove a shared story from user's blurblog."
|
||||
|
@ -357,6 +362,11 @@
|
|||
desc: "Story id to remove the existing share."
|
||||
required: true
|
||||
example: "http://blog.newsblur.com/post/1"
|
||||
- key: format
|
||||
desc: "Return a JSON or HTML template"
|
||||
optional: true
|
||||
default: "json"
|
||||
example: "html"
|
||||
- url: /social/load_user_friends
|
||||
method: GET
|
||||
short_desc: "Lists of user profiles: followers, followings, etc."
|
||||
|
@ -414,6 +424,33 @@
|
|||
desc: "4 interactions per page."
|
||||
optional: true
|
||||
example: "2"
|
||||
- key: format
|
||||
desc: "JSON or HTML template"
|
||||
optional: true
|
||||
default: "json"
|
||||
example: "html"
|
||||
- url: /social/activities
|
||||
method: GET
|
||||
short_desc: "A user's activities."
|
||||
long_desc:
|
||||
- "A user's activities: follows, shared stories, and replies to comments."
|
||||
- >
|
||||
Also includes starred stories and new site subscriptions if fetching the
|
||||
currently logged in user's activities.
|
||||
params:
|
||||
- key: user_id
|
||||
desc: "ID of user. Defaults to current logged in user."
|
||||
optional: true
|
||||
example: "42"
|
||||
- key: page
|
||||
desc: "4 activities per page."
|
||||
optional: true
|
||||
example: "2"
|
||||
- key: format
|
||||
desc: "JSON or HTML template"
|
||||
optional: true
|
||||
default: "json"
|
||||
example: "html"
|
||||
- url: /social/follow
|
||||
method: POST
|
||||
short_desc: "Follow a user and subscribe to their blurblog."
|
||||
|
@ -462,6 +499,11 @@
|
|||
desc: "ID of feed for the shared story."
|
||||
required: true
|
||||
example: "42"
|
||||
- key: format
|
||||
desc: "JSON or HTML template"
|
||||
optional: true
|
||||
default: "json"
|
||||
example: "html"
|
||||
- url: /social/save_comment_reply
|
||||
method: POST
|
||||
short_desc: "Saves a reply to a comment."
|
||||
|
@ -494,6 +536,11 @@
|
|||
reply can be overwritten.
|
||||
optional: true
|
||||
example: "Brilliant analysis, bro."
|
||||
- key: format
|
||||
desc: "Return a JSON or HTML template"
|
||||
optional: true
|
||||
default: "json"
|
||||
example: "html"
|
||||
- url: /social/find_friends
|
||||
method: GET
|
||||
short_desc: "Search for a user by username, email, or blurblog title."
|
||||
|
|
Loading…
Add table
Reference in a new issue