This commit is contained in:
Simon Vieille 2015-05-06 22:46:29 +02:00
parent c371c56a9a
commit dfcc4569d0
4 changed files with 38 additions and 10 deletions

View file

@ -71,17 +71,26 @@
<div class="commit"> <div class="commit">
<p> <p>
Commit <strong class="text-warning">{{ commit.commit }}</strong> Commit <strong class="text-warning">{{ commit.commit }}</strong>
{% if loop.first %}(init){% endif %}
<br/> <br/>
Date: {{ commit.date|date('date.format'|trans) }} Date: {{ commit.date|date('date.format'|trans) }}
</p> </p>
<p> <div>
<a href="{{ path('view', {gist: gist.file, commit: commit.commit}) }}" class="btn btn-primary"> <a href="{{ path('view', {gist: gist.file, commit: commit.commit}) }}" class="btn btn-primary">
Afficher Afficher
</a> </a>
<a class="btn btn-default"> {% if not loop.first %}
DIFF <a href="#diff-{{ loop.index }}" id="diff-{{ loop.index }}" class="btn btn-default show-diff">
</a> DIFF
</p> </a>
<div class="diff">
<pre>{{ commit.diff }}</pre>
</div>
{% endif %}
</div>
</div> </div>
{% if not loop.last %} {% if not loop.last %}

View file

@ -43,10 +43,22 @@ class GistService
$history = []; $history = [];
for ($i = count($commits) - 1; $i >= 0; $i--) { for ($i = count($commits) - 1; $i >= 0; $i--) {
$history[] = array( $commit = trim($commits[$i][1]);
$command = GitCommand::getInstance('show', $commit);
$command->setDirectory($this->gistPath);
$command->bypass(false);
$diff = explode("\n", $this->gitWrapper->run($command));
$diff = implode("\n", array_slice($diff, 11));
$data = array(
'commit' => trim($commits[$i][1]), 'commit' => trim($commits[$i][1]),
'date' => new \DateTime(trim($dates[$i][1])), 'date' => new \DateTime(trim($dates[$i][1])),
'diff' => $diff,
); );
$history[] = $data;
} }
return $history; return $history;

View file

@ -26,17 +26,17 @@ body {
margin-right: 4px; margin-right: 4px;
} }
#viewer > pre { pre {
background: #222; background: #222;
border: #222; border: #222;
color: #ddd; color: #ddd;
} }
#viewer pre ol { pre ol {
padding-left: 50px; padding-left: 50px !important;
} }
#viewer li:hover { pre li:hover {
background: #222; background: #222;
} }
@ -44,3 +44,6 @@ body {
margin-top: -5px; margin-top: -5px;
} }
.diff {
display: none;
}

View file

@ -65,6 +65,10 @@ var editorEvents = function() {
$('#options input:checked').each(function() { $('#options input:checked').each(function() {
$(this).trigger('change'); $(this).trigger('change');
}); });
$('.show-diff').click(function() {
$(this).next().toggle();
});
} }
var mainEditorEvents = function() { var mainEditorEvents = function() {