Changeset - 9fad28af93bd
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2012-06-20 00:06:00
marcin@python-works.com
fixed ico for pull request comment
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/helpers.py
Show inline comments
 
@@ -509,192 +509,194 @@ def action_parser(user_log, feed=False):
 

	
 
        compare_view = (
 
            ' <div class="compare_view tooltip" title="%s">'
 
            '<a href="%s">%s</a> </div>' % (
 
                _('Show all combined changesets %s->%s') % (
 
                    revs_ids[0], revs_ids[-1]
 
                ),
 
                url('changeset_home', repo_name=repo_name,
 
                    revision='%s...%s' % (revs_ids[0], revs_ids[-1])
 
                ),
 
                _('compare view')
 
            )
 
        )
 

	
 
        # if we have exactly one more than normally displayed
 
        # just display it, takes less space than displaying
 
        # "and 1 more revisions"
 
        if len(revs_ids) == revs_limit + 1:
 
            rev = revs[revs_limit]
 
            cs_links.append(", " + lnk(rev, repo_name))
 

	
 
        # hidden-by-default ones
 
        if len(revs_ids) > revs_limit + 1:
 
            uniq_id = revs_ids[0]
 
            html_tmpl = (
 
                '<span> %s <a class="show_more" id="_%s" '
 
                'href="#more">%s</a> %s</span>'
 
            )
 
            if not feed:
 
                cs_links.append(html_tmpl % (
 
                      _('and'),
 
                      uniq_id, _('%s more') % (len(revs_ids) - revs_limit),
 
                      _('revisions')
 
                    )
 
                )
 

	
 
            if not feed:
 
                html_tmpl = '<span id="%s" style="display:none">, %s </span>'
 
            else:
 
                html_tmpl = '<span id="%s"> %s </span>'
 

	
 
            morelinks = ', '.join(
 
              [lnk(rev, repo_name) for rev in revs[revs_limit:]]
 
            )
 

	
 
            if len(revs_ids) > revs_top_limit:
 
                morelinks += ', ...'
 

	
 
            cs_links.append(html_tmpl % (uniq_id, morelinks))
 
        if len(revs) > 1:
 
            cs_links.append(compare_view)
 
        return ''.join(cs_links)
 

	
 
    def get_fork_name():
 
        repo_name = action_params
 
        return _('fork name ') + str(link_to(action_params, url('summary_home',
 
                                          repo_name=repo_name,)))
 

	
 
    def get_user_name():
 
        user_name = action_params
 
        return user_name
 

	
 
    def get_users_group():
 
        group_name = action_params
 
        return group_name
 

	
 
    # action : translated str, callback(extractor), icon
 
    action_map = {
 
    'user_deleted_repo':         (_('[deleted] repository'),
 
                                  None, 'database_delete.png'),
 
    'user_created_repo':         (_('[created] repository'),
 
                                  None, 'database_add.png'),
 
    'user_created_fork':         (_('[created] repository as fork'),
 
                                  None, 'arrow_divide.png'),
 
    'user_forked_repo':          (_('[forked] repository'),
 
                                  get_fork_name, 'arrow_divide.png'),
 
    'user_updated_repo':         (_('[updated] repository'),
 
                                  None, 'database_edit.png'),
 
    'admin_deleted_repo':        (_('[delete] repository'),
 
                                  None, 'database_delete.png'),
 
    'admin_created_repo':        (_('[created] repository'),
 
                                  None, 'database_add.png'),
 
    'admin_forked_repo':         (_('[forked] repository'),
 
                                  None, 'arrow_divide.png'),
 
    'admin_updated_repo':        (_('[updated] repository'),
 
                                  None, 'database_edit.png'),
 
    'admin_created_user':        (_('[created] user'),
 
                                  get_user_name, 'user_add.png'),
 
    'admin_updated_user':        (_('[updated] user'),
 
                                  get_user_name, 'user_edit.png'),
 
    'admin_created_users_group': (_('[created] users group'),
 
                                  get_users_group, 'group_add.png'),
 
    'admin_updated_users_group': (_('[updated] users group'),
 
                                  get_users_group, 'group_edit.png'),
 
    'user_commented_revision':   (_('[commented] on revision in repository'),
 
                                  get_cs_links, 'comment_add.png'),
 
    'user_commented_pull_request': (_('[commented] on pull request'),
 
                                    get_cs_links, 'comment_add.png'),
 
    'push':                      (_('[pushed] into'),
 
                                  get_cs_links, 'script_add.png'),
 
    'push_local':                (_('[committed via RhodeCode] into repository'),
 
                                  get_cs_links, 'script_edit.png'),
 
    'push_remote':               (_('[pulled from remote] into repository'),
 
                                  get_cs_links, 'connect.png'),
 
    'pull':                      (_('[pulled] from'),
 
                                  None, 'down_16.png'),
 
    'started_following_repo':    (_('[started following] repository'),
 
                                  None, 'heart_add.png'),
 
    'stopped_following_repo':    (_('[stopped following] repository'),
 
                                  None, 'heart_delete.png'),
 
    }
 

	
 
    action_str = action_map.get(action, action)
 
    if feed:
 
        action = action_str[0].replace('[', '').replace(']', '')
 
    else:
 
        action = action_str[0]\
 
            .replace('[', '<span class="journal_highlight">')\
 
            .replace(']', '</span>')
 

	
 
    action_params_func = lambda: ""
 

	
 
    if callable(action_str[1]):
 
        action_params_func = action_str[1]
 

	
 
    def action_parser_icon():
 
        action = user_log.action
 
        action_params = None
 
        x = action.split(':')
 

	
 
        if len(x) > 1:
 
            action, action_params = x
 

	
 
        tmpl = """<img src="%s%s" alt="%s"/>"""
 
        ico = action_map.get(action, ['', '', ''])[2]
 
        return literal(tmpl % ((url('/images/icons/')), ico, action))
 

	
 
    # returned callbacks we need to call to get
 
    return [lambda: literal(action), action_params_func, action_parser_icon]
 

	
 

	
 

	
 
