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

Commit d5796df

Browse files
author
Alexandre Salomé
committed
Merge pull request #3 from gitonomy/css
Stylish a little bit
2 parents 1e1cea6 + 808a4e9 commit d5796df

File tree

9 files changed

+251
-97
lines changed

9 files changed

+251
-97
lines changed

src/Gitonomy/Browser/Controller/MainController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function listAction()
2525

2626
public function showRepositoryAction()
2727
{
28-
return $this->twig->render('log.html.twig');
28+
return $this->twig->render('repository.html.twig');
2929
}
3030

3131
public function logAjaxAction(Request $request, $repository)

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

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

106107
{% block branches %}
107108
{% spaceless %}
108-
{% for branch in branches %}
109-
<li>
110-
<a href="{{ path('reference', {fullname: branch.fullname}) }}">
111-
<strong>{{ branch.name }}</strong>
112-
</a>
113-
<small>
114-
{{ git_author(branch.commit) }}
115-
{{ branch.commit.authorDate.format('d/m/Y') }}
116-
</small>
117-
</li>
118-
{% endfor %}
109+
<ul>
110+
{% for branch in branches %}
111+
<li>
112+
<a href="{{ git_url(branch) }}">
113+
<strong>{{ branch.name }}</strong>
114+
</a>
115+
<small>
116+
{{ git_author(branch.commit) }}
117+
{{ branch.commit.authorDate.format('d/m/Y') }}
118+
</small>
119+
</li>
120+
{% endfor %}
121+
</ul>
119122
{% endspaceless %}
120123
{% endblock %}
121124

122125
{% block tags %}
123126
{% spaceless %}
124-
{% for tag in tags %}
125-
<li>
126-
<a href="{{ path('reference', {fullname: tag.fullname}) }}">
127-
<strong>{{ tag.name }}</strong>
128-
</a>
129-
<small>
130-
{{ git_author(tag.commit) }}
131-
{{ tag.commit.authorDate.format('d/m/Y') }}
132-
</small>
133-
</li>
134-
{% endfor %}
127+
<ul>
128+
{% for tag in tags %}
129+
<li>
130+
<a href="{{ git_url(tag) }}">
131+
<strong>{{ tag.name }}</strong>
132+
</a>
133+
<small>
134+
{{ git_author(tag.commit) }}
135+
{{ tag.commit.authorDate.format('d/m/Y') }}
136+
</small>
137+
</li>
138+
{% endfor %}
139+
</ul>
135140
{% endspaceless %}
136141
{% endblock %}
137142

@@ -149,6 +154,7 @@
149154

