szuru/public_html/templates/history.tpl

83 lines
2.8 KiB
Smarty
Raw Permalink Normal View History

<%
var reprValue = function(value) {
2015-06-28 12:25:35 +02:00
if (typeof(value) === 'string' || value instanceof String) {
return value;
}
return JSON.stringify(value);
};
2014-11-19 10:22:59 +01:00
var showDifference = function(className, difference) {
2015-06-28 12:25:35 +02:00
_.each(difference, function(value, key) {
if (!Array.isArray(value)) {
value = [value];
}
_.each(value, function(v) {
%><li class="<%= className %> difference-<%= key %>"><%= key + ':' + reprValue(v) %></li><%
});
});
2014-11-19 10:22:59 +01:00
};
%>
2014-09-26 20:41:28 +02:00
<table class="history">
2015-06-28 12:25:35 +02:00
<tbody>
<% _.each(history, function( historyEntry) { %>
<tr>
<td class="time" title="<%= util.formatAbsoluteTime(historyEntry.time) %>">
<%= util.formatRelativeTime(historyEntry.time) %>
</td>
2014-09-26 20:41:28 +02:00
2015-06-28 12:25:35 +02:00
<td class="user">
<% var userName = historyEntry.user && historyEntry.user.name || '' %>
2014-09-26 20:41:28 +02:00
2015-06-28 12:25:35 +02:00
<% if (userName) { %>
<a href="#/user/<%= userName %>">
<% } %>
2014-09-26 20:41:28 +02:00
2015-06-28 12:25:35 +02:00
<img width="20" height="20" class="author-avatar"
src="/data/thumbnails/20x20/avatars/<%= userName || '!' %>"
alt="<%= userName || 'Anonymous user' %>"/>
2014-09-26 20:41:28 +02:00
2015-06-28 12:25:35 +02:00
<%= userName || 'Anonymous user' %>
2014-09-26 20:41:28 +02:00
2015-06-28 12:25:35 +02:00
<% if (userName) { %>
</a>
<% } %>
</td>
2014-09-26 20:41:28 +02:00
2015-06-28 12:25:35 +02:00
<td class="subject">
<% if (historyEntry.type === 0) { %>
<a href="#/post/<%= historyEntry.primaryKey %>">
@<%= historyEntry.primaryKey %>
</a>
<% } else if (historyEntry.type === 1) { %>
<a href="#/tag/<%= historyEntry.data.name %>">
#<%= historyEntry.data.name %>
</a>
<% } else { %>
?
<% } %>
</td>
2014-09-26 20:41:28 +02:00
2015-06-28 12:25:35 +02:00
<td class="difference">
<% if (historyEntry.operation == 2) { %>
deleted
<% } else { %>
<% if (historyEntry.operation == 0) { %>
added
<% } else { %>
changed
<% } %>
2014-09-26 20:41:28 +02:00
2015-06-28 12:25:35 +02:00
<% if (historyEntry.dataDifference) { %>
<ul><!--
--><% showDifference('addition', historyEntry.dataDifference['+']) %><!--
--><% showDifference('removal', historyEntry.dataDifference['-']) %><!--
--></ul>
<% } %>
<% } %>
</td>
</tr>
<% }) %>
</tbody>
2014-09-26 20:41:28 +02:00
</table>