Skip to content
This repository was archived by the owner on Apr 12, 2020. It is now read-only.

Commit dc0ee79

Browse files
author
alexandresalome
committed
css for diff
1 parent ac3a2fc commit dc0ee79

File tree

4 files changed

+88
-33
lines changed

4 files changed

+88
-33
lines changed

src/Gitonomy/Browser/Resources/views/git/default_theme.html.twig

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
{{ git_render('diff_file', {file: file}) }}
101101
</div>
102102
{% endfor %}
103+
</div>
103104
{% endspaceless %}
104105
{% endblock %}
105106

@@ -153,6 +154,7 @@
153154

154155
{% block diff_file %}
155156
{% spaceless %}
157+
<header>
156158
{% if file.oldName == file.newName and file.oldMode == file.newMode %}
157159
<span class="file">{{ file.oldName }}</span>
158160
{% elseif file.oldName == null %}
@@ -166,40 +168,32 @@
166168
<li>{{ file.oldName }} ({{ file.oldMode }}) -&gt; {{ file.newName }} ({{ file.newMode }})</li>
167169
</ul>
168170
{% endif %}
169-
{% if not file.binary %}
170-
<div class="btn-group pull-right">
171-
<a rel="tooltip" title="{{ 'label.button.old'|trans }}" class="btn btn-small show-old"><i class="icon-chevron-left"></i></a>
172-
<a rel="tooltip" title="{{ 'label.button.diff'|trans }}" disabled="disabled" class="btn btn-small show-diff"><i class="icon-eye-close"></i></a>
173-
<a rel="tooltip" title="{{ 'label.button.new'|trans }}" class="btn btn-small show-new"><i class="icon-chevron-right"></i></a>
174-
{% if reference|default(null) and slug|default(null) %}
175-
<a rel="tooltip" data-placement="left" title="{{ 'label.button.full_file'|trans }}" class="btn btn-small" href="{{ path('project_tree', {slug: slug, reference: reference, path: file.name}) }}"><i class="icon-file"></i></a>
176-
{% endif %}
177-
</div>
178-
{% endif %}
179171
</header>
180172
<div class="file-changes">
181-
{% for change in file.changes %}
182-
{% if not loop.first %}
183-
<tr><td class="skip" colspan="3">&nbsp;</td></tr>
184-
{% endif %}
185-
{% set old = change.rangeOldStart %}
186-
{% set new = change.rangeNewStart %}
187-
{%- for x, line in change.lines -%}
188-
<tr class="{{ line[0] == 1 ? 'new' : line[0] == -1 ? 'old' : '' }}">
189-
<td class="old">{{ line[0] != 1 ? old : ' ' }}</td>
190-
<td class="new">{{ line[0] != -1 ? new : ' ' }}</td>
191-
<td class="{{ line[0] == 1 ? 'plus' : line[0] == -1 ? 'minus' : '' }} source"><pre>{{ line[1] }}</pre></td>
192-
</tr>
193-
{%- if line[0] == 1 -%}
194-
{%- set new = new + 1 -%}
195-
{%- elseif line[0] == -1 -%}
196-
{%- set old = old + 1 -%}
197-
{%- else -%}
198-
{%- set new = new + 1 -%}
199-
{%- set old = old + 1 -%}
200-
{%- endif -%}
201-
{%- endfor -%}
202-
{% endfor %}
173+
<table class="diff-lines">
174+
{% for change in file.changes %}
175+
{% if not loop.first %}
176+
<tr><td class="skip" colspan="3">&nbsp;</td></tr>
177+
{% endif %}
178+
{% set old = change.rangeOldStart %}
179+
{% set new = change.rangeNewStart %}
180+
{%- for x, line in change.lines -%}
181+
<tr class="{{ line[0] == 1 ? 'new' : line[0] == -1 ? 'old' : '' }}">
182+
<td class="old">{{ line[0] != 1 ? old : ' ' }}</td>
183+
<td class="new">{{ line[0] != -1 ? new : ' ' }}</td>
184+
<td class="{{ line[0] == 1 ? 'plus' : line[0] == -1 ? 'minus' : '' }} source"><pre>{{ line[1] }}</pre></td>
185+
</tr>
186+
{%- if line[0] == 1 -%}
187+
{%- set new = new + 1 -%}
188+
{%- elseif line[0] == -1 -%}
189+
{%- set old = old + 1 -%}
190+
{%- else -%}
191+
{%- set new = new + 1 -%}
192+
{%- set old = old + 1 -%}
193+
{%- endif -%}
194+
{%- endfor -%}
195+
{% endfor %}
196+
</table>
203197
</div>
204198
{% endspaceless %}
205199
{% endblock %}

src/Gitonomy/Browser/Resources/views/layout.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html>
33
<head>
44
<title>{% block title '' %}</title>
5+
<link rel="stylesheet" href="{{ app.request.basepath }}/css/git/diff.css" />
56
<link rel="stylesheet" href="{{ app.request.basepath }}/css/git/log.css" />
67
<link rel="stylesheet" href="{{ app.request.basepath }}/css/layout.css" />
78
</head>

web/css/git/diff.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.git-diff .file {
2+
margin-top: 10px;
3+
}
4+
5+
.git-diff .file > header {
6+
background-color: #efefef;
7+
padding: 10px;
8+
}
9+
10+
.git-diff .file > header span.file {
11+
font-weight: bold;
12+
}
13+
14+
15+
.git-diff .file > header span.file.deleted {
16+
font-weight: normal;
17+
text-decoration: line-through;
18+
}
19+
20+
21+
.git-diff table.diff-lines {
22+
border-spacing: 0;
23+
border-collapse: collapse;
24+
border: 1px solid #dfdfdf;
25+
width: 100%;
26+
}
27+
28+
.git-diff table.diff-lines td {
29+
font-family: monospace;
30+
}
31+
32+
.git-diff table.diff-lines td.old, .git-diff table.diff-lines td.new {
33+
padding: 0 5px;
34+
background-color: #efefef;
35+
border-right: 1px solid #dfdfdf;
36+
}
37+
38+
.git-diff table.diff-lines td.source {
39+
width: 100%;
40+
}
41+
42+
.git-diff table.diff-lines td.source pre {
43+
background: none;
44+
border: 0;
45+
margin: 0;
46+
padding: 0;
47+
}
48+
49+
.git-diff table.diff-lines td.source.plus {
50+
background-color: #ddffdd;
51+
}
52+
53+
.git-diff table.diff-lines td.source.minus {
54+
background-color: #ffdddd;
55+
}
56+
57+
.git-diff table.diff-lines td.skip {
58+
background-color: #efefef;
59+
}
60+

web/css/layout.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
h1, h2, h3, p, body, ul, li {
1+
h1, h2, h3, p, body, ul, li, table, tr, td, th {
22
margin: 0;
33
padding: 0;
44
}

0 commit comments

Comments
 (0)