Exemplo n.º 1
0
def badge_badge(request, format, nick):
  view = api.actor_get(request.user, nick)
  
  presence = api.presence_get(request.user, view.nick)
  
  if not presence:
    # look offline please
    line = 'Offline'
    light = 'gray'
    location = ''
  else:
    line = presence.extra.get('status', 'Offline')
    light = presence.extra.get('light', 'gray')
    location = presence.extra.get('location', '')

  if format == 'image':
    # TODO: Create badge images
    return http.HttpResponseRedirect('/images/badge_%s.gif' % light)

  if format == 'js-small':
    multiline = len(line) > 17
    truncated_line = len(line) > 30 and "%s..." % (line[:27]) or line
    content_type = 'text/javascript'
    template_path = 'js_small.js'
  elif format == 'js-medium' or format == 'js-large':
    truncated_line = len(line) > 40 and "%s..." % (line[:27]) or line
    content_type = 'text/javascript'
    template_path = '%s.js' % format.replace('-', '_')
  elif format == 'json':
    # TODO: Create badge.json template
    content_type = 'application/json'
    template_path = 'badge.json'
  elif format == 'xml':
    content_type = 'application/xml'
    # TODO: Create badge.xml template
    template_path = 'badge.xml'

  c = template.RequestContext(request, locals())
  t = loader.get_template('badge/templates/%s' % template_path)
  r = http.HttpResponse(t.render(c))
  r['Content-type'] = content_type
  return r
Exemplo n.º 2
0
def badge_badge(request, format, nick):
  view = api.actor_get(request.user, nick)
  
  presence = api.presence_get(request.user, view.nick)
  
  if not presence:
    # look offline please
    line = 'Offline'
    light = 'gray'
    location = ''
  else:
    line = presence.extra.get('status', 'Offline')
    light = presence.extra.get('light', 'gray')
    location = presence.extra.get('location', '')

  if format == 'image':
    return http.HttpResponseRedirect('/images/badge_%s.gif' % light)

  if format == 'js-small':
    multiline = len(line) > 17
    truncated_line = len(line) > 30 and "%s..." % (line[:27]) or line
    content_type = 'text/javascript'
    template_path = 'js_small.js'
  elif format == 'js-medium' or format == 'js-large':
    truncated_line = len(line) > 40 and "%s..." % (line[:27]) or line
    content_type = 'text/javascript'
    template_path = '%s.js' % format.replace('-', '_')
  elif format == 'json':
    content_type = 'text/javascript'
    template_path = 'badge.json'

  elif format == 'xml':
    content_type = 'application/xml'
    template_path = 'badge.xml'

  c = template.RequestContext(request, locals())
  t = loader.get_template('badge/templates/%s' % template_path)
  r = http.HttpResponse(t.render(c))
  r['Content-type'] = content_type
  return r
Exemplo n.º 3
0
def channel_history(request, nick, format='html'):
  """ the page for a channel

  if the channel does not exist we go to create channel instead

  should let you join a channel or post to it if you already are a member
  also leave it if you are a member,
  display the posts to this channel and the member list if you are allowed
  to see them

  if you are an admin you should have the options to modify the channel
  """
  nick = clean.channel(nick)

  view = api.actor_lookup_nick(request.user, nick)
  if not view:
    return http.HttpResponseRedirect('/channel/create?channel=%s' % nick)

  admins = api.channel_get_admins(request.user, channel=view.nick)
  members = api.channel_get_members(request.user, channel=view.nick)

  handled = common_views.handle_view_action(
      request,
      {'channel_join': request.path,
       'channel_part': request.path,
       'channel_post': request.path,
       'entry_remove': request.path,
       'entry_remove_comment': request.path,
       'entry_mark_as_spam': request.path,
       'subscription_remove': request.path,
       'subscription_request': request.path,
       }
      )
  if handled:
    return handled

  privacy = 'public'

  user_can_post = False
  user_is_admin = False
  if not request.user:
    pass
  elif api.channel_has_admin(request.user, view.nick, request.user.nick):
    privacy = 'private'
    user_can_post = True
    user_is_admin = True
  elif api.channel_has_member(request.user, view.nick, request.user.nick):
    privacy = 'contacts'
    user_can_post = True

  per_page = CHANNEL_HISTORY_PER_PAGE
  offset, prev = util.page_offset(request)

  if privacy == 'public':
    inbox = api.inbox_get_actor_public(
        request.user,
        view.nick,
        limit=(per_page + 1),
        offset=offset)
  elif privacy == 'contacts':
    inbox = api.inbox_get_actor_contacts(
        request.user,
        view.nick,
        limit=(per_page + 1),
        offset=offset)
  elif privacy == 'private':
    inbox = api.inbox_get_actor_private(
        api.ROOT,
        view.nick,
        limit=(per_page + 1),
        offset=offset)

  # START inbox generation chaos
  # TODO(termie): refacccttttooorrrrr

  entries = api.entry_get_entries(request.user, inbox)
  # clear out deleted entries
  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]
  actor_streams = api.stream_get_actor(request.user, view.nick)
  stream_keys += [s.key().name() for s in actor_streams]
  streams = api.stream_get_streams(request.user, stream_keys)

  contact_nicks = api.actor_get_contacts(request.user, view.nick)
  actor_nicks = (contact_nicks +
                 admins +
                 members +
                 [view.nick] +
                 [s.owner for s in streams.values()] +
                 [e.actor for e in entries])
  actors = api.actor_get_actors(request.user, actor_nicks)

  # here comes lots of munging data into shape
  contacts = [actors[x] for x in contact_nicks if actors[x]]
  streams = display.prep_stream_dict(streams, actors)
  entries = display.prep_entry_list(entries, streams, actors)
  admins = [actors[x] for x in admins if actors[x]]
  members = [actors[x] for x in members if actors[x]]

  # END inbox generation chaos

  presence = api.presence_get(request.user, view.nick)

  # for sidebar_members
  members_count = view.extra['member_count']
  members_more = members_count > CONTACTS_PER_PAGE

  # for sidebar_admins
  admins_count = view.extra['admin_count']
  admins_more = admins_count > CONTACTS_PER_PAGE

  # config for templates
  green_top = True
  sidebar_green_top = True
  selectable_icons = display.SELECTABLE_ICONS


  # for sidebar streams (copied from actor/views.py.  refactor)
  view_streams = dict([(x.key().name(), streams[x.key().name()])
                       for x in actor_streams])
  if request.user:
    # un/subscribe buttons are possible only, when logged in

    # TODO(termie): what if there are quite a lot of streams?
    for stream in view_streams.values():
      stream.subscribed = api.subscription_exists(
          request.user,
          stream.key().name(),
          'inbox/%s/overview' % request.user.nick
          )

  area = 'channel'
  c = template.RequestContext(request, locals())

  if format == 'html':
    t = loader.get_template('channel/templates/history.html')
    return http.HttpResponse(t.render(c))
  elif format == 'json':
    t = loader.get_template('channel/templates/history.json')
    r = util.HttpJsonResponse(t.render(c), request)
    return r
  elif format == 'atom':
    t = loader.get_template('channel/templates/history.atom')
    r = util.HttpAtomResponse(t.render(c), request)
    return r
  elif format == 'rss':
    t = loader.get_template('channel/templates/history.rss')
    r = util.HttpRssResponse(t.render(c), request)
    return r
