diff --git a/app/config/routing.yml b/app/config/routing.yml index b5cefa4..8696989 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -10,6 +10,14 @@ view: path: /view/{gist}/{commit} defaults: {_controller: Gist\Controller\ViewController::viewAction, _locale: en, commit: 0} +embed: + path: /embed/{gist}/{commit} + defaults: {_controller: Gist\Controller\ViewController::embedAction, _locale: en, commit: 0} + +embedjs: + path: /embedjs/{gist}/{commit} + defaults: {_controller: Gist\Controller\ViewController::embedJsAction, _locale: en, commit: 0} + raw: path: /raw/{gist}/{commit} defaults: {_controller: Gist\Controller\ViewController::rawAction, _locale: en, commit: 0} diff --git a/app/locales/en.yml b/app/locales/en.yml index 870b3b8..a8fd24c 100644 --- a/app/locales/en.yml +++ b/app/locales/en.yml @@ -19,10 +19,14 @@ gist: raw: 'RAW' download: 'Download' clone: 'Clone' + embed: 'Embed:' date: format: 'Y-m-d h:i:s' +footer: + text: '
Powered by GIST
' + form: error: not_blank: 'This value should not be blank bro!' diff --git a/app/locales/fr.yml b/app/locales/fr.yml index 4d6d58c..31c5ba9 100644 --- a/app/locales/fr.yml +++ b/app/locales/fr.yml @@ -19,10 +19,14 @@ gist: raw: 'RAW' download: 'Télécharger' clone: 'Clôner' + embed: 'Insérer : ' date: format: 'd/m/Y H\hi s\s' +footer: + text: 'Propulsé avec GIST
' + form: error: not_blank: 'Vous devez saisir cette donnée.' diff --git a/bower.json b/bower.json index 9ccae1e..6f20eb6 100644 --- a/bower.json +++ b/bower.json @@ -15,6 +15,7 @@ "dependencies": { "bootstrap": "3.3.4", "flag-icon-css": "0.7.1", - "SyntaxHighlighter": "3.0.83" + "SyntaxHighlighter": "3.0.83", + "iframe-resizer": "2.8.6" } } diff --git a/src/Gist/Controller/ViewController.php b/src/Gist/Controller/ViewController.php index a772eb8..d26b88d 100644 --- a/src/Gist/Controller/ViewController.php +++ b/src/Gist/Controller/ViewController.php @@ -25,6 +25,30 @@ class ViewController extends Controller } } + public function embedAction(Request $request, Application $app, $gist, $commit) + { + $viewOptions = $this->getViewOptions($request, $app, $gist, $commit); + + if (is_array($viewOptions)) { + return $app['twig']->render('View/embed.html.twig', $viewOptions); + } else { + return $this->notFoundResponse($app); + } + } + + public function embedJsAction(Request $request, Application $app, $gist, $commit) + { + $viewOptions = $this->getViewOptions($request, $app, $gist, $commit); + + return new Response( + $app['twig']->render('View/embedJs.html.twig', $viewOptions), + 200, + array( + 'Content-Type' => 'text/javascript', + ) + ); + } + public function rawAction(Request $request, Application $app, $gist, $commit) { $viewOptions = $this->getViewOptions($request, $app, $gist, $commit); diff --git a/src/Gist/Resources/views/View/embed.html.twig b/src/Gist/Resources/views/View/embed.html.twig new file mode 100644 index 0000000..3a6b13b --- /dev/null +++ b/src/Gist/Resources/views/View/embed.html.twig @@ -0,0 +1,93 @@ +{% extends 'base.html.twig' %} + +{% block css %} + + + {{ parent() }} + + +{% endblock %} + +{% block title %}{{ gist.title ? gist.title : 'gist.untitled'|trans }} - {{ commit|slice(0, 10) }}{% endblock %} + +{% block nav %}{% endblock %} + +{% block body %} +{{ raw_content|raw }}+ {% else %} + {{ content|raw }} + {% endif %} +
+ {{ 'gist.action.embed'|trans }} + ' }}" /> +
{% if not gist.cipher %}