diff --git a/app/locales/fr.yml b/app/locales/fr.yml index d51c1e7..a856fa0 100644 --- a/app/locales/fr.yml +++ b/app/locales/fr.yml @@ -34,7 +34,7 @@ form: choice: yes: 'Oui' no: 'Non' - submit: 'Send' + submit: 'Envoyer' type: label: 'Langage : %value%' choice: diff --git a/bower.json b/bower.json index 716f91d..7288ac5 100644 --- a/bower.json +++ b/bower.json @@ -13,6 +13,7 @@ "homepage": "https://gitlab.deblan.org/deblan/gist.deblan.org", "dependencies": { "bootstrap": "3.3.4", - "flag-icon-css": "0.7.1" + "flag-icon-css": "0.7.1", + "SyntaxHighlighter": "3.0.83" } } diff --git a/src/Gist/Resources/views/View/view.html.twig b/src/Gist/Resources/views/View/view.html.twig index 8c8e3b5..edc28af 100644 --- a/src/Gist/Resources/views/View/view.html.twig +++ b/src/Gist/Resources/views/View/view.html.twig @@ -3,9 +3,16 @@ {% block css %} + {% if gist.cipher %} + + + {% endif %} + {{ parent() }} {% endblock %} +{% block title %}{{ gist.title ? gist.title : 'gist.untitled'|trans }} - {{ commit|slice(0, 10) }}{% endblock %} + {% block body %}
@@ -66,7 +73,7 @@
{% if gist.cipher %} -
{{ content }}
+
{{ raw_content|raw }}
{% else %} {{ content|raw }} {% endif %} @@ -117,4 +124,37 @@ {% block js %} {{ parent() }} + + {% if gist.cipher %} + + + + + {% endif %} {% endblock %} diff --git a/web/app/js/app.js b/web/app/js/app.js index a116502..6ecc1d4 100644 --- a/web/app/js/app.js +++ b/web/app/js/app.js @@ -66,9 +66,9 @@ var editorEvents = function() { $(this).trigger('change'); }); - $('.show-diff').click(function() { - $($(this).data('target')).toggle(); - }); + $('.show-diff').click(function() { + $($(this).data('target')).toggle(); + }); } var mainEditorEvents = function() { @@ -94,8 +94,28 @@ var mainEditorEvents = function() { }); } +var viewerEvents = function() { + if (0 === $('.syntaxhighlighter').length) { + return; + } + + $(document).ready(function() { + var url = document.location.href; + var parts = url.split('#key='); + + if (parts.length === 2) { + var decrypted = CryptoJS.AES.decrypt($('.syntaxhighlighter').html(), parts[1], { + format: JsonFormatter + }); + $('.syntaxhighlighter').text(decrypted.toString(CryptoJS.enc.Utf8)); + SyntaxHighlighter.all(); + } + }); +} + var bootstrap = function() { editorEvents(); + viewerEvents(); mainEditorEvents(); }