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

Commit ac3a2fc

Browse files
author
alexandresalome
committed
add option local_only to branch block
1 parent 3a9c422 commit ac3a2fc

File tree

5 files changed

+63
-50
lines changed

5 files changed

+63
-50
lines changed

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

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,33 +105,37 @@
105105

106106
{% block branches %}
107107
{% 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 %}
108+
<ul>
109+
{% for branch in branches %}
110+
<li>
111+
<a href="{{ git_url(branch) }}">
112+
<strong>{{ branch.name }}</strong>
113+
</a>
114+
<small>
115+
{{ git_author(branch.commit) }}
116+
{{ branch.commit.authorDate.format('d/m/Y') }}
117+
</small>
118+
</li>
119+
{% endfor %}
120+
</ul>
119121
{% endspaceless %}
120122
{% endblock %}
121123

122124
{% block tags %}
123125
{% 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 %}
126+
<ul>
127+
{% for tag in tags %}
128+
<li>
129+
<a href="{{ git_url(tag) }}">
130+
<strong>{{ tag.name }}</strong>
131+
</a>
132+
<small>
133+
{{ git_author(tag.commit) }}
134+
{{ tag.commit.authorDate.format('d/m/Y') }}
135+
</small>
136+
</li>
137+
{% endfor %}
138+
</ul>
135139
{% endspaceless %}
136140
{% endblock %}
137141

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{% extends "layout.html.twig" %}
22

33
{% block content %}
4-
<h2>Branches</h2>
4+
<h3>Branches</h3>
55
{{ git_branches(repository) }}
66

7-
<h2>Tags</h2>
7+
<h3>Tags</h3>
88
{{ git_tags(repository) }}
99

10-
<h2>Logs</h2>
10+
<h3>Logs</h3>
1111
{{ git_log(repository.log.setLimit(30), {query_url: path('log_ajax')}) }}
1212
{% 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/layout.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
h1, h2, h3, p, body {
1+
h1, h2, h3, p, body, ul, li {
22
margin: 0;
33
padding: 0;
44
}
55

6+
li {
7+
list-style-type: none;
8+
}
9+
610
body {
711
margin: 0;
812
font-family: sans-serif;
@@ -72,9 +76,17 @@ body {
7276
}
7377

7478
.gitonomy-browser h2 {
79+
font-weight: normal;
80+
font-size: 2em;
81+
line-height: 2em;
82+
color: #333;
83+
}
84+
85+
.gitonomy-browser h3 {
7586
font-weight: normal;
7687
font-size: 1.3em;
7788
padding-top: 1em;
89+
margin-bottom: 0.3em;
7890
color: #333;
7991
border-bottom: 1px solid #ddd;
8092
}

0 commit comments

Comments
 (0)