From dfcc4569d04dfaafae73e7cac84e7cad14636265 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 6 May 2015 22:46:29 +0200 Subject: [PATCH] diff --- src/Gist/Resources/views/View/view.html.twig | 19 ++++++++++++++----- src/Gist/Service/GistService.php | 14 +++++++++++++- web/app/css/app.css | 11 +++++++---- web/app/js/app.js | 4 ++++ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/Gist/Resources/views/View/view.html.twig b/src/Gist/Resources/views/View/view.html.twig index f345e84..96eda55 100644 --- a/src/Gist/Resources/views/View/view.html.twig +++ b/src/Gist/Resources/views/View/view.html.twig @@ -71,17 +71,26 @@

Commit {{ commit.commit }} + + {% if loop.first %}(init){% endif %} +
Date: {{ commit.date|date('date.format'|trans) }}

-

+

Afficher - - DIFF - -

+ {% if not loop.first %} + + DIFF + + +
+
{{ commit.diff }}
+
+ {% endif %} +
{% if not loop.last %} diff --git a/src/Gist/Service/GistService.php b/src/Gist/Service/GistService.php index 5885eef..62fdbdc 100644 --- a/src/Gist/Service/GistService.php +++ b/src/Gist/Service/GistService.php @@ -43,10 +43,22 @@ class GistService $history = []; 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]), 'date' => new \DateTime(trim($dates[$i][1])), + 'diff' => $diff, ); + + $history[] = $data; } return $history; diff --git a/web/app/css/app.css b/web/app/css/app.css index d82e15f..75592eb 100644 --- a/web/app/css/app.css +++ b/web/app/css/app.css @@ -26,17 +26,17 @@ body { margin-right: 4px; } -#viewer > pre { +pre { background: #222; border: #222; color: #ddd; } -#viewer pre ol { - padding-left: 50px; +pre ol { + padding-left: 50px !important; } -#viewer li:hover { +pre li:hover { background: #222; } @@ -44,3 +44,6 @@ body { margin-top: -5px; } +.diff { + display: none; +} diff --git a/web/app/js/app.js b/web/app/js/app.js index 33e55dc..509fb8c 100644 --- a/web/app/js/app.js +++ b/web/app/js/app.js @@ -65,6 +65,10 @@ var editorEvents = function() { $('#options input:checked').each(function() { $(this).trigger('change'); }); + + $('.show-diff').click(function() { + $(this).next().toggle(); + }); } var mainEditorEvents = function() {