150155
{% block diff_file %}
151156
{% spaceless %}
157+
<header>
152158
{% if file.oldName == file.newName and file.oldMode == file.newMode %}
153159
<span class="file">{{ file.oldName }}</span>
154160
{% elseif file.oldName == null %}
@@ -162,40 +168,32 @@
162168
<li>{{ file.oldName }} ({{ file.oldMode }}) -&gt; {{ file.newName }} ({{ file.newMode }})</li>
163169
</ul>
164170
{% endif %}
165-
{% if not file.binary %}
166-
<div class="btn-group pull-right">
167-
<a rel="tooltip" title="{{ 'label.button.old'|trans }}" class="btn btn-small show-old"><i class="icon-chevron-left"></i></a>
168-
<a rel="tooltip" title="{{ 'label.button.diff'|trans }}" disabled="disabled" class="btn btn-small show-diff"><i class="icon-eye-close"></i></a>
169-
<a rel="tooltip" title="{{ 'label.button.new'|trans }}" class="btn btn-small show-new"><i class="icon-chevron-right"></i></a>
170-
{% if reference|default(null) and slug|default(null) %}
171-
<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>
172-
{% endif %}
173-
</div>
174-
{% endif %}
175171
</header>
176172
<div class="file-changes">
177-
{% for change in file.changes %}
178-
{% if not loop.first %}
179-
<tr><td class="skip" colspan="3">&nbsp;</td></tr>
180-
{% endif %}
181-
{% set old = change.rangeOldStart %}
182-
{% set new = change.rangeNewStart %}
183-
{%- for x, line in change.lines -%}
184-
<tr class="{{ line[0] == 1 ? 'new' : line[0] == -1 ? 'old' : '' }}">
185-
<td class="old">{{ line[0] != 1 ? old : ' ' }}</td>
186-
<td class="new">{{ line[0] != -1 ? new : ' ' }}</td>
187-
<td class="{{ line[0] == 1 ? 'plus' : line[0] == -1 ? 'minus' : '' }} source"><pre>{{ line[1] }}</pre></td>
188-
</tr>
189-
{%- if line[0] == 1 -%}
190-
{%- set new = new + 1 -%}
191-
{%- elseif line[0] == -1 -%}
192-
{%- set old = old + 1 -%}
193-
{%- else -%}
194-
{%- set new = new + 1 -%}
195-
{%- set old = old + 1 -%}
196-
{%- endif -%}
197-
{%- endfor -%}
198-
{% 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>
199197
</div>
200198
{% endspaceless %}
201199
{% endblock %}

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@
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>
89
<body>
9-
<div class="gitonomy-browser">
10-
<h1><a href="{{ path('repositories') }}">gitonomy browser</a></h1>
11-
<hr />
12-
{% block content '' %}
13-
<hr />
14-
<script type="text/javascript" src="{{ app.request.basepath }}/vendor/jquery-1.9.0.min.js"></script>
15-
<script type="text/javascript" src="{{ app.request.basepath }}/js/log.js"></script>
10+
<div class="gitonomy-browser-wrapper">
11+
<div class="gitonomy-browser">
12+
<h1>
13+
{% if repository|default(false) %}
14+
<a class="project-name" href="{{ path('repository') }}">{{ repository.name }}</a>
15+
-
16+
{% endif %}
17+
<a href="{{ path('repositories') }}">gitonomy/browser</a>
18+
</h1>
19+
<div class="gitonomy-browser-content">
20+
{% block content '' %}
21+
</div>
22+
<div class="gitonomy-browser-footer">
23+
<p>
24+
Powered by <a href="http://gitonomy.com">gitonomy</a>
25+
</p>
26+
</div>
27+
</div>
1628
</div>
29+
<script type="text/javascript" src="{{ app.request.basepath }}/vendor/jquery-1.9.0.min.js"></script>
30+
<script type="text/javascript" src="{{ app.request.basepath }}/js/log.js"></script>
1731
</body>
1832
</html>

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
{% block content %}
66
<h2>
7-
<a href="{{ path('repository') }}">
8-
{{ repository }}
9-
</a>
10-
&gt;
117
{% if reference is git_branch %}
128
branch {{ reference.name }}
139
{% elseif reference is git_tag %}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
{% extends "layout.html.twig" %}
22

33
{% block content %}
4-
<h2>{{ repository }}</h2>
5-
6-
<h3>Branches:</h3>
4+
<h3>Branches</h3>
75
{{ git_branches(repository) }}
86

9-
<h3>Tags:</h3>
7+
<h3>Tags</h3>
108
{{ git_tags(repository) }}
119

12-
<h3>Logs:</h3>
10+
<h3>Logs</h3>
1311
{{ git_log(repository.log.setLimit(30), {query_url: path('log_ajax')}) }}
1412
{% endblock %}

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,11 @@
22

33
{% block content %}
44
{% for repository in repositories %}
5-
<h2>
5+
<h3>
66
<a href="{{ path('repository', {repository: repository}) }}">
77
{{ repository }}
88
</a>
9-
</h2>
10-
<ul>
11-
{% for branch in repository.references.localBranches %}
12-
<li>
13-
{% spaceless %}
14-
<a href="{{ path('reference', {repository: repository, fullname: branch.fullname}) }}">
15-
<strong>{{ branch.name }}</strong>
16-
</a>
17-
{% endspaceless %}
18-
<small>
19-
{{ git_author(branch.commit) }}
20-
{{ branch.commit.authorDate.format('d/m/Y') }}
21-
</small>
22-
</li>
23-
{% endfor %}
24-
</ul>
9+
</h3>
10+
{{ git_branches(repository, {local_only: true}) }}
2511
{% endfor %}
2612
{% endblock %}

src/Gitonomy/Browser/Twig/GitExtension.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,18 @@ public function renderDiff(\Twig_Environment $env, Diff $diff, array $options =
123123
));
124124
}
125125

126-
public function renderBranches(\Twig_Environment $env, Repository $repository)
126+
public function renderBranches(\Twig_Environment $env, Repository $repository, array $options = array())
127127
{
128+
$options = array_merge(array('local_only' => false), $options);
129+
130+
if (!$options['local_only']) {
131+
$branches = $repository->getReferences()->getBranches();
132+
} else {
133+
$branches = $repository->getReferences()->getLocalBranches();
134+
}
135+
128136
return $this->renderBlock($env, 'branches', array(
129-
'branches' => $repository->getReferences()->getBranches(),
137+
'branches' => $branches,
130138
));
131139
}
132140

@@ -152,11 +160,6 @@ public function renderAuthor(\Twig_Environment $env, Commit $commit, array $opti
152160
));
153161
}
154162

155-
public function getName()
156-
{
157-
return 'git';
158-
}
159-
160163
public function addThemes($themes)
161164
{
162165
$themes = reset($themes);
@@ -179,4 +182,12 @@ public function renderBlock(\Twig_Environment $env, $block, $context = array())
179182

180183
throw new \InvalidArgumentException('Unable to find block '.$block);
181184
}
185+
186+
/**
187+
* {@inheritdoc}
188+
*/
189+
public function getName()
190+
{
191+
return 'git';
192+
}
182193
}

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+

0 commit comments

Comments
 (0)