Making WordPress.org

Changeset 3140


Ignore:
Timestamp:
05/14/2016 12:27:03 PM (6 years ago)
Author:
ocean90
Message:

Trac: Use user's nicename for gravatars and profile links.

Adds wporg_sanitize_user_nicename() which simulates bb_sanitize_with_dashes() from bbPress.

See #1462.

Location:
sites/trunk/trac.wordpress.org/templates
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/trac.wordpress.org/templates/site-ticket.html

    r3137 r3140  
    3434
    3535<!--! Gravatars for the ticket reporter -->
    36 <td py:match="td[@headers='h_reporter']" py:attrs="select('@*')">
    37   <a href="${profile_link + ticket.reporter}">
    38     <img class="avatar" src="https://wordpress.org/grav-redirect.php?user=${ticket.reporter}&amp;s=48" srcset="https://wordpress.org/grav-redirect.php?user=${ticket.reporter}&amp;s=96 2x" height="48" width="48" />
     36<td py:match="td[@headers='h_reporter']" py:attrs="select('@*')" py:with="wporg_user = wporg_sanitize_user_nicename(ticket.reporter)">
     37  <a href="${profile_link + wporg_user}">
     38    <img class="avatar" src="https://wordpress.org/grav-redirect.php?user=${wporg_user}&amp;s=48" srcset="https://wordpress.org/grav-redirect.php?user=${wporg_user}&amp;s=96 2x" height="48" width="48" />
    3939  </a>
    4040    ${select('*|comment()|text()')}
     
    4343<!--! Gravatars for the ticket owner -->
    4444<td py:match="td[@headers='h_owner']" py:attrs="select('@*')">
    45   <a href="${profile_link + ticket.owner}" py:if="ticket.owner">
    46     <img class="avatar" src="https://wordpress.org/grav-redirect.php?user=${ticket.owner}&amp;s=48" srcset="https://wordpress.org/grav-redirect.php?user=${ticket.owner}&amp;s=96 2x" height="48" width="48" />
     45  <a py:if="ticket.owner" py:with="wporg_user = wporg_sanitize_user_nicename(ticket.owner)" href="${profile_link + wporg_user}">
     46    <img class="avatar" src="https://wordpress.org/grav-redirect.php?user=${wporg_user}&amp;s=48" srcset="https://wordpress.org/grav-redirect.php?user=${wporg_user}&amp;s=96 2x" height="48" width="48" />
    4747  </a>
    4848    ${select('*|comment()|text()')}
  • sites/trunk/trac.wordpress.org/templates/site.html

    r3139 r3140  
    3131    except (IndexError, KeyError):
    3232        pass
     33
     34    import re
     35    def wporg_sanitize_user_nicename(str):
     36        str = str.lower()
     37        str = re.sub(r'[^%a-z0-9\x80-\xff _-]', '', str)
     38        str = str.strip()
     39        str = re.sub(r'\s+', '-', str)
     40        str = re.sub(r'-+', '-', str)
     41        str = re.sub(r'_+', '_', str)
     42        return str;
     43
    3344?>
    3445
  • sites/trunk/trac.wordpress.org/templates/ticket_change.html

    r3137 r3140  
    3333
    3434<py:choose>
    35 <py:when test="'author' in change and ('slackbot' == change.author or 'ircbot' == change.author)">
     35<py:when test="'author' in change and ('slackbot' == change.author or 'ircbot' == change.author)"
     36         py:with="wporg_user = wporg_sanitize_user_nicename(change.author)"  >
    3637  <h3 class="change chat-bot">
    3738    <span class="avatar" py:if="change">
    3839      <span class="username-line">
    39         <img src="https://wordpress.org/grav-redirect.php?user=${authorinfo(change.author)}&amp;s=48" srcset="https://wordpress.org/grav-redirect.php?user=${authorinfo(change.author)}&amp;s=96 2x" height="48" width="48" />
     40        <img src="https://wordpress.org/grav-redirect.php?user=${wporg_user}&amp;s=48" srcset="https://wordpress.org/grav-redirect.php?user=${wporg_user}&amp;s=96 2x" height="48" width="48" />
    4041        ${wiki_to_html(context, change.comment, escape_newlines=preserve_newlines)}
    4142      </span>
     
    7475    </span>
    7576    <py:choose>
    76       <py:when test="'author' in change">
     77      <py:when test="'author' in change" py:with="wporg_user = wporg_sanitize_user_nicename(change.author)">
    7778        <span class="avatar" py:if="change">
    78           <span class="username-line"><a href="https://profiles.wordpress.org/${authorinfo(change.author)}" class="profile-link">
    79             <img src="https://wordpress.org/grav-redirect.php?user=${authorinfo(change.author)}&amp;s=48" srcset="https://wordpress.org/grav-redirect.php?user=${authorinfo(change.author)}&amp;s=96 2x" height="48" width="48" /> @<span class="username" data-username="${change.author}">${authorinfo(change.author)}</span></a></span>
     79          <span class="username-line"><a href="https://profiles.wordpress.org/${wporg_user}" class="profile-link">
     80            <img src="https://wordpress.org/grav-redirect.php?user=${wporg_user}&amp;s=48" srcset="https://wordpress.org/grav-redirect.php?user=${wporg_user}&amp;s=96 2x" height="48" width="48" /> @<span class="username" data-username="${change.author}">${authorinfo(change.author)}</span></a></span>
    8081          <py:if test="'date' in change">
    8182            <br /><span class="time-ago">${dateinfo(change.date)} ago</span>
Note: See TracChangeset for help on using the changeset viewer.