def channel_browse(request, format='html'): per_page = CHANNELS_PER_PAGE prev_offset, _ = util.page_offset_nick(request) # Use +1 to identify if there are more that need to be displayed. channel_list = api.channel_browse(request.user, (per_page + 1), prev_offset) actors, more = util.page_actors(request, channel_list, per_page) offset_text = 'More' # for the Our Picks section of the sidebar ourpicks_channels = api.actor_get_channels_member(request.user, api.ROOT.nick) ourpicks_channels = api.channel_get_channels(request.user, ourpicks_channels) ourpicks_channels = [x for x in ourpicks_channels.values() if x] area = 'channel' c = template.RequestContext(request, locals()) # TODO(tyler): Other output formats. if format == 'html': t = loader.get_template('channel/templates/browse.html') return http.HttpResponse(t.render(c))
def actor_followers(request, nick=None, format='html'): nick = clean.nick(nick) view = api.actor_lookup_nick(request.user, nick) if not view: raise exception.UserDoesNotExistError(nick, request.user) handled = common_views.handle_view_action( request, { 'actor_add_contact': request.path, 'actor_remove_contact': request.path, }) if handled: return handled per_page = CONTACTS_PER_PAGE offset, prev = util.page_offset_nick(request) follower_nicks = api.actor_get_followers(request.user, view.nick, limit=(per_page + 1), offset=offset) actor_nicks = follower_nicks actors = api.actor_get_actors(request.user, actor_nicks) # clear deleted actors actors = dict([(k, v) for k, v in actors.iteritems() if v]) per_page = per_page - (len(follower_nicks) - len(actors)) # TODO(termie): incorporate this into paging so we only fetch the range # on this page # add some extra info so we can let the user do contextual actions # on these homeboys if request.user and request.user.nick == view.nick: for actor in actors: if api.actor_is_contact(request.user, view.nick, actor): actors[actor].my_contact = True whose = 'Your' else: whose = "%s's" % view.display_nick() # here comes lots of munging data into shape actor_tiles = [actors[x] for x in follower_nicks if x in actors] actor_tiles_count = view.extra.get('follower_count', 0) actor_tiles, actor_tiles_more = util.page_actors(request, actor_tiles, per_page) area = 'people' c = template.RequestContext(request, locals()) # TODO: Other output formats. if format == 'html': t = loader.get_template('actor/templates/followers.html') return http.HttpResponse(t.render(c))
def channel_members(request, nick=None, format='html'): nick = clean.channel(nick) view = api.actor_lookup_nick(request.user, nick) if not view: raise exception.UserDoesNotExistError(nick, request.user) handled = common_views.handle_view_action( request, { 'actor_add_contact': request.path, 'actor_remove_contact': request.path, }) if handled: return handled per_page = CONTACTS_PER_PAGE offset, prev = util.page_offset_nick(request) follower_nicks = api.channel_get_members(request.user, view.nick, limit=(per_page + 1), offset=offset) actor_nicks = follower_nicks actors = api.actor_get_actors(request.user, actor_nicks) # clear deleted actors actors = dict([(k, v) for k, v in actors.iteritems() if v]) per_page = per_page - (len(follower_nicks) - len(actors)) whose = "%s's" % view.display_nick() # here comes lots of munging data into shape actor_tiles = [actors[x] for x in follower_nicks if x in actors] actor_tiles_count = view.extra.get('member_count', 0) actor_tiles, actor_tiles_more = util.page_actors(request, actor_tiles, per_page) area = 'channels' c = template.RequestContext(request, locals()) # TODO: Other output formats. if format == 'html': t = loader.get_template('channel/templates/members.html') return http.HttpResponse(t.render(c))
def channel_members(request, nick=None, format='html'): nick = clean.channel(nick) view = api.actor_lookup_nick(request.user, nick) if not view: raise exception.UserDoesNotExistError(nick, request.user) handled = common_views.handle_view_action( request, { 'actor_add_contact': request.path, 'actor_remove_contact': request.path, }) if handled: return handled per_page = CONTACTS_PER_PAGE offset, prev = util.page_offset_nick(request) follower_nicks = api.channel_get_members(request.user, view.nick, limit=(per_page + 1), offset=offset) actor_nicks = follower_nicks actors = api.actor_get_actors(request.user, actor_nicks) # clear deleted actors actors = dict([(k, v) for k, v in actors.iteritems() if v]) per_page = per_page - (len(follower_nicks) - len(actors)) whose = "%s's" % view.display_nick() # here comes lots of munging data into shape actor_tiles = [actors[x] for x in follower_nicks if x in actors] actor_tiles_count = view.extra.get('member_count', 0) actor_tiles, actor_tiles_more = util.page_actors(request, actor_tiles, per_page) area = 'channels' c = template.RequestContext(request, locals()) if format == 'html': t = loader.get_template('channel/templates/members.html') return http.HttpResponse(t.render(c))
def channel_browse(request, format='html'): per_page = CHANNELS_PER_PAGE prev_offset, _ = util.page_offset_nick(request) # Use +1 to identify if there are more that need to be displayed. channel_list = api.channel_browse(request.user, (per_page+1), prev_offset) actors, more = util.page_actors(request, channel_list, per_page) offset_text = 'More' # for the Our Picks section of the sidebar ourpicks_channels = api.actor_get_channels_member(request.user, api.ROOT.nick) ourpicks_channels = api.channel_get_channels(request.user, ourpicks_channels) ourpicks_channels = [x for x in ourpicks_channels.values() if x] area = 'channel' c = template.RequestContext(request, locals()) # TODO(tyler): Other output formats. if format == 'html': t = loader.get_template('channel/templates/browse.html') return http.HttpResponse(t.render(c))
def actor_contacts(request, nick=None, format='html'): nick = clean.nick(nick) view = api.actor_lookup_nick(request.user, nick) if not view: raise exception.UserDoesNotExistError(nick, request.user) handled = common_views.handle_view_action( request, { 'actor_add_contact': request.path, 'actor_remove_contact': request.path, }) if handled: return handled per_page = CONTACTS_PER_PAGE offset, prev = util.page_offset_nick(request) contact_nicks = api.actor_get_contacts(request.user, view.nick, limit=(per_page + 1), offset=offset) actor_nicks = contact_nicks actors = api.actor_get_actors(request.user, actor_nicks) # clear deleted actors actors = dict([(k, v) for k, v in actors.iteritems() if v]) per_page = per_page - (len(contact_nicks) - len(actors)) # TODO(termie): incorporate this into paging so we only fetch the range # on this page # add some extra info so we can let the user do contextual actions # on these homeboys if request.user and request.user.nick == view.nick: # looking at self, find out who of these people follow me so # I can highlight them for actor in actors: if api.actor_is_follower(request.user, view.nick, actor): actors[actor].my_follower = True actors[actor].my_contact = True actors[actor].rel = 'contact' whose = 'Your' elif request.user: my_contacts_nicks = api.actor_get_contacts(request.user, request.user.nick) for f in my_contacts_nicks: try: actors[f].my_contact = True except: pass for x in actors: actors[x].rel = 'contact' whose = "%s's" % view.display_nick() # here comes lots of munging data into shape actor_tiles = [actors[x] for x in contact_nicks if x in actors] actor_tiles_count = view.extra.get('contact_count', 0) actor_tiles, actor_tiles_more = util.page_actors(request, actor_tiles, per_page) area = 'people' c = template.RequestContext(request, locals()) if format == 'html': t = loader.get_template('actor/templates/contacts.html') return http.HttpResponse(t.render(c)) elif format == 'json': t = loader.get_template('actor/templates/contacts.json') r = http.HttpResponse(t.render(c)) r['Content-type'] = 'text/javascript' return r