Exemplo n.º 4
0
def actor_history(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)

  called_subscribe, sub_ref = common_views.call_api_from_request(
      request, 'subscription_request')
  if called_subscribe:
    if sub_ref.state == 'subscribed':
      message = 'Subscribed.'
    else:
      message = 'Subscription requested.'
    return util.RedirectFlash(view.url(), message)

  handled = common_views.handle_view_action(
      request,
      { 'entry_remove': request.path,
        'entry_remove_comment': request.path,
        'entry_mark_as_spam': request.path,
        'subscription_remove': view.url(),
        'actor_add_contact': request.path,
        'actor_remove_contact': request.path,
        'post': request.path,
        'presence_set': request.path,
      }
  )
  if handled:
    return handled

  privacy = 'public'
  if request.user:
    if view.nick == request.user.nick:
      privacy = 'private'
    # ROOT because we care whether or not request.user is a contact of
    # the view user's, not whether the request.user can see the contacts
    elif api.actor_has_contact(api.ROOT, view.nick, request.user.nick):
      privacy = 'contacts'

  # we're going to hide a bunch of stuff if this user is private and we
  # aren't allowed to see
  user_is_private = False
  if view.privacy < models.PRIVACY_PUBLIC and privacy == 'public':
    user_is_private = True

  per_page = ENTRIES_PER_PAGE
  offset, prev = util.page_offset(request)

  if privacy == 'public':
    if user_is_private:
      inbox = []
    else:
      inbox = api.inbox_get_actor_public(request.user, view.nick,
                                         limit=(per_page + 1), offset=offset)
  elif privacy == 'contacts':
    inbox = api.inbox_get_actor_contacts(request.user, view.nick,
                                         limit=(per_page + 1), offset=offset)
  elif privacy == 'private':
    inbox = api.inbox_get_actor_private(request.user, view.nick,
                                        limit=(per_page + 1), offset=offset)

  actor_streams = api.stream_get_actor_safe(request.user, view.nick)

  entries, more = _get_inbox_entries(request, inbox)
  contacts, channels, streams, entries = _assemble_inbox_data(request,
                                                              entries,
                                                              actor_streams,
                                                              view)

  # If not logged in, cannot write
  is_owner = request.user and view.nick == request.user.nick

  try:
    presence = api.presence_get(request.user, view.nick)
    presence_stream = api.stream_get_presence(request.user, view.nick)
    last_entry = api.entry_get_last(request.user, presence_stream.keyname())
    view.last_entry = last_entry
  except exception.ApiException:
    pass


  # for add/remove contact
  if request.user:
    user_is_contact = api.actor_has_contact(request.user,
                                            request.user.nick,
                                            view.nick)
    view.my_contact = user_is_contact
  else:
    user_is_contact = False

  # for sidebar streams
  view_streams = _get_sidebar_streams(actor_streams, streams, request.user)

  # for sidebar_contacts
  contacts_count = view.extra.get('contact_count', 0)
  contacts_more = contacts_count > CONTACTS_PER_PAGE

  # for sidebar channels
  channels_count = view.extra.get('channel_count', 0)
  channels_more = channels_count > CHANNELS_PER_PAGE

  # Config for the template
  green_top = True
  sidebar_green_top = True
  selectable_icons = display.SELECTABLE_ICONS
  area = 'user'

  c = template.RequestContext(request, locals())

  if format == 'html':
    t = loader.get_template('actor/templates/history.html')
    return http.HttpResponse(t.render(c))
  elif format == 'json':
    t = loader.get_template('actor/templates/history.json')
    return util.HttpJsonResponse(t.render(c), request)
  elif format == 'atom':
    t = loader.get_template('actor/templates/history.atom')
    return util.HttpAtomResponse(t.render(c), request)
  elif format == 'rss':
    t = loader.get_template('actor/templates/history.rss')
    return util.HttpRssResponse(t.render(c), request)
