Tweak diffs.css and refactor 'view_version' template to use it

This commit is contained in:
Lance Edgar 2018-01-06 20:28:13 -06:00
parent 568a625500
commit c3c77ed586
2 changed files with 21 additions and 55 deletions

View file

@ -4,6 +4,10 @@ table.diff {
border-collapse: collapse;
border-left: 1px solid Black;
border-top: 1px solid Black;
font-size: 11pt;
margin-top: 2em;
margin-left: 50px;
min-width: 80%;
}
table.diff th,
@ -13,16 +17,22 @@ table.diff td {
padding: 2px 5px;
}
table.diff td {
padding: 5px 10px;
}
table.diff.monospace td.old-value,
table.diff.monospace td.new-value{
font-family: monospace;
white-space: pre;
}
table.diff tr.diff td.new-value {
table.diff.new td.new-value,
table.diff.dirty tr.diff td.new-value {
background-color: #cfc;
}
table.diff tr.diff td.old-value {
table.diff.deleted td.old-value,
table.diff.dirty tr.diff td.old-value {
background-color: #fcc;
}

View file

@ -5,50 +5,6 @@
## TODO: this was basically copied from Revel diff template..need to abstract
<%def name="extra_styles()">
${parent.extra_styles()}
<style type="text/css">
table {
background-color: White;
border-collapse: collapse;
border-left: 1px solid black;
border-top: 1px solid black;
font-size: 11pt;
margin-top: 2em;
margin-left: 50px;
min-width: 80%;
}
table th,
table td {
border-bottom: 1px solid black;
border-right: 1px solid black;
}
table td {
padding: 5px 10px;
}
table td.value {
font-family: monospace;
white-space: pre;
}
table.new td.host-value,
table.diff tr.diff td.host-value {
background-color: #cfc;
}
table.deleted td.local-value,
table.diff tr.diff td.local-value {
background-color: #fcc;
}
</style>
</%def>
<%def name="content_title()">
<div style="float: right;">
% if previous_transaction:
@ -98,7 +54,7 @@
<h2>${title_for_version(version)}</h2>
% if version.previous and version.operation_type == continuum.Operation.DELETE:
<table class="deleted">
<table class="diff monospace deleted">
<thead>
<tr>
<th>field name</th>
@ -110,14 +66,14 @@
% for field in fields_for_version(version):
<tr>
<td class="field">${field}</td>
<td class="value local-value">${repr(getattr(version.previous, field))}</td>
<td class="value host-value">&nbsp;</td>
<td class="value old-value">${repr(getattr(version.previous, field))}</td>
<td class="value new-value">&nbsp;</td>
</tr>
% endfor
</tbody>
</table>
% elif version.previous:
<table class="diff">
<table class="diff monospace dirty">
<thead>
<tr>
<th>field name</th>
@ -129,14 +85,14 @@
% for field in fields_for_version(version):
<tr${' class="diff"' if getattr(version, field) != getattr(version.previous, field) else ''|n}>
<td class="field">${field}</td>
<td class="value local-value">${repr(getattr(version.previous, field))}</td>
<td class="value host-value">${repr(getattr(version, field))}</td>
<td class="value old-value">${repr(getattr(version.previous, field))}</td>
<td class="value new-value">${repr(getattr(version, field))}</td>
</tr>
% endfor
</tbody>
</table>
% else:
<table class="new">
<table class="diff monospace new">
<thead>
<tr>
<th>field name</th>
@ -148,8 +104,8 @@
% for field in fields_for_version(version):
<tr>
<td class="field">${field}</td>
<td class="value local-value">&nbsp;</td>
<td class="value host-value">${repr(getattr(version, field))}</td>
<td class="value old-value">&nbsp;</td>
<td class="value new-value">${repr(getattr(version, field))}</td>
</tr>
% endfor
</tbody>