diff --git a/app/config/routing.yml b/app/config/routing.yml index f74e139..0421f47 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -3,5 +3,9 @@ home: defaults: {_controller: Gist\Controller\EditController::createAction, _locale: en} view: - path: /{gist}/{commit} + path: /view/{gist}/{commit} defaults: {_controller: Gist\Controller\ViewController::viewAction, _locale: en, commit: 0} + +revisions: + path: /revs/{gist} + defaults: {_controller: Gist\Controller\ViewController::revisionsAction, _locale: en} diff --git a/src/Gist/Controller/ViewController.php b/src/Gist/Controller/ViewController.php index 43d323d..0f7f01e 100644 --- a/src/Gist/Controller/ViewController.php +++ b/src/Gist/Controller/ViewController.php @@ -35,17 +35,41 @@ class ViewController 'gist' => $gist, 'type' => $gist->getType(), 'history' => $history, + 'commit' => $commit, 'content' => $app['gist']->highlight($gist->getType(), $content), ) ); } + public function revisionsAction(Request $request, Application $app, $gist) + { + $gist = GistQuery::create()->findOneByFile($gist); + + if (null === $gist) { + return $this->notFoundResponse($app); + } + + $history = $app['gist']->getHistory($gist); + + if (empty($history)) { + return $this->notFoundResponse($app); + } + + return $app['twig']->render( + 'View/revisions.html.twig', + array( + 'gist' => $gist, + 'history' => $history, + ) + ); + } + protected function notFoundResponse(Application $app) { return $app['twig']->render('View/notFound.html.twig'); } - protected function getContentByCommit(Application $app, Gist $gist, $commit, $history) + protected function getContentByCommit(Application $app, Gist $gist, &$commit, $history) { if ($commit === 0) { $commit = $history[0]['commit']; diff --git a/src/Gist/Resources/views/View/revisions.html.twig b/src/Gist/Resources/views/View/revisions.html.twig new file mode 100644 index 0000000..a9b61b8 --- /dev/null +++ b/src/Gist/Resources/views/View/revisions.html.twig @@ -0,0 +1,94 @@ +{% extends 'base.html.twig' %} + +{% block css %} + + + {{ parent() }} +{% endblock %} + +{% block body %} +
+
+ {% if not gist.cipher %} + + {% endif %} + +
+
+ {% if not gist.cipher %} + + {% endif %} + + {{ gist.title ? gist.title : 'gist.untitled'|trans }} +
+
+
+ {% if not gist.cipher %} +
+ {% for commit in history %} +
+

+ + {{ commit.commit|slice(0, 10) }} + + + {% if loop.first %}init{% endif %} + + {% if not loop.first %} + + diff + + {% endif %} +

+

+ {{ commit.date|date('date.format'|trans) }} +

+
+ {% if not loop.first %} + +
+ {{ commit.diff|raw }} +
+ {% endif %} +
+
+ + {% if not loop.last %} +
+ {% endif %} + {% endfor %} +
+ {% endif %} +
+
+
+
+
+{% endblock %} + +{% block js %} + {{ parent() }} +{% endblock %} diff --git a/src/Gist/Resources/views/View/view.html.twig b/src/Gist/Resources/views/View/view.html.twig index 8e51d6f..ded0d84 100644 --- a/src/Gist/Resources/views/View/view.html.twig +++ b/src/Gist/Resources/views/View/view.html.twig @@ -12,10 +12,10 @@ {% if not gist.cipher %}