Exemplo n.º 5
0
def actor_overview(request, nick, format='html'):
  nick = clean.nick(nick)

  view = api.actor_lookup_nick(request.user, nick)

  if not view:
    raise exception.UserDoesNotExistError(nick, request.user)

  if not request.user or view.nick != request.user.nick:
    # Instead of displaying the overview, redirect to the public-facing page
    return http.HttpResponseRedirect(view.url())

  handled = common_views.handle_view_action(
      request,
      { 
        'entry_remove': request.path,
        'entry_remove_comment': request.path,
        'entry_mark_as_spam': request.path,
        'presence_set': request.path,
        'settings_hide_comments': request.path,
        'post': request.path,
      }
  )
  if handled:
    return handled

  per_page = ENTRIES_PER_PAGE
  offset, prev = util.page_offset(request)

  inbox = api.inbox_get_actor_overview(request.user,  
                                       view.nick,
                                       limit=(per_page + 1), 
                                       offset=offset)

  actor_streams = api.stream_get_actor(request.user, view.nick)
  entries, more = _get_inbox_entries(request, inbox,
                                     view.extra.get('comments_hide', 0))
  contacts, channels, streams, entries = _assemble_inbox_data(request,
                                                              entries,
                                                              actor_streams,
                                                              view)

  # Check for unconfirmed emails
  unconfirmeds = api.activation_get_actor_email(request.user, view.nick)
  if unconfirmeds:
    unconfirmed_email = unconfirmeds[0].content

  # If not logged in, cannot write
  is_owner = False
  try:
    is_owner = view.nick == request.user.nick
  except:
    pass
  presence = api.presence_get(request.user, view.nick)

  # for sidebar streams
  view_streams = _get_sidebar_streams(actor_streams, streams)

  # for sidebar_contacts
  contacts_count = view.extra.get('contact_count', 0)
  contacts_more = contacts_count > CONTACTS_PER_PAGE

  # for sidebar channels
  channels_count = view.extra.get('channel_count', 0)
  channels_more = channels_count > CHANNELS_PER_PAGE

  # Config for the template
  green_top = True
  sidebar_green_top = True
  selectable_icons = display.SELECTABLE_ICONS

  area = 'home'

  # TODO(tyler/termie):  This conflicts with the global settings import.
  # Also, this seems fishy.  Do none of the settings.* items work in templates?
  import settings
  
  c = template.RequestContext(request, locals())

  if format == 'html':
    t = loader.get_template('actor/templates/overview.html')
    return http.HttpResponse(t.render(c))
  elif format == 'json':
    t = loader.get_template('actor/templates/overview.json')
    return util.HttpJsonResponse(t.render(c), request)
  elif format == 'atom':
    t = loader.get_template('actor/templates/overview.atom')
    return util.HttpAtomResponse(t.render(c), request)
  elif format == 'rss':
    t = loader.get_template('actor/templates/overview.rss')
    return util.HttpRssResponse(t.render(c), request)
Exemplo n.º 6
0
def actor_history(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)

    called_subscribe, sub_ref = common_views.call_api_from_request(
        request, 'subscription_request')
    if called_subscribe:
        if sub_ref.state == 'subscribed':
            message = 'Subscribed.'
        else:
            message = 'Subscription requested.'
        return util.RedirectFlash(view.url(), message)

    handled = common_views.handle_view_action(
        request, {
            'entry_remove': request.path,
            'entry_remove_comment': request.path,
            'entry_mark_as_spam': request.path,
            'subscription_remove': view.url(),
            'actor_add_contact': request.path,
            'actor_remove_contact': request.path,
            'post': request.path,
            'presence_set': request.path,
        })
    if handled:
        return handled

    privacy = 'public'
    if request.user:
        if view.nick == request.user.nick:
            privacy = 'private'
        # ROOT because we care whether or not request.user is a contact of
        # the view user's, not whether the request.user can see the contacts
        elif api.actor_has_contact(api.ROOT, view.nick, request.user.nick):
            privacy = 'contacts'

    # we're going to hide a bunch of stuff if this user is private and we
    # aren't allowed to see
    user_is_private = False
    if view.privacy < models.PRIVACY_PUBLIC and privacy == 'public':
        user_is_private = True

    per_page = ENTRIES_PER_PAGE
    offset, prev = util.page_offset(request)

    if privacy == 'public':
        if user_is_private:
            inbox = []
        else:
            inbox = api.inbox_get_actor_public(request.user,
                                               view.nick,
                                               limit=(per_page + 1),
                                               offset=offset)
    elif privacy == 'contacts':
        inbox = api.inbox_get_actor_contacts(request.user,
                                             view.nick,
                                             limit=(per_page + 1),
                                             offset=offset)
    elif privacy == 'private':
        inbox = api.inbox_get_actor_private(request.user,
                                            view.nick,
                                            limit=(per_page + 1),
                                            offset=offset)

    actor_streams = api.stream_get_actor_safe(request.user, view.nick)

    entries, more = _get_inbox_entries(request, inbox)
    contacts, channels, streams, entries = _assemble_inbox_data(
        request, entries, actor_streams, view)

    # If not logged in, cannot write
    is_owner = request.user and view.nick == request.user.nick

    try:
        presence = api.presence_get(request.user, view.nick)
        presence_stream = api.stream_get_presence(request.user, view.nick)
        last_entry = api.entry_get_last(request.user,
                                        presence_stream.keyname())
        view.last_entry = last_entry
    except exception.ApiException:
        pass

    # for add/remove contact
    if request.user:
        user_is_contact = api.actor_has_contact(request.user,
                                                request.user.nick, view.nick)
        view.my_contact = user_is_contact
    else:
        user_is_contact = False

    # for sidebar streams
    view_streams = _get_sidebar_streams(actor_streams, streams, request.user)

    # for sidebar_contacts
    contacts_count = view.extra.get('contact_count', 0)
    contacts_more = contacts_count > CONTACTS_PER_PAGE

    # for sidebar channels
    channels_count = view.extra.get('channel_count', 0)
    channels_more = channels_count > CHANNELS_PER_PAGE

    # Config for the template
    green_top = True
    sidebar_green_top = True
    selectable_icons = display.SELECTABLE_ICONS
    area = 'user'

    c = template.RequestContext(request, locals())

    if format == 'html':
        t = loader.get_template('actor/templates/history.html')
        return http.HttpResponse(t.render(c))
    elif format == 'json':
        t = loader.get_template('actor/templates/history.json')
        return util.HttpJsonResponse(t.render(c), request)
    elif format == 'atom':
        t = loader.get_template('actor/templates/history.atom')
        return util.HttpAtomResponse(t.render(c), request)
    elif format == 'rss':
        t = loader.get_template('actor/templates/history.rss')
        return util.HttpRssResponse(t.render(c), request)
