forked from deblan/gist
Ciphered GIST cloning
This commit is contained in:
parent
c8d35c23bb
commit
6ab827bf94
|
@ -17,7 +17,14 @@
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
{{ form_errors(form.content) }}
|
{{ form_errors(form.content) }}
|
||||||
{{ form_widget(form.content) }}
|
|
||||||
|
{% set class = 'form-control' %}
|
||||||
|
|
||||||
|
{% if gist.cipher %}
|
||||||
|
{% set class = class ~ ' cipher-editor' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{{ form_widget(form.content, {attr: {class: class}}) }}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<input type="submit" class="btn btn-primary" value="{{ 'form.submit'|trans }}">
|
<input type="submit" class="btn btn-primary" value="{{ 'form.submit'|trans }}">
|
||||||
|
@ -29,3 +36,13 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{% if gist.cipher %}
|
||||||
|
<script>
|
||||||
|
var cipherGistClone = true;
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{{ parent() }}
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -50,14 +50,14 @@
|
||||||
<div class="col-md-12" id="embed">
|
<div class="col-md-12" id="embed">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
{% if not gist.cipher %}
|
<div class="pull-right actions">
|
||||||
<div class="pull-right actions">
|
<a target="_blank" href="{{ path('view', app.request.attributes.get('_route_params')) }}" class="btn btn-default btn-sm">
|
||||||
<a target="_blank" href="{{ path('view', app.request.attributes.get('_route_params')) }}" class="btn btn-default btn-sm">
|
<span class="btn btn-warning btn-xs">
|
||||||
<span class="btn btn-warning btn-xs">
|
{{ commit|slice(0, 10) }}
|
||||||
{{ commit|slice(0, 10) }}
|
</span>
|
||||||
</span>
|
</a>
|
||||||
</a>
|
|
||||||
|
|
||||||
|
{% if not gist.cipher %}
|
||||||
<a target="_blank" href="{{ path('raw', app.request.attributes.get('_route_params')) }}" class="btn btn-default btn-sm">
|
<a target="_blank" href="{{ path('raw', app.request.attributes.get('_route_params')) }}" class="btn btn-default btn-sm">
|
||||||
<span class="glyphicon glyphicon-eye-open"></span>
|
<span class="glyphicon glyphicon-eye-open"></span>
|
||||||
{{ 'gist.action.raw'|trans }}
|
{{ 'gist.action.raw'|trans }}
|
||||||
|
@ -66,12 +66,13 @@
|
||||||
<span class="glyphicon glyphicon-save-file"></span>
|
<span class="glyphicon glyphicon-save-file"></span>
|
||||||
{{ 'gist.action.download'|trans }}
|
{{ 'gist.action.download'|trans }}
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="{{ path('clone', app.request.attributes.get('_route_params')) }}" class="btn btn-success btn-sm">
|
{% endif %}
|
||||||
<span class="glyphicon glyphicon-copy"></span>
|
|
||||||
{{ 'gist.action.clone'|trans }}
|
<a target="_blank" href="{{ path('clone', app.request.attributes.get('_route_params')) }}" class="btn btn-success btn-sm">
|
||||||
</a>
|
<span class="glyphicon glyphicon-copy"></span>
|
||||||
</div>
|
{{ 'gist.action.clone'|trans }}
|
||||||
{% endif %}
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{ gist.title ? gist.title : 'gist.untitled'|trans }}
|
{{ gist.title ? gist.title : 'gist.untitled'|trans }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,21 +11,19 @@
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
{% if not gist.cipher %}
|
<ul class="nav nav-tabs">
|
||||||
<ul class="nav nav-tabs">
|
<li>
|
||||||
<li>
|
<a href="{{ path('view', {gist: gist.file}) }}" class="cipher-link">
|
||||||
<a href="{{ path('view', {gist: gist.file}) }}">
|
{{ 'gist.action.view'|trans }}
|
||||||
{{ 'gist.action.view'|trans }}
|
</a>
|
||||||
</a>
|
</li>
|
||||||
</li>
|
<li class="active">
|
||||||
<li class="active">
|
<a href="{{ path('revisions', {gist: gist.file}) }}" class="cipher-link">
|
||||||
<a href="{{ path('revisions', {gist: gist.file}) }}">
|
{{ 'gist.action.history'|trans }}
|
||||||
{{ 'gist.action.history'|trans }}
|
<span class="badge">{{ history|length }}</span>
|
||||||
<span class="badge">{{ history|length }}</span>
|
</a>
|
||||||
</a>
|
</li>
|
||||||
</li>
|
</ul>
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
|
@ -33,42 +31,40 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
{% if not gist.cipher %}
|
<div id="revisions" class="tab-pane in active">
|
||||||
<div id="revisions" class="tab-pane in active">
|
{% for commit in history %}
|
||||||
{% for commit in history %}
|
<div class="commit">
|
||||||
<div class="commit">
|
<p>
|
||||||
<p>
|
<a href="{{ path('view', {gist: gist.file, commit: commit.commit}) }}" class="btn btn-warning btn-sm cipher-link">
|
||||||
<a href="{{ path('view', {gist: gist.file, commit: commit.commit}) }}" class="btn btn-warning btn-sm">
|
{{ commit.commit|slice(0, 10) }}
|
||||||
{{ commit.commit|slice(0, 10) }}
|
</a>
|
||||||
|
|
||||||
|
{% if loop.first %}<span class="btn btn-info btn-sm">init</span>{% endif %}
|
||||||
|
|
||||||
|
{% if not loop.first %}
|
||||||
|
<a href="#diff-{{ loop.index }}" data-target="#diff-{{ loop.index }}" class="btn btn-default btn-sm show-diff">
|
||||||
|
diff
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{{ commit.date|date('date.format'|trans) }}
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
{% if not loop.first %}
|
||||||
|
|
||||||
{% if loop.first %}<span class="btn btn-info btn-sm">init</span>{% endif %}
|
<div class="diff" id="diff-{{ loop.index }}">
|
||||||
|
{{ commit.diff|raw }}
|
||||||
{% if not loop.first %}
|
</div>
|
||||||
<a href="#diff-{{ loop.index }}" data-target="#diff-{{ loop.index }}" class="btn btn-default btn-sm show-diff">
|
{% endif %}
|
||||||
diff
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
{{ commit.date|date('date.format'|trans) }}
|
|
||||||
</p>
|
|
||||||
<div>
|
|
||||||
{% if not loop.first %}
|
|
||||||
|
|
||||||
<div class="diff" id="diff-{{ loop.index }}">
|
|
||||||
{{ commit.diff|raw }}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% if not loop.last %}
|
{% if not loop.last %}
|
||||||
<hr />
|
<hr />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,29 +16,28 @@
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
{% if not gist.cipher %}
|
<ul class="nav nav-tabs">
|
||||||
<ul class="nav nav-tabs">
|
<li class="active">
|
||||||
<li class="active">
|
<a href="{{ path('view', {gist: gist.file}) }}" class="cipher-link">
|
||||||
<a href="{{ path('view', {gist: gist.file}) }}">
|
{{ 'gist.action.view'|trans }}
|
||||||
{{ 'gist.action.view'|trans }}
|
</a>
|
||||||
</a>
|
</li>
|
||||||
</li>
|
<li>
|
||||||
<li>
|
<a href="{{ path('revisions', {gist: gist.file}) }}" class="cipher-link">
|
||||||
<a href="{{ path('revisions', {gist: gist.file}) }}">
|
{{ 'gist.action.history'|trans }}
|
||||||
{{ 'gist.action.history'|trans }}
|
<span class="badge">{{ history|length }}</span>
|
||||||
<span class="badge">{{ history|length }}</span>
|
</a>
|
||||||
</a>
|
</li>
|
||||||
</li>
|
</ul>
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
{% if not gist.cipher %}
|
<div class="pull-right actions">
|
||||||
<div class="pull-right actions">
|
<span class="btn btn-warning btn-xs">
|
||||||
<span class="btn btn-warning btn-xs">
|
{{ commit|slice(0, 10) }}
|
||||||
{{ commit|slice(0, 10) }}
|
</span>
|
||||||
</span>
|
|
||||||
|
|
||||||
|
{% if not gist.cipher %}
|
||||||
<a href="{{ path('raw', app.request.attributes.get('_route_params')) }}" class="btn btn-default btn-sm">
|
<a href="{{ path('raw', app.request.attributes.get('_route_params')) }}" class="btn btn-default btn-sm">
|
||||||
<span class="glyphicon glyphicon-eye-open"></span>
|
<span class="glyphicon glyphicon-eye-open"></span>
|
||||||
{{ 'gist.action.raw'|trans }}
|
{{ 'gist.action.raw'|trans }}
|
||||||
|
@ -47,12 +46,13 @@
|
||||||
<span class="glyphicon glyphicon-save-file"></span>
|
<span class="glyphicon glyphicon-save-file"></span>
|
||||||
{{ 'gist.action.download'|trans }}
|
{{ 'gist.action.download'|trans }}
|
||||||
</a>
|
</a>
|
||||||
<a href="{{ path('clone', app.request.attributes.get('_route_params')) }}" class="btn btn-success btn-sm">
|
{% endif %}
|
||||||
<span class="glyphicon glyphicon-copy"></span>
|
|
||||||
{{ 'gist.action.clone'|trans }}
|
<a href="{{ path('clone', app.request.attributes.get('_route_params')) }}" class="btn btn-success btn-sm cipher-link">
|
||||||
</a>
|
<span class="glyphicon glyphicon-copy"></span>
|
||||||
</div>
|
{{ 'gist.action.clone'|trans }}
|
||||||
{% endif %}
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{ gist.title ? gist.title : 'gist.untitled'|trans }}
|
{{ gist.title ? gist.title : 'gist.untitled'|trans }}
|
||||||
|
|
||||||
|
|
|
@ -71,10 +71,10 @@
|
||||||
</ul>
|
</ul>
|
||||||
{% block langs %}
|
{% block langs %}
|
||||||
<p class="navbar-text navbar-right">
|
<p class="navbar-text navbar-right">
|
||||||
<a class="lang btn btn-xs" href="{{ path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge({_locale: 'en'})) }}">
|
<a class="lang btn btn-xs cipher-link" href="{{ path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge({_locale: 'en'})) }}">
|
||||||
<span class="flag-icon flag-icon-gb"></span>
|
<span class="flag-icon flag-icon-gb"></span>
|
||||||
</a>
|
</a>
|
||||||
<a class="lang btn btn-xs" href="{{ path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge({_locale: 'fr'})) }}">
|
<a class="lang btn btn-xs cipher-link" href="{{ path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge({_locale: 'fr'})) }}">
|
||||||
<span class="flag-icon flag-icon-fr"></span>
|
<span class="flag-icon flag-icon-fr"></span>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -94,8 +94,15 @@ var mainEditorEvents = function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#main-form').submit(function(e) {
|
$('#main-form').submit(function(e) {
|
||||||
if ($('.cipher-input:checked').val() === 'yes') {
|
if ($('.cipher-input:checked').val() === 'yes' || typeof cipherGistClone !== 'undefined') {
|
||||||
var passphrase = randomString(256, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
var key = getKey();
|
||||||
|
|
||||||
|
if (key) {
|
||||||
|
var passphrase = key;
|
||||||
|
} else {
|
||||||
|
var passphrase = randomString(256, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||||
|
}
|
||||||
|
|
||||||
var content = $('#form_content').val();
|
var content = $('#form_content').val();
|
||||||
var encrypted = CryptoJS.AES.encrypt(content, passphrase, {
|
var encrypted = CryptoJS.AES.encrypt(content, passphrase, {
|
||||||
format: JsonFormatter
|
format: JsonFormatter
|
||||||
|
@ -123,25 +130,43 @@ var viewerEvents = function() {
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var key = getKey();
|
var key = getKey();
|
||||||
|
|
||||||
|
var $cipherEditor = $('.cipher-editor');
|
||||||
var $embedInput = $('#embed-input');
|
var $embedInput = $('#embed-input');
|
||||||
var to = ' ';
|
|
||||||
|
|
||||||
if (0 !== $render.length && key) {
|
if (key) {
|
||||||
var decrypted = CryptoJS.AES.decrypt($render.html(), key, {
|
$('.cipher-link').each(function() {
|
||||||
format: JsonFormatter
|
var href = $(this).attr('href');
|
||||||
|
href = href + '#key=' + key;
|
||||||
|
|
||||||
|
$(this).attr('href', href);
|
||||||
});
|
});
|
||||||
$render.text(decrypted.toString(CryptoJS.enc.Utf8));
|
|
||||||
SyntaxHighlighter.all();
|
|
||||||
|
|
||||||
to = ' data-key="#key=' + key + '" ';
|
var to = ' ';
|
||||||
|
|
||||||
$('.lang').each(function() {
|
if (0 !== $render.length || $cipherEditor.length !== 0) {
|
||||||
$(this).attr('href', $(this).attr('href') + '#key=' + key);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($embedInput.length) {
|
if ($render.length !== 0) {
|
||||||
$embedInput.val($embedInput.val().replace('%key%', to));
|
var decrypted = CryptoJS.AES.decrypt($render.html(), key, {
|
||||||
|
format: JsonFormatter
|
||||||
|
});
|
||||||
|
|
||||||
|
$render.text(decrypted.toString(CryptoJS.enc.Utf8));
|
||||||
|
SyntaxHighlighter.all();
|
||||||
|
|
||||||
|
to = ' data-key="#key=' + key + '" ';
|
||||||
|
} else {
|
||||||
|
var decrypted = CryptoJS.AES.decrypt($cipherEditor.val(), key, {
|
||||||
|
format: JsonFormatter
|
||||||
|
});
|
||||||
|
|
||||||
|
$cipherEditor.val(decrypted.toString(CryptoJS.enc.Utf8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($embedInput.length) {
|
||||||
|
$embedInput.val($embedInput.val().replace('%key%', to));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue