Esempio n. 1
0
def expired_static(context, request):
    """Redirect static urls that use an expired revision segment
    to the currently active one. This has the following advantages:
    
    - prevent static links from saved content causing a 404
      (instead they will give a 303 and go to the current version)
    
    - make it easier to find the QUnit tests from a browser.

    """
    path = request.matchdict['path']
    path0 = path[0]
    # Is the first segment a r1234455667 format?
    first_segment = False
    if path0.startswith('r'):
        try:
            int(path0[1:])
        except ValueError:
            pass
        else:
            first_segment = True
    # Let's be smart here and except old or missing revision segments alike:
    # /static/{r1234oldrev}/foo/bar   --> /static/{r5678newrev}/foo/bar
    # /static/foo/bar                 --> /static/{r5678newrev}/foo/bar
    if first_segment:
        path = path[1:]
    # Do the redirect
    url = get_static_url(request) + '/' + '/'.join(path);
    return HTTPFound(location=url)
Esempio n. 2
0
    def __init__(self, context, request):
        super(AdvancedSearchResultsDisplayPeople,
              self).__init__(context, request)
        contact_items = []
        if context.extension and context.extension.strip():
            extension_html = (
                '<span class="sras-people-extension">x%s</span>' %
                context.extension)
            contact_items.append(extension_html)
        if context.room_no and context.room_no.strip():
            room_html = ('<span class="sras-people-room">Room %s</span>' %
                         context.room_no)
            contact_items.append(room_html)
        if context.email and context.email.strip():
            email_html = ('<a href="mailto:%s">%s</a>' %
                          (context.email, context.email))
            contact_items.append(email_html)

        photo = context.get('photo')
        if photo is None:
            thumbnail = get_static_url(request) + '/images/defaultUser.gif'
        else:
            thumbnail = thumb_url(photo, request, (50, 50))

        self.display_data = dict(
            contact_html=' - '.join(contact_items),
            thumbnail=thumbnail,
        )
Esempio n. 3
0
File: panels.py Progetto: hj91/karl
def chatter_user_info(context, request, userid=None):
    chatter = find_chatter(context)
    chatter_url = resource_url(chatter, request)
    profiles = find_profiles(context)
    if userid is None:
        userid = request.GET.get('userid')
    if userid is None:
        userid = authenticated_userid(request)
    profile = profiles.get(userid)
    profile_url = profile and resource_url(profile, request) or None
    photo = profile and profile.get('photo') or None
    if photo is not None:
        photo_url = thumb_url(photo, request, CHATTER_THUMB_SIZE)
    else:
        photo_url = get_static_url(request) + "/images/defaultUser.gif"
    posts = sum(1 for p in chatter.recentWithCreators(*[userid]))
    following = sum(1 for u in chatter.listFollowed(userid))
    followers = sum(1 for u in chatter.listFollowing(userid))
    return {
        'creator': getattr(profile, 'title', 'anonymous'),
        'creator_url': '%s%s' % (chatter_url, userid),
        'creator_profile_url': profile_url,
        'creator_image_url': photo_url,
        'creator_userid': userid,
        'chatter_url': chatter_url,
        'posts': posts,
        'following': following,
        'followers': followers
    }
def chatter_user_info(context, request, userid=None):
    chatter = find_chatter(context)
    chatter_url = resource_url(chatter, request)
    profiles = find_profiles(context)
    if userid is None:
        userid = request.GET.get('userid')
    if userid is None:
        userid = authenticated_userid(request)
    profile = profiles.get(userid)
    profile_url = profile and resource_url(profile, request) or None
    photo = profile and profile.get('photo') or None
    if photo is not None:
        photo_url = thumb_url(photo, request, CHATTER_THUMB_SIZE)
    else:
        photo_url = get_static_url(request) + "/images/defaultUser.gif"
    posts = sum(1 for p in chatter.recentWithCreators(*[userid]))
    following = sum(1 for u in chatter.listFollowed(userid))
    followers = sum(1 for u in chatter.listFollowing(userid))
    return {'creator': getattr(profile, 'title', 'anonymous'),
            'creator_url': '%s%s' % (chatter_url, userid),
            'creator_profile_url': profile_url,
            'creator_image_url': photo_url,
            'creator_userid': userid,
            'chatter_url': chatter_url,
            'posts': posts,
            'following': following,
            'followers': followers}
Esempio n. 5
0
    def __init__(self, context, request):
        super(AdvancedSearchResultsDisplayPeople, self).__init__(context,
                                                                 request)
        contact_items = []
        if context.extension and context.extension.strip():
            extension_html = ('<span class="sras-people-extension">x%s</span>'
                              % context.extension)
            contact_items.append(extension_html)
        if context.room_no and context.room_no.strip():
            room_html = ('<span class="sras-people-room">Room %s</span>'
                         % context.room_no)
            contact_items.append(room_html)
        if context.email and context.email.strip():
            email_html = ('<a href="mailto:%s">%s</a>'
                          % (context.email, context.email))
            contact_items.append(email_html)

        photo = context.get('photo')
        if photo is None:
            thumbnail = get_static_url(request) + '/images/defaultUser.gif'
        else:
            thumbnail = thumb_url(photo, request, (50,50))

        self.display_data = dict(
            contact_html = ' - '.join(contact_items),
            thumbnail = thumbnail,
            )
Esempio n. 6
0
File: site.py Progetto: lslaz1/karl
def expired_static(context, request):
    """Redirect static urls that use an expired revision segment
    to the currently active one. This has the following advantages:

    - prevent static links from saved content causing a 404
      (instead they will give a 303 and go to the current version)

    - make it easier to find the QUnit tests from a browser.

    """
    path = request.matchdict['path']
    path0 = path[0]
    # Is the first segment a r1234455667 format?
    first_segment = False
    if path0.startswith('r'):
        try:
            int(path0[1:])
        except ValueError:
            pass
        else:
            first_segment = True
    # Let's be smart here and except old or missing revision segments alike:
    # /static/{r1234oldrev}/foo/bar   --> /static/{r5678newrev}/foo/bar
    # /static/foo/bar                 --> /static/{r5678newrev}/foo/bar
    if first_segment:
        path = path[1:]
    # Do the redirect
    url = get_static_url(request) + '/' + '/'.join(path)
    return HTTPFound(location=url)
Esempio n. 7
0
    def __init__(self, context, request):
        super(AdvancedSearchResultsDisplayFile,
              self).__init__(context, request)

        fileinfo = getMultiAdapter((context, request), IFileInfo)
        icon = (get_static_url(request) + "/images/" +
                fileinfo.mimeinfo['small_icon_name'])

        self.display_data = dict(
            fileinfo=fileinfo,
            icon=icon,
        )
Esempio n. 8
0
    def __init__(self, context, request):
        super(AdvancedSearchResultsDisplayFile, self).__init__(context,
                                                               request)

        fileinfo = getMultiAdapter((context, request), IFileInfo)
        icon = (get_static_url(request) + "/images/" +
                fileinfo.mimeinfo['small_icon_name'])

        self.display_data = dict(
            fileinfo = fileinfo,
            icon = icon,
            )
Esempio n. 9
0
def file_livesearch_result(context, request):
    fileinfo = getMultiAdapter((context, request), IFileInfo)
    static_url = get_static_url(request)
    icon =  "%s/images/%s" % (static_url, fileinfo.mimeinfo['small_icon_name'])
    return livesearch_dict(
        context, request,
        modified_by=context.modified_by,
        modified=context.modified.isoformat(),
        icon=icon,
        community=_community_title(context),
        type='file',
        category='file',
        )
Esempio n. 10
0
def file_livesearch_result(context, request):
    fileinfo = getMultiAdapter((context, request), IFileInfo)
    static_url = get_static_url(request)
    icon = "%s/images/%s" % (static_url, fileinfo.mimeinfo['small_icon_name'])
    return livesearch_dict(
        context,
        request,
        modified_by=context.modified_by,
        modified=context.modified.isoformat(),
        icon=icon,
        community=_community_title(context),
        type='file',
        category='file',
    )
Esempio n. 11
0
def profile_livesearch_result(context, request):
    photo = context.get('photo')
    if photo is None:
        thumbnail = get_static_url(request) + '/images/defaultUser.gif'
    else:
        thumbnail = thumb_url(photo, request, (85,85))
    return livesearch_dict(
        context, request,
        extension=context.extension,
        email=context.email,
        department=context.department,
        type='profile',
        category='profile',
        thumbnail=thumbnail,
        )
Esempio n. 12
0
File: chatter.py Progetto: zagy/karl
def quip_info(request, *quips):
    result = []
    chatter = find_chatter(request.context)
    profiles = find_profiles(request.context)
    chatter_url = resource_url(chatter, request)
    userid = authenticated_userid(request)
    for quip in quips:
        quip_id = quip.__name__
        creator = quip.creator
        reposter = None
        reposter_fullname = ''
        if quip.repost is not None:
            creator = quip.repost
            reposter = quip.creator
            profile = profiles.get(reposter)
            reposter_fullname = profile and profile.title or reposter
        reply = None
        if quip.reply in chatter:
            reply = quip_info(request, *(chatter[quip.reply], ))[0]
        profile = profiles.get(creator)
        photo = profile and profile.get('photo') or None
        creator_fullname = profile and profile.title or creator
        if photo is not None:
            photo_url = thumb_url(photo, request, CHATTER_THUMB_SIZE)
        else:
            photo_url = get_static_url(request) + "/images/defaultUser.gif"
        timeago = str(quip.created.strftime(TIMEAGO_FORMAT))
        info = {
            'text': quip.text,
            'html': quip.html or quip.text,
            'creator': creator,
            'creator_fullname': creator_fullname,
            'creator_url': '%s%s' % (chatter_url, quip.creator),
            'creator_image_url': photo_url,
            'is_current_user': creator == userid,
            'reposter': reposter,
            'reposter_fullname': reposter_fullname,
            'reply': reply,
            'timeago': timeago,
            'names': list(quip.names),
            'communities': list(quip.communities),
            'tags': list(quip.tags),
            'url': resource_url(quip, request),
            'private': bool(getattr(quip, '__acl__', ())),
            'quip_id': quip_id,
        }
        result.append(info)
    return result