Exemplo n.º 7
0
def actor_overview(request, nick, format='html'):
    nick = clean.nick(nick)

    view = api.actor_lookup_nick(request.user, nick)

    if not view:
        raise exception.UserDoesNotExistError(nick, request.user)

    if not request.user or view.nick != request.user.nick:
        # Instead of displaying the overview, redirect to the public-facing page
        return http.HttpResponseRedirect(view.url())

    handled = common_views.handle_view_action(
        request, {
            'entry_remove': request.path,
            'entry_remove_comment': request.path,
            'entry_mark_as_spam': request.path,
            'presence_set': request.path,
            'settings_hide_comments': request.path,
            'post': request.path,
        })
    if handled:
        return handled

    per_page = ENTRIES_PER_PAGE
    offset, prev = util.page_offset(request)

    inbox = api.inbox_get_actor_overview(request.user,
                                         view.nick,
                                         limit=(per_page + 1),
                                         offset=offset)

    actor_streams = api.stream_get_actor(request.user, view.nick)
    entries, more = _get_inbox_entries(request, inbox,
                                       view.extra.get('comments_hide', 0))
    contacts, channels, streams, entries = _assemble_inbox_data(
        request, entries, actor_streams, view)

    # Check for unconfirmed emails
    unconfirmeds = api.activation_get_actor_email(request.user, view.nick)
    if unconfirmeds:
        unconfirmed_email = unconfirmeds[0].content

    # If not logged in, cannot write
    is_owner = False
    try:
        is_owner = view.nick == request.user.nick
    except:
        pass
    presence = api.presence_get(request.user, view.nick)

    # for sidebar streams
    view_streams = _get_sidebar_streams(actor_streams, streams)

    # for sidebar_contacts
    contacts_count = view.extra.get('contact_count', 0)
    contacts_more = contacts_count > CONTACTS_PER_PAGE

    # for sidebar channels
    channels_count = view.extra.get('channel_count', 0)
    channels_more = channels_count > CHANNELS_PER_PAGE

    # Config for the template
    green_top = True
    sidebar_green_top = True
    selectable_icons = display.SELECTABLE_ICONS

    area = 'home'

    # TODO(tyler/termie):  This conflicts with the global settings import.
    # Also, this seems fishy.  Do none of the settings.* items work in templates?
    import settings

    c = template.RequestContext(request, locals())

    if format == 'html':
        t = loader.get_template('actor/templates/overview.html')
        return http.HttpResponse(t.render(c))
    elif format == 'json':
        t = loader.get_template('actor/templates/overview.json')
        return util.HttpJsonResponse(t.render(c), request)
    elif format == 'atom':
        t = loader.get_template('actor/templates/overview.atom')
        return util.HttpAtomResponse(t.render(c), request)
    elif format == 'rss':
        t = loader.get_template('actor/templates/overview.rss')
        return util.HttpRssResponse(t.render(c), request)
Exemplo n.º 8
0
def actor_overview(request, nick, format='html'):
  nick = clean.nick(nick)

  view = api.actor_lookup_nick(request.user, nick)

  if not view:
    raise exception.UserDoesNotExistError(nick, request.user)

  if not request.user or view.nick != request.user.nick:
    # Instead of displaying the overview, redirect to the public-facing page
    return http.HttpResponseRedirect(view.url())


  unauth = twitter.is_unauth(request)
  twitter_options = twitter.twitter_options(request)
  if 'twitter' in request.POST:
    if unauth:
      return http.HttpResponseRedirect('/twitter/auth?redirect_to=/%s/overview' % view.display_nick())
    status = twitter.post_update(request)
    if status:
      flasherror = ["We have experimented some problems trying to post a cc in twitter"]

  logging.info('Overview request.path: %s' % request.path)
  handled = common_views.handle_view_action(
      request,
      { 
        'entry_remove': request.path,
        'entry_remove_comment': request.path,
        'entry_mark_as_spam': request.path,
        'presence_set': request.path,
        'settings_hide_comments': request.path,
        'post': request.path,
      }
  )
  logging.info('handled: %s' % handled)
  if handled:
    return handled

  per_page = ENTRIES_PER_PAGE
  offset, prev = util.page_offset(request)
  
  inbox = api.inbox_get_actor_overview(request.user,
                                       view.nick,
                                       limit=(per_page + 1),
                                       offset=offset)

  actor_streams = api.stream_get_actor(request.user, view.nick)
  entries, more = helper.get_inbox_entries(request, inbox, False, per_page, True, view)
  contacts, channels, streams, entries = helper.assemble_inbox_data(request, entries, actor_streams, view)

  latest = api.inbox_get_actor_private(request.user, view.nick, per_page)
  latest = api.entry_get_entries(request.user, latest)
  if len(latest) > 0:
    latest = latest[0]
    
  # Check for unconfirmed emails
  unconfirmeds = api.activation_get_actor_email(request.user, view.nick)
  if unconfirmeds:
    unconfirmed_email = unconfirmeds[0].content

  first_time, emailform = api.is_first_time(request.user, view.nick)
  loadmodal = first_time

  # If not logged in, cannot write
  is_owner = False
  try:
    is_owner = view.nick == request.user.nick
  except:
    pass
  presence = api.presence_get(request.user, view.nick)

  # for sidebar streams
  view_streams = dict([(x.key().name(), streams[x.key().name()])
                       for x in actor_streams])

  #@begin zero code OVERVIEW
  # for sidebar info
  channels_count = view.extra.get('channel_count', 0)
  channels_more = channels_count > CHANNELS_PER_PAGE
  followers_count = view.extra.get('follower_count', 0)
  #@end

  # for sidebar_contacts
  contacts_count = view.extra.get('contact_count', 0)
  contacts_more = contacts_count > CONTACTS_PER_PAGE

  # Config for the template
  green_top = True
  sidebar_green_top = True
  selectable_icons = display.SELECTABLE_ICONS
  actor_link = True

  area = 'home'
  subtab = 'overview'

  # TODO(tyler/termie):  This conflicts with the global settings import.
  # Also, this seems fishy.  Do none of the settings.* items work in templates?
  c = template.RequestContext(request, locals())

  if format == 'html':
    t = loader.get_template('actor/templates/overview.html')
    r = http.HttpResponse(t.render(c))
  elif format == 'json':
    t = loader.get_template('actor/templates/overview.json')
    r = util.HttpJsonResponse(t.render(c), request)
  elif format == 'atom':
    t = loader.get_template('actor/templates/overview.atom')
    r = util.HttpAtomResponse(t.render(c), request)
  elif format == 'rss':
    t = loader.get_template('actor/templates/overview.rss')
    r = util.HttpRssResponse(t.render(c), request)
  return r