#==============================================================================
 
# PERMS
 
#==============================================================================
 
from rhodecode.lib.auth import HasPermissionAny, HasPermissionAll, \
 
HasRepoPermissionAny, HasRepoPermissionAll
 

	
 

	
 
#==============================================================================
 
# GRAVATAR URL
 
#==============================================================================
 

	
 
def gravatar_url(email_address, size=30):
 
    if (not str2bool(config['app_conf'].get('use_gravatar')) or
 
        not email_address or email_address == 'anonymous@rhodecode.org'):
 
        f = lambda a, l: min(l, key=lambda x: abs(x - a))
 
        return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30]))
 

	
 
    ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme')
 
    default = 'identicon'
 
    baseurl_nossl = "http://www.gravatar.com/avatar/"
 
    baseurl_ssl = "https://secure.gravatar.com/avatar/"
 
    baseurl = baseurl_ssl if ssl_enabled else baseurl_nossl
 

	
 
    if isinstance(email_address, unicode):
 
        #hashlib crashes on unicode items
 
        email_address = safe_str(email_address)
 
    # construct the url
 
    gravatar_url = baseurl + hashlib.md5(email_address.lower()).hexdigest() + "?"
 
    gravatar_url += urllib.urlencode({'d': default, 's': str(size)})
 

	
 
    return gravatar_url
 

	
 

	
 
#==============================================================================
 
# REPO PAGER, PAGER FOR REPOSITORY
 
#==============================================================================
 
class RepoPage(Page):
 

	
 
    def __init__(self, collection, page=1, items_per_page=20,
 
                 item_count=None, url=None, **kwargs):
 

	
 
        """Create a "RepoPage" instance. special pager for paging
 
        repository
 
        """
 
        self._url_generator = url
 

	
 
        # Safe the kwargs class-wide so they can be used in the pager() method
 
        self.kwargs = kwargs
 

	
 
        # Save a reference to the collection
 
        self.original_collection = collection
 

	
0 comments (0 inline, 0 general)