Esempio n. 13
0
def profile_livesearch_result(context, request):
    photo = context.get('photo')
    if photo is None:
        thumbnail = get_static_url(request) + '/images/defaultUser.gif'
    else:
        thumbnail = thumb_url(photo, request, (85, 85))
    return livesearch_dict(
        context,
        request,
        extension=context.extension,
        email=context.email,
        department=context.department,
        type='profile',
        category='profile',
        thumbnail=thumbnail,
    )
Esempio n. 14
0
File: chatter.py Progetto: hj91/karl
def quip_info(request, *quips):
    result = []
    chatter = find_chatter(request.context)
    profiles = find_profiles(request.context)
    chatter_url = resource_url(chatter, request)
    userid = authenticated_userid(request)
    for quip in quips:
        quip_id = quip.__name__
        creator = quip.creator
        reposter = None
        reposter_fullname = ''
        if quip.repost is not None:
            creator = quip.repost
            reposter = quip.creator
            profile = profiles.get(reposter)
            reposter_fullname = profile and profile.title or reposter
        reply =  None
        if quip.reply in chatter:
            reply = quip_info(request, *(chatter[quip.reply],))[0]
        profile = profiles.get(creator)
        photo = profile and profile.get('photo') or None
        creator_fullname = profile and profile.title or creator
        if photo is not None:
            photo_url = thumb_url(photo, request, CHATTER_THUMB_SIZE)
        else:
            photo_url = get_static_url(request) + "/images/defaultUser.gif"
        timeago = str(quip.created.strftime(TIMEAGO_FORMAT))
        info = {'text': quip.text,
                'html': quip.html or quip.text,
                'creator': creator,
                'creator_fullname': creator_fullname,
                'creator_url': '%s%s' % (chatter_url, quip.creator),
                'creator_image_url': photo_url,
                'is_current_user': creator == userid,
                'reposter': reposter,
                'reposter_fullname': reposter_fullname,
                'reply': reply,
                'timeago': timeago,
                'names': list(quip.names),
                'communities': list(quip.communities),
                'tags': list(quip.tags),
                'url': resource_url(quip, request),
                'private': bool(getattr(quip, '__acl__', ())),
                'quip_id': quip_id,
               }
        result.append(info)
    return result
Esempio n. 15
0
File: chatter.py Progetto: zagy/karl
def _quippers_from_users(context, request, user_list):
    userid = authenticated_userid(request)
    chatter = find_chatter(context)
    chatter_url = resource_url(chatter, request)
    profiles = find_profiles(context)
    following = []
    for quipper in user_list:
        info = {}
        profile = profiles.get(quipper)
        photo = profile and profile.get('photo') or None
        if photo is not None:
            photo_url = thumb_url(photo, request, CHATTER_THUMB_SIZE)
        else:
            photo_url = get_static_url(request) + "/images/defaultUser.gif"
        info['image_url'] = photo_url
        info['userid'] = quipper
        info['fullname'] = profile and profile.title or None
        info['url'] = '%s%s' % (chatter_url, quipper)
        user_list = chatter.listFollowed(userid)
        info['followed'] = quipper in user_list
        info['same_user'] = userid == quipper
        following.append(info)
    return following
Esempio n. 16
0
File: chatter.py Progetto: hj91/karl
def _quippers_from_users(context, request, user_list):
    userid = authenticated_userid(request)
    chatter = find_chatter(context)
    chatter_url = resource_url(chatter, request)
    profiles = find_profiles(context)
    following = []
    for quipper in user_list:
        info = {}
        profile = profiles.get(quipper)
        photo = profile and profile.get('photo') or None
        if photo is not None:
            photo_url = thumb_url(photo, request, CHATTER_THUMB_SIZE)
        else:
            photo_url = get_static_url(request) + "/images/defaultUser.gif"
        info['image_url'] = photo_url
        info['userid'] = quipper
        info['fullname'] = profile and profile.title or None
        info['url'] = '%s%s' % (chatter_url, quipper)
        user_list = chatter.listFollowed(userid)
        info['followed'] = quipper in user_list
        info['same_user'] = userid == quipper
        following.append(info)
    return following