Exemplo n.º 9
0
def actor_mentions(request, nick, format='html'):
  nick = clean.nick(nick)

  view = api.actor_lookup_nick(request.user, nick)

  if not view:
    raise exception.UserDoesNotExistError(nick, request.user)

  if not request.user or view.nick != request.user.nick:
    return http.HttpResponseRedirect(view.url())

  unauth = twitter.is_unauth(request)
  twitter_options = twitter.twitter_options(request)
  if 'twitter' in request.POST:
    if unauth:
      return http.HttpResponseRedirect('/twitter/auth?redirect_to=/%s/mentions' % view.display_nick())
    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,
        'presence_set': request.path,
        'settings_hide_comments': request.path,
        'post': request.path,
      }
  )
  if handled:
    return handled

  per_page = ENTRIES_PER_PAGE
  offset, prev = util.page_offset(request)

  inbox = api.inbox_get_actor_mentions(request.user,
                                       view.nick,
                                       limit=(per_page + 1), 
                                       offset=offset)

  # START inbox generation chaos
  # TODO(termie): refacccttttooorrrrr
  entries = api.entry_get_entries(request.user, inbox)

  #begin @zero code
  #if view.extra.get('comments_hide', 0):
    # TODO(tyler): This is certainly not the most eloquent way to filter
    # through entries to remove comments.
    # entries = [x for x in entries if not x.stream.endswith('comments')]
  entries = api.filter_entries_mentions(request.user, entries, view.nick)

  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]
  actor_streams = api.stream_get_actor(request.user, view.nick)
  stream_keys += [s.key().name() for s in actor_streams]
  streams = api.stream_get_streams(request.user, stream_keys)

  contact_nicks = api.actor_get_contacts(request.user, 
                                         view.nick, 
                                         limit=CONTACTS_PER_PAGE)
  actor_nicks = (contact_nicks +
                 [view.nick] +
                 [s.owner for s in streams.values()] +
                 [e.owner for e in entries] +
                 [e.actor for e in entries])
  actors = api.actor_get_actors(request.user, actor_nicks)

  channels = api.actor_get_channels_member(request.user, view.nick,
                                limit=(CHANNELS_PER_PAGE + 1))

  # here comes lots of munging data into shape
  # clear deleted contacts
  contacts = [actors[x] for x in contact_nicks if actors[x]]
  streams = display.prep_stream_dict(streams, actors)
  entries = display.prep_entry_list(entries, streams, actors)

  # END inbox generation chaos
  
  # Check for unconfirmed emails
  unconfirmeds = api.activation_get_actor_email(request.user, view.nick)
  if unconfirmeds:
    unconfirmed_email = unconfirmeds[0].content

  # If not logged in, cannot write
  is_owner = False
  try:
    is_owner = view.nick == request.user.nick
  except:
    pass
  presence = api.presence_get(request.user, view.nick)

  # for sidebar streams
  view_streams = dict([(x.key().name(), streams[x.key().name()])
                       for x in actor_streams])

  channels_count = view.extra.get('channel_count', 0)
  channels_more = channels_count > CHANNELS_PER_PAGE
  followers_count = view.extra.get('follower_count', 0)

  # for sidebar_contacts
  contacts_count = view.extra.get('contact_count', 0)
  contacts_more = contacts_count > CONTACTS_PER_PAGE

  # Config for the template
  green_top = True
  sidebar_green_top = True
  selectable_icons = display.SELECTABLE_ICONS

  area = 'mentions'
  subtab = 'mentions'

  # TODO(tyler/termie):  This conflicts with the global settings import.
  # Also, this seems fishy.  Do none of the settings.* items work in templates?
  import settings
  
  c = template.RequestContext(request, locals())

  if format == 'html':
    t = loader.get_template('actor/templates/mentions.html')
    return http.HttpResponse(t.render(c))
