Merge pull request #97 from gazpachoking/history_avatars

Add gravatar icons to history
This commit is contained in:
Matthew Scragg 2015-12-18 09:38:00 -06:00
commit a27996d761
5 changed files with 11 additions and 9 deletions

View file

@ -289,9 +289,10 @@ class Wiki(HookMixin):
change_type = change.type change_type = change.type
elif change.new.path == file_path: elif change.new.path == file_path:
change_type = change.type change_type = change.type
author_name, author_email = entry.commit.author.split('<') author_name, author_email = entry.commit.author.rstrip('>').split('<')
versions.append(dict( versions.append(dict(
author=author_name.strip(), author=author_name.strip(),
author_email=author_email,
time=entry.commit.author_time, time=entry.commit.author_time,
message=entry.commit.message, message=entry.commit.message,
sha=entry.commit.id, sha=entry.commit.id,

View file

@ -2,7 +2,7 @@ import itertools
import sys import sys
from flask import abort, g, render_template, request, redirect, Blueprint, flash, url_for, current_app from flask import abort, g, render_template, request, redirect, Blueprint, flash, url_for, current_app
from flask.ext.login import login_required, current_user from flask.ext.login import login_required, current_user
from realms.lib.util import to_canonical, remove_ext from realms.lib.util import to_canonical, remove_ext, gravatar_url
from .models import PageNotFound from .models import PageNotFound
blueprint = Blueprint('wiki', __name__) blueprint = Blueprint('wiki', __name__)
@ -66,7 +66,10 @@ def history(name):
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous():
return current_app.login_manager.unauthorized() return current_app.login_manager.unauthorized()
return render_template('wiki/history.html', name=name, history=g.current_wiki.get_history(name)) hist = g.current_wiki.get_history(name)
for item in hist:
item['gravatar'] = gravatar_url(item['author_email'])
return render_template('wiki/history.html', name=name, history=hist)
@blueprint.route("/_edit/<path:name>") @blueprint.route("/_edit/<path:name>")

View file

@ -83,9 +83,7 @@
float: right; float: right;
} }
.user-avatar a img { .avatar {
width: 24px;
height: 24px;
-webkit-box-shadow: 0 1px 3px #1e1e1e; -webkit-box-shadow: 0 1px 3px #1e1e1e;
-moz-box-shadow: 0 1px 3px #1e1e1e; -moz-box-shadow: 0 1px 3px #1e1e1e;
box-shadow: 0 1px 3px #1e1e1e; box-shadow: 0 1px 3px #1e1e1e;

View file

@ -62,7 +62,7 @@
<li class="dropdown user-avatar"> <li class="dropdown user-avatar">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span> <span>
<img src="{{ current_user.avatar }}" class="menu-avatar"> <img src="{{ current_user.avatar }}?s=24" class="avatar">
<span>{{ current_user.username }} <i class="icon-caret-down"></i></span> <span>{{ current_user.username }} <i class="icon-caret-down"></i></span>
</span> </span>
</a> </a>

View file

@ -22,7 +22,7 @@
<input type="checkbox" name="versions[]" value="{{ h.sha }}" /> <input type="checkbox" name="versions[]" value="{{ h.sha }}" />
{% endif %} {% endif %}
</td> </td>
<td>{{ h.author }}</td> <td><img src="{{ h.gravatar }}?s=20" class="avatar"/> {{ h.author }}</td>
<td><a href="{{ url_for('wiki.commit', name=name, sha=h.sha) }}" class='label label-primary'>View</a> {{ h.message }} </td> <td><a href="{{ url_for('wiki.commit', name=name, sha=h.sha) }}" class='label label-primary'>View</a> {{ h.message }} </td>
<td>{{ h.time|datetime }}</td> <td>{{ h.time|datetime }}</td>
</tr> </tr>