def explore_recent(request, format="html"): per_page = ENTRIES_PER_PAGE offset, prev = util.page_offset(request) inbox = api.inbox_get_explore(request.user, limit=(per_page + 1), offset=offset) # START inbox generation chaos # TODO(termie): refacccttttooorrrrr entries = api.entry_get_entries(request.user, inbox) per_page = per_page - (len(inbox) - len(entries)) entries, more = util.page_entries(request, entries, per_page) stream_keys = [e.stream for e in entries] streams = api.stream_get_streams(request.user, stream_keys) actor_nicks = [e.owner for e in entries] + [e.actor for e in entries] actors = api.actor_get_actors(request.user, actor_nicks) # here comes lots of munging data into shape streams = prep_stream_dict(streams, actors) entries = prep_entry_list(entries, streams, actors) # END inbox generation chaos area = 'explore' sidebar_green_top = True c = template.RequestContext(request, locals()) if format == 'html': t = loader.get_template('explore/templates/recent.html') return http.HttpResponse(t.render(c)) elif format == 'json': t = loader.get_template('explore/templates/recent.json') r = util.HttpJsonResponse(t.render(c), request) return r elif format == 'atom': t = loader.get_template('explore/templates/recent.atom') r = util.HttpAtomResponse(t.render(c), request) return r elif format == 'rss': t = loader.get_template('explore/templates/recent.rss') r = util.HttpRssResponse(t.render(c), request) return r
def explore_recent(request, format="html"): per_page = ENTRIES_PER_PAGE offset, prev = util.page_offset(request) inbox = api.inbox_get_explore(request.user, limit=(per_page + 1), offset=offset) # START inbox generation chaos # TODO(termie): refacccttttooorrrrr entries = api.entry_get_entries(request.user, inbox) per_page = per_page - (len(inbox) - len(entries)) entries, more = util.page_entries(request, entries, per_page) stream_keys = [e.stream for e in entries] streams = api.stream_get_streams(request.user, stream_keys) actor_nicks = [e.owner for e in entries] + [e.actor for e in entries] actors = api.actor_get_actors(request.user, actor_nicks) # here comes lots of munging data into shape streams = prep_stream_dict(streams, actors) entries = prep_entry_list(entries, streams, actors) # END inbox generation chaos area = 'explore' sidebar_green_top = True c = template.RequestContext(request, locals()) if format == 'html': t = loader.get_template('recent.html') return http.HttpResponse(t.render(c)); elif format == 'json': t = loader.get_template('recent.json') r = util.HttpJsonResponse(t.render(c), request) return r elif format == 'atom': t = loader.get_template('recent.atom') r = util.HttpAtomResponse(t.render(c), request) return r elif format == 'rss': t = loader.get_template('recent.rss') r = util.HttpRssResponse(t.render(c), request) return r
def front_front(request): logging.info("In the Frontpage") # if the user is logged in take them to their overview if request.user: url = request.user.url(request=request) return HttpResponseRedirect(url + "/overview") # NOTE: grab a bunch of extra so that we don't ever end up with # less than 5 per_page = ENTRIES_PER_PAGE * 2 inbox = api.inbox_get_explore(request.user, limit=per_page) featured_members = api.actor_get_random_actors(api.ROOT, FRONT_MEMBERS) random.shuffle(featured_members) root = api.ROOT area = 'frontpage' t = loader.get_template('front/templates/front.html') c = RequestContext(request, locals()) return HttpResponse(t.render(c));
def explore_recent(request, format="html"): if request.user: view = request.user logging.info("entering here") #twitter unauth = twitter.is_unauth(request) if 'twitter' in request.POST: if unauth: return http.HttpResponseRedirect('/twitter/auth?redirect_to=/') status = twitter.post_update(request) if status: flasherror = ["We have experimented some problems trying to post a cc in twitter"] handled = common_views.handle_view_action( request, { 'entry_remove': request.path, 'entry_remove_comment': request.path, 'entry_mark_as_spam': request.path, 'actor_add_contact': request.path, 'actor_remove_contact': request.path, 'post': request.path, 'presence_set': request.path, } ) if handled: return handled subtab = 'explore' per_page = ENTRIES_PER_PAGE offset, prev = util.page_offset(request) inbox = api.inbox_get_explore(request, limit=(per_page + 1), offset=offset) entries, more = helper.get_inbox_entries(request, inbox) stream_keys = [e.stream for e in entries] streams = api.stream_get_streams(request.user, stream_keys) actor_nicks = [e.owner for e in entries] + [e.actor for e in entries] actors = api.actor_get_actors(request.user, actor_nicks) # here comes lots of munging data into shape entries = prep_entry_list(entries, streams, actors) if request.user: channels_count = view.extra.get('channel_count', 0) channels_more = channels_count > CHANNELS_PER_PAGE followers_count = view.extra.get('follower_count', 0) contacts_count = view.extra.get('contact_count', 0) contacts_more = contacts_count > CONTACTS_PER_PAGE contact_nicks = api.actor_get_contacts_safe(request.user, view.nick, limit=CONTACTS_PER_PAGE) contacts = api.actor_get_actors(request.user, contact_nicks) contacts = [contacts[x] for x in contact_nicks if contacts[x]] green_top = True sidebar_green_top = True # END inbox generation chaos area = 'explore' actor_link = True c = template.RequestContext(request, locals()) if format == 'html': t = loader.get_template('explore/templates/recent.html') return http.HttpResponse(t.render(c)); elif format == 'json': t = loader.get_template('explore/templates/recent.json') r = util.HttpJsonResponse(t.render(c), request) return r elif format == 'atom': t = loader.get_template('explore/templates/recent.atom') r = util.HttpAtomResponse(t.render(c), request) return r elif format == 'rss': t = loader.get_template('explore/templates/recent.rss') r = util.HttpRssResponse(t.render(c), request) return r
def front_front(request): # if the user is logged in take them to their overview if request.user: return HttpResponseRedirect(request.user.url() + "/overview") # NOTE: grab a bunch of extra so that we don't ever end up with # less than 5 per_page = ENTRIES_PER_PAGE * 2 inbox = api.inbox_get_explore(request.user, limit=per_page) # START inbox generation chaos # TODO(termie): refacccttttooorrrrr entries = api.entry_get_entries(request.user, inbox) per_page = per_page - (len(inbox) - len(entries)) entries, more = util.page_entries(request, entries, per_page) stream_keys = [e.stream for e in entries] streams = api.stream_get_streams(request.user, stream_keys) actor_nicks = [e.owner for e in entries] + [e.actor for e in entries] actors = api.actor_get_actors(request.user, actor_nicks) # take it back down and don't show a more link entries = entries[:ENTRIES_PER_PAGE] more = None # here comes lots of munging data into shape streams = prep_stream_dict(streams, actors) entries = prep_entry_list(entries, streams, actors) # END inbox generation chaos try: # Featured Channels -- Ones to which the ROOT user is a member featured_channels = api.actor_get_channels_member( request.user, api.ROOT.nick, limit=SIDEBAR_FETCH_LIMIT) random.shuffle(featured_channels) # Just in case any are deleted: featured_channels = featured_channels[:2*SIDEBAR_LIMIT] featured_channels = api.channel_get_channels( request.user, featured_channels) featured_channels = [x for x in featured_channels.values() if x] featured_channels = featured_channels[:SIDEBAR_LIMIT] featured_members = api.actor_get_contacts( request.user, api.ROOT.nick, limit=SIDEBAR_FETCH_LIMIT) random.shuffle(featured_members) # Just in case any are deleted: featured_members = featured_members[:2*SIDEBAR_LIMIT] featured_members = api.actor_get_actors(request.user, featured_members) featured_members = [x for x in featured_members.values() if x] featured_members = featured_members[:SIDEBAR_LIMIT] except exception.ApiNotFound: pass root = api.ROOT area = 'frontpage' t = loader.get_template('front/templates/front.html') c = RequestContext(request, locals()) return HttpResponse(t.render(c));
def front_front(request): # if the user is logged in take them to their overview if request.user: url = request.user.url(request=request) return HttpResponseRedirect(url + "/overview") # NOTE: grab a bunch of extra so that we don't ever end up with # less than 5 per_page = ENTRIES_PER_PAGE * 2 inbox = api.inbox_get_explore(request.user, limit=per_page) # START inbox generation chaos # TODO(termie): refacccttttooorrrrr entries = api.entry_get_entries(request.user, inbox) per_page = per_page - (len(inbox) - len(entries)) entries, more = util.page_entries(request, entries, per_page) stream_keys = [e.stream for e in entries] streams = api.stream_get_streams(request.user, stream_keys) actor_nicks = [e.owner for e in entries] + [e.actor for e in entries] actors = api.actor_get_actors(request.user, actor_nicks) # take it back down and don't show a more link entries = entries[:ENTRIES_PER_PAGE] more = None # here comes lots of munging data into shape streams = prep_stream_dict(streams, actors) entries = prep_entry_list(entries, streams, actors) # END inbox generation chaos try: # Featured Channels -- Ones to which the ROOT user is a member featured_channels = api.actor_get_channels_member( request.user, api.ROOT.nick, limit=SIDEBAR_FETCH_LIMIT) random.shuffle(featured_channels) # Just in case any are deleted: featured_channels = featured_channels[:2*SIDEBAR_LIMIT] featured_channels = api.channel_get_channels( request.user, featured_channels) featured_channels = [x for x in featured_channels.values() if x] featured_channels = featured_channels[:SIDEBAR_LIMIT] featured_members = api.actor_get_contacts( request.user, api.ROOT.nick, limit=SIDEBAR_FETCH_LIMIT) random.shuffle(featured_members) # Just in case any are deleted: featured_members = featured_members[:2*SIDEBAR_LIMIT] featured_members = api.actor_get_actors(request.user, featured_members) featured_members = [x for x in featured_members.values() if x] featured_members = featured_members[:SIDEBAR_LIMIT] except exception.ApiNotFound: pass root = api.ROOT area = 'frontpage' t = loader.get_template('front/templates/front.html') c = RequestContext(request, locals()) return HttpResponse(t.render(c));