Exemplo n.º 10
0
def actor_history(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)

    called_subscribe, sub_ref = common_views.call_api_from_request(
        request, 'subscription_request')
    if called_subscribe:
        if sub_ref.state == 'subscribed':
            message = 'Subscribed.'
        else:
            message = 'Subscription requested.'
        return util.RedirectFlash(view.url(), message)

    handled = common_views.handle_view_action(
        request, {
            'entry_remove': request.path,
            'entry_remove_comment': request.path,
            'entry_mark_as_spam': request.path,
            'subscription_remove': view.url(),
            'actor_add_contact': request.path,
            'actor_remove_contact': request.path,
            'post': request.path,
            'presence_set': request.path,
        })
    if handled:
        return handled

    privacy = 'public'
    if request.user:
        if view.nick == request.user.nick:
            privacy = 'private'
        # ROOT because we care whether or not request.user is a contact of
        # the view user's, not whether the request.user can see the contacts
        elif api.actor_has_contact(api.ROOT, view.nick, request.user.nick):
            privacy = 'contacts'

    # we're going to hide a bunch of stuff if this user is private and we
    # aren't allowed to see
    user_is_private = False
    if view.privacy < models.PRIVACY_PUBLIC and privacy == 'public':
        user_is_private = True

    per_page = ENTRIES_PER_PAGE
    offset, prev = util.page_offset(request)

    if privacy == 'public':
        if user_is_private:
            inbox = []
        else:
            inbox = api.inbox_get_actor_public(request.user,
                                               view.nick,
                                               limit=(per_page + 1),
                                               offset=offset)
    elif privacy == 'contacts':
        inbox = api.inbox_get_actor_contacts(request.user,
                                             view.nick,
                                             limit=(per_page + 1),
                                             offset=offset)
    elif privacy == 'private':
        inbox = api.inbox_get_actor_private(request.user,
                                            view.nick,
                                            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]
    try:
        actor_streams = api.stream_get_actor(request.user, view.nick)
    except exception.ApiException:
        actor_streams = []
    stream_keys += [s.key().name() for s in actor_streams]
    streams = api.stream_get_streams(request.user, stream_keys)

    try:
        contact_nicks = api.actor_get_contacts(request.user,
                                               view.nick,
                                               limit=CONTACTS_PER_PAGE)
    except exception.ApiException:
        contact_nicks = []

    actor_nicks = (contact_nicks + [view.nick] +
                   [s.owner for s in streams.values()] +
                   [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
    contacts = [actors[x] for x in contact_nicks if actors[x]]
    streams = display.prep_stream_dict(streams, actors)
    entries = display.prep_entry_list(entries, streams, actors)

    # END inbox generation chaos

    # If not logged in, cannot write
    is_owner = request.user and view.nick == request.user.nick

    try:
        presence = api.presence_get(request.user, view.nick)
        presence_stream = api.stream_get_presence(request.user, view.nick)
        last_entry = api.entry_get_last(request.user,
                                        presence_stream.keyname())
        view.last_entry = last_entry
    except exception.ApiException:
        pass

    # for add/remove contact
    if request.user:
        user_is_contact = api.actor_has_contact(request.user,
                                                request.user.nick, view.nick)
        view.my_contact = user_is_contact
    else:
        user_is_contact = False

    # for sidebar streams
    view_streams = dict([(x.key().name(), streams[x.key().name()])
                         for x in actor_streams])
    if request.user:
        # un/subscribe buttons are possible only, when logged in

        # TODO(termie): what if there are quite a lot of streams?
        for stream in view_streams.values():
            stream.subscribed = api.subscription_exists(
                request.user,
                stream.key().name(), 'inbox/%s/overview' % request.user.nick)

    # for sidebar_contacts
    contacts_count = view.extra.get('contact_count', 0)
    contacts_more = contacts_count > CONTACTS_PER_PAGE

    # Config for the template
    green_top = True
    sidebar_green_top = True
    selectable_icons = display.SELECTABLE_ICONS
    area = 'user'

    c = template.RequestContext(request, locals())

    if format == 'html':
        t = loader.get_template('actor/templates/history.html')
        return http.HttpResponse(t.render(c))
    elif format == 'json':
        t = loader.get_template('actor/templates/history.json')
        r = util.HttpJsonResponse(t.render(c), request)
        return r
    elif format == 'atom':
        t = loader.get_template('actor/templates/history.atom')
        r = util.HttpAtomResponse(t.render(c), request)
        return r
    elif format == 'rss':
        t = loader.get_template('actor/templates/history.rss')
        r = util.HttpRssResponse(t.render(c), request)
        return r
Exemplo n.º 11
0
def actor_overview(request, nick, format='html'):
    nick = clean.nick(nick)

    view = api.actor_lookup_nick(request.user, nick)

    if not view:
        raise exception.UserDoesNotExistError(nick, request.user)

    if not request.user or view.nick != request.user.nick:
        # Instead of displaying the overview, redirect to the public-facing page
        return http.HttpResponseRedirect(view.url())

    handled = common_views.handle_view_action(
        request, {
            'entry_remove': request.path,
            'entry_remove_comment': request.path,
            'entry_mark_as_spam': request.path,
            'presence_set': request.path,
            'settings_hide_comments': request.path,
            'post': request.path,
        })
    if handled:
        return handled

    per_page = ENTRIES_PER_PAGE
    offset, prev = util.page_offset(request)

    inbox = api.inbox_get_actor_overview(request.user,
                                         view.nick,
                                         limit=(per_page + 1),
                                         offset=offset)

    # START inbox generation chaos
    # TODO(termie): refacccttttooorrrrr
    entries = api.entry_get_entries(request.user, inbox)

    if view.extra.get('comments_hide', 0):
        # TODO(tyler): This is certainly not the most eloquent way to filter
        # through entries to remove comments.
        entries = [x for x in entries if not x.stream.endswith('comments')]

    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]
    actor_streams = api.stream_get_actor(request.user, view.nick)
    stream_keys += [s.key().name() for s in actor_streams]
    streams = api.stream_get_streams(request.user, stream_keys)

    contact_nicks = api.actor_get_contacts(request.user,
                                           view.nick,
                                           limit=CONTACTS_PER_PAGE)
    actor_nicks = (contact_nicks + [view.nick] +
                   [s.owner for s in streams.values()] +
                   [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
    # clear deleted contacts
    contacts = [actors[x] for x in contact_nicks if actors[x]]
    streams = display.prep_stream_dict(streams, actors)
    entries = display.prep_entry_list(entries, streams, actors)

    # END inbox generation chaos

    # Check for unconfirmed emails
    unconfirmeds = api.activation_get_actor_email(request.user, view.nick)
    if unconfirmeds:
        unconfirmed_email = unconfirmeds[0].content

    # If not logged in, cannot write
    is_owner = False
    try:
        is_owner = view.nick == request.user.nick
    except:
        pass
    presence = api.presence_get(request.user, view.nick)

    # for sidebar streams
    view_streams = dict([(x.key().name(), streams[x.key().name()])
                         for x in actor_streams])

    # for sidebar_contacts
    contacts_count = view.extra.get('contact_count', 0)
    contacts_more = contacts_count > CONTACTS_PER_PAGE

    # Config for the template
    green_top = True
    sidebar_green_top = True
    selectable_icons = display.SELECTABLE_ICONS

    area = 'home'

    # TODO(tyler/termie):  This conflicts with the global settings import.
    # Also, this seems fishy.  Do none of the settings.* items work in templates?
    import settings

    c = template.RequestContext(request, locals())

    if format == 'html':
        t = loader.get_template('actor/templates/overview.html')
        return http.HttpResponse(t.render(c))
    elif format == 'json':
        t = loader.get_template('actor/templates/overview.json')
        r = util.HttpJsonResponse(t.render(c), request)
        return r
    elif format == 'atom':
        t = loader.get_template('actor/templates/overview.atom')
        r = util.HttpAtomResponse(t.render(c), request)
        return r
    elif format == 'rss':
        t = loader.get_template('actor/templates/overview.rss')
        r = util.HttpRssResponse(t.render(c), request)
        return r
Exemplo n.º 12
0
def actor_history(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)

  called_subscribe, sub_ref = common_views.call_api_from_request(
      request, 'subscription_request')
  if called_subscribe:
    if sub_ref.state == 'subscribed':
      message = 'Subscribed.'
    else:
      message = 'Subscription requested.'
    return util.RedirectFlash(view.url(), message)

  handled = common_views.handle_view_action(
      request,
      { 'entry_remove': request.path,
        'entry_remove_comment': request.path,
        'entry_mark_as_spam': request.path,
        'subscription_remove': view.url(),
        'actor_add_contact': request.path,
        'actor_remove_contact': request.path,
        'post': request.path,
        'presence_set': request.path,
      }
  )
  if handled:
    return handled

  privacy = 'public'
  if request.user:
    if view.nick == request.user.nick:
      privacy = 'private'
    # ROOT because we care whether or not request.user is a contact of
    # the view user's, not whether the request.user can see the contacts
    elif api.actor_has_contact(api.ROOT, view.nick, request.user.nick):
      privacy = 'contacts'

  # we're going to hide a bunch of stuff if this user is private and we
  # aren't allowed to see
  user_is_private = False
  if view.privacy < models.PRIVACY_PUBLIC and privacy == 'public':
    user_is_private = True

  per_page = ENTRIES_PER_PAGE
  offset, prev = util.page_offset(request)

  if privacy == 'public':
    if user_is_private:
      inbox = []
    else:
      inbox = api.inbox_get_actor_public(request.user, view.nick,
                                         limit=(per_page + 1), offset=offset)
  elif privacy == 'contacts':
    inbox = api.inbox_get_actor_contacts(request.user, view.nick,
                                         limit=(per_page + 1), offset=offset)
  elif privacy == 'private':
    inbox = api.inbox_get_actor_private(request.user, view.nick,
                                        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]
  try:
    actor_streams = api.stream_get_actor(request.user, view.nick)
  except exception.ApiException:
    actor_streams = []
  stream_keys += [s.key().name() for s in actor_streams]
  streams = api.stream_get_streams(request.user, stream_keys)

  try:
    contact_nicks = api.actor_get_contacts(request.user, 
                                           view.nick, 
                                           limit=CONTACTS_PER_PAGE)
  except exception.ApiException:
    contact_nicks = []

  actor_nicks = (contact_nicks +
                 [view.nick] +
                 [s.owner for s in streams.values()] +
                 [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
  contacts = [actors[x] for x in contact_nicks if actors[x]]
  streams = display.prep_stream_dict(streams, actors)
  entries = display.prep_entry_list(entries, streams, actors)

  # END inbox generation chaos

  # If not logged in, cannot write
  is_owner = request.user and view.nick == request.user.nick

  try:
    presence = api.presence_get(request.user, view.nick)
    presence_stream = api.stream_get_presence(request.user, view.nick)
    last_entry = api.entry_get_last(request.user, presence_stream.keyname())
    view.last_entry = last_entry
  except exception.ApiException:
    pass


  # for add/remove contact
  if request.user:
    user_is_contact = api.actor_has_contact(request.user,
                                            request.user.nick,
                                            view.nick)
    view.my_contact = user_is_contact
  else:
    user_is_contact = False

  # for sidebar streams
  view_streams = dict([(x.key().name(), streams[x.key().name()])
                       for x in actor_streams])
  if request.user:
    # un/subscribe buttons are possible only, when logged in

    # TODO(termie): what if there are quite a lot of streams?
    for stream in view_streams.values():
      stream.subscribed = api.subscription_exists(
          request.user,
          stream.key().name(),
          'inbox/%s/overview' % request.user.nick
          )


  # for sidebar_contacts
  contacts_count = view.extra.get('contact_count', 0)
  contacts_more = contacts_count > CONTACTS_PER_PAGE

  # Config for the template
  green_top = True
  sidebar_green_top = True
  selectable_icons = display.SELECTABLE_ICONS
  area = 'user'

  c = template.RequestContext(request, locals())

  if format == 'html':
    t = loader.get_template('actor/templates/history.html')
    return http.HttpResponse(t.render(c))
  elif format == 'json':
    t = loader.get_template('actor/templates/history.json')
    r = util.HttpJsonResponse(t.render(c), request)
    return r
  elif format == 'atom':
    t = loader.get_template('actor/templates/history.atom')
    r = util.HttpAtomResponse(t.render(c), request)
    return r
  elif format == 'rss':
    t = loader.get_template('actor/templates/history.rss')
    r = util.HttpRssResponse(t.render(c), request)
    return r
Exemplo n.º 13
0
def actor_overview(request, nick, format='html'):
  nick = clean.nick(nick)

  view = api.actor_lookup_nick(request.user, nick)

  if not view:
    raise exception.UserDoesNotExistError(nick, request.user)

  if not request.user or view.nick != request.user.nick:
    # Instead of displaying the overview, redirect to the public-facing page
    return http.HttpResponseRedirect(view.url())

  handled = common_views.handle_view_action(
      request,
      { 
        'entry_remove': request.path,
        'entry_remove_comment': request.path,
        'entry_mark_as_spam': request.path,
        'presence_set': request.path,
        'settings_hide_comments': request.path,
        'post': request.path,
      }
  )
  if handled:
    return handled

  per_page = ENTRIES_PER_PAGE
  offset, prev = util.page_offset(request)

  inbox = api.inbox_get_actor_overview(request.user,  
                                       view.nick,
                                       limit=(per_page + 1), 
                                       offset=offset)

  # START inbox generation chaos
  # TODO(termie): refacccttttooorrrrr
  entries = api.entry_get_entries(request.user, inbox)
  
  if view.extra.get('comments_hide', 0):
    # TODO(tyler): This is certainly not the most eloquent way to filter
    # through entries to remove comments.
    entries = [x for x in entries if not x.stream.endswith('comments')]

  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]
  actor_streams = api.stream_get_actor(request.user, view.nick)
  stream_keys += [s.key().name() for s in actor_streams]
  streams = api.stream_get_streams(request.user, stream_keys)

  contact_nicks = api.actor_get_contacts(request.user, 
                                         view.nick, 
                                         limit=CONTACTS_PER_PAGE)
  actor_nicks = (contact_nicks +
                 [view.nick] +
                 [s.owner for s in streams.values()] +
                 [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
  # clear deleted contacts
  contacts = [actors[x] for x in contact_nicks if actors[x]]
  streams = display.prep_stream_dict(streams, actors)
  entries = display.prep_entry_list(entries, streams, actors)

  # END inbox generation chaos
  
  # Check for unconfirmed emails
  unconfirmeds = api.activation_get_actor_email(request.user, view.nick)
  if unconfirmeds:
    unconfirmed_email = unconfirmeds[0].content

  # If not logged in, cannot write
  is_owner = False
  try:
    is_owner = view.nick == request.user.nick
  except:
    pass
  presence = api.presence_get(request.user, view.nick)

  # for sidebar streams
  view_streams = dict([(x.key().name(), streams[x.key().name()])
                       for x in actor_streams])

  # for sidebar_contacts
  contacts_count = view.extra.get('contact_count', 0)
  contacts_more = contacts_count > CONTACTS_PER_PAGE

  # Config for the template
  green_top = True
  sidebar_green_top = True
  selectable_icons = display.SELECTABLE_ICONS

  area = 'home'

  # TODO(tyler/termie):  This conflicts with the global settings import.
  # Also, this seems fishy.  Do none of the settings.* items work in templates?
  import settings
  
  c = template.RequestContext(request, locals())

  if format == 'html':
    t = loader.get_template('actor/templates/overview.html')
    return http.HttpResponse(t.render(c))
  elif format == 'json':
    t = loader.get_template('actor/templates/overview.json')
    r = util.HttpJsonResponse(t.render(c), request)
    return r
  elif format == 'atom':
    t = loader.get_template('actor/templates/overview.atom')
    r = util.HttpAtomResponse(t.render(c), request)
    return r
  elif format == 'rss':
    t = loader.get_template('actor/templates/overview.rss')
    r = util.HttpRssResponse(t.render(c), request)
    return r
Exemplo n.º 14
0
def channel_history(request, nick, format='html'):
    """ the page for a channel

  if the channel does not exist we go to create channel instead

  should let you join a channel or post to it if you already are a member
  also leave it if you are a member,
  display the posts to this channel and the member list if you are allowed
  to see them

  if you are an admin you should have the options to modify the channel
  """
    nick = clean.channel(nick)

    view = api.actor_lookup_nick(request.user, nick)
    if not view:
        return http.HttpResponseRedirect('/channel/create?channel=%s' % nick)

    admins = api.channel_get_admins(request.user, channel=view.nick)
    members = api.channel_get_members(request.user, channel=view.nick)

    handled = common_views.handle_view_action(
        request, {
            'channel_join': request.path,
            'channel_part': request.path,
            'channel_post': request.path,
            'entry_remove': request.path,
            'entry_remove_comment': request.path,
            'entry_mark_as_spam': request.path,
            'subscription_remove': request.path,
            'subscription_request': request.path,
        })
    if handled:
        return handled

    privacy = 'public'

    user_can_post = False
    user_is_admin = False
    if not request.user:
        pass
    elif api.channel_has_admin(request.user, view.nick, request.user.nick):
        privacy = 'private'
        user_can_post = True
        user_is_admin = True
    elif api.channel_has_member(request.user, view.nick, request.user.nick):
        privacy = 'contacts'
        user_can_post = True

    per_page = CHANNEL_HISTORY_PER_PAGE
    offset, prev = util.page_offset(request)

    if privacy == 'public':
        inbox = api.inbox_get_actor_public(request.user,
                                           view.nick,
                                           limit=(per_page + 1),
                                           offset=offset)
    elif privacy == 'contacts':
        inbox = api.inbox_get_actor_contacts(request.user,
                                             view.nick,
                                             limit=(per_page + 1),
                                             offset=offset)
    elif privacy == 'private':
        inbox = api.inbox_get_actor_private(api.ROOT,
                                            view.nick,
                                            limit=(per_page + 1),
                                            offset=offset)

    # START inbox generation chaos
    # TODO(termie): refacccttttooorrrrr

    entries = api.entry_get_entries(request.user, inbox)
    # clear out deleted entries
    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]
    actor_streams = api.stream_get_actor(request.user, view.nick)
    stream_keys += [s.key().name() for s in actor_streams]
    streams = api.stream_get_streams(request.user, stream_keys)

    contact_nicks = api.actor_get_contacts(request.user, view.nick)
    actor_nicks = (contact_nicks + admins + members + [view.nick] +
                   [s.owner
                    for s in streams.values()] + [e.actor for e in entries])
    actors = api.actor_get_actors(request.user, actor_nicks)

    # here comes lots of munging data into shape
    contacts = [actors[x] for x in contact_nicks if actors[x]]
    streams = display.prep_stream_dict(streams, actors)
    entries = display.prep_entry_list(entries, streams, actors)
    admins = [actors[x] for x in admins if actors[x]]
    members = [actors[x] for x in members if actors[x]]

    # END inbox generation chaos

    presence = api.presence_get(request.user, view.nick)

    # for sidebar_members
    members_count = view.extra['member_count']
    members_more = members_count > CONTACTS_PER_PAGE

    # for sidebar_admins
    admins_count = view.extra['admin_count']
    admins_more = admins_count > CONTACTS_PER_PAGE

    # config for templates
    green_top = True
    sidebar_green_top = True
    selectable_icons = display.SELECTABLE_ICONS

    # for sidebar streams (copied from actor/views.py.  refactor)
    view_streams = dict([(x.key().name(), streams[x.key().name()])
                         for x in actor_streams])
    if request.user:
        # un/subscribe buttons are possible only, when logged in

        # TODO(termie): what if there are quite a lot of streams?
        for stream in view_streams.values():
            stream.subscribed = api.subscription_exists(
                request.user,
                stream.key().name(), 'inbox/%s/overview' % request.user.nick)

    area = 'channel'
    c = template.RequestContext(request, locals())

    if format == 'html':
        t = loader.get_template('channel/templates/history.html')
        return http.HttpResponse(t.render(c))
    elif format == 'json':
        t = loader.get_template('channel/templates/history.json')
        r = util.HttpJsonResponse(t.render(c), request)
        return r
    elif format == 'atom':
        t = loader.get_template('channel/templates/history.atom')
        r = util.HttpAtomResponse(t.render(c), request)
        return r
    elif format == 'rss':
        t = loader.get_template('channel/templates/history.rss')
        r = util.HttpRssResponse(t.render(c), request)
        return r