diff --git a/cfg/conf.ini.sample b/cfg/conf.ini.sample index 4fdce17..01433a2 100644 --- a/cfg/conf.ini.sample +++ b/cfg/conf.ini.sample @@ -52,6 +52,11 @@ languageselection = false ; if this is set and language selection is disabled, this will be the only language ; languagedefault = "en" +; (optional) URL shortener address to offer after a new paste is created +; it is suggested to only use this with self-hosted shorteners as this will leak +; the pastes encryption key +; urlshortener = "https://shortener.example.com/api?link=" + [expire] ; expire value that is selected per default ; make sure the value exists in [expire_options] diff --git a/i18n/de.json b/i18n/de.json index 4cdebec..191c69f 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -135,5 +135,6 @@ "Your browser does not support uploading encrypted files. Please use a newer browser.": "Dein Browser unterstützt das hochladen von verschlüsselten Dateien nicht. Bitte verwende einen neueren Browser.", "Invalid attachment.": "Ungültiger Datei-Anhang.", - "Options": "Optionen" + "Options": "Optionen", + "Shorten URL": "URL verkürzen" } diff --git a/i18n/fr.json b/i18n/fr.json index 87b7ca9..8736314 100644 --- a/i18n/fr.json +++ b/i18n/fr.json @@ -144,5 +144,6 @@ "Your browser does not support uploading encrypted files. Please use a newer browser.": "Votre navigateur ne supporte pas l'envoi de fichiers chiffrés. Merci d'utiliser un navigateur plus récent.", "Invalid attachment.": "Attachement invalide.", - "Options": "Options" + "Options": "Options", + "Shorten URL": "Raccourcir URL" } diff --git a/i18n/pl.json b/i18n/pl.json index b5ba538..82085fd 100644 --- a/i18n/pl.json +++ b/i18n/pl.json @@ -135,5 +135,6 @@ "Your browser does not support uploading encrypted files. Please use a newer browser.": "Your browser does not support uploading encrypted files. Please use a newer browser.", "Invalid attachment.": "Invalid attachment.", - "Options": "Options" + "Options": "Options", + "Shorten URL": "Skróć adres URL" } diff --git a/i18n/sl.json b/i18n/sl.json index 53fac9c..a7e9542 100644 --- a/i18n/sl.json +++ b/i18n/sl.json @@ -144,5 +144,6 @@ "Your browser does not support uploading encrypted files. Please use a newer browser.": "Tvoj brskalnik ne omogoča nalaganje zakodiranih datotek. Prosim uporabi novejši brskalnik.", "Invalid attachment.": "Neveljavna priponka.", - "Options": "Možnosti" + "Options": "Možnosti", + "Shorten URL": "Skrajšajte URL" } diff --git a/img/icon_shorten.png b/img/icon_shorten.png new file mode 100644 index 0000000..324cbaa Binary files /dev/null and b/img/icon_shorten.png differ diff --git a/js/zerobin.js b/js/zerobin.js index 460a6b6..530f860 100644 --- a/js/zerobin.js +++ b/js/zerobin.js @@ -405,7 +405,7 @@ $(function() { * translation cache */ translations: {} - } + }; /** * filter methods @@ -921,7 +921,7 @@ $(function() { filter.cipher(randomkey, password, e.target.result), filter.cipher(randomkey, password, theFile.name) ); - } + }; })(files[0]); reader.readAsDataURL(files[0]); } @@ -942,7 +942,9 @@ $(function() { /** * Send a new paste to server, step 2 * - * @param Event event + * @param string randomkey + * @param encrypted string cipherdata_attachment + * @param encrypted string cipherdata_attachment_name */ sendDataContinue: function(randomkey, cipherdata_attachment, cipherdata_attachment_name) { @@ -977,7 +979,12 @@ $(function() { zerobin.showStatus('', false); zerobin.errorMessage.addClass('hidden'); - $('#pastelink').html(i18n._('Your paste is %s (Hit [Ctrl]+[c] to copy)', url, url)); + $('#pastelink').html( + i18n._( + 'Your paste is %s (Hit [Ctrl]+[c] to copy)', + url, url + ) + zerobin.shortenUrl(url) + ); $('#deletelink').html('' + i18n._('Delete data') + ''); zerobin.pasteResult.removeClass('hidden'); // We pre-select the link so that the user only has to [Ctrl]+[c] the link. @@ -1004,6 +1011,26 @@ $(function() { }); }, + /** + * Check if a URL shortener was defined and create HTML containing a link to it. + * + * @param string url + * @return string html + */ + shortenUrl: function(url) + { + var shortenerHtml = $('#shortenbutton'); + if (shortenerHtml) { + var shortener = shortenerHtml.data('shortener'); + shortenerHtml.attr( + 'onclick', + "window.location.href = '" + shortener + encodeURIComponent(url) + "';" + ); + return ' ' + $('
').append(shortenerHtml.clone()).html(); + } + return ''; + }, + /** * Put the screen in "New paste" mode. */ diff --git a/lib/configuration.php b/lib/configuration.php index 7895b60..76ddb55 100644 --- a/lib/configuration.php +++ b/lib/configuration.php @@ -44,6 +44,7 @@ class configuration 'base64version' => '2.1.9', 'languageselection' => false, 'languagedefault' => '', + 'urlshortener' => '', ), 'expire' => array( 'default' => '1week', diff --git a/lib/zerobin.php b/lib/zerobin.php index 8179608..9e02fcb 100644 --- a/lib/zerobin.php +++ b/lib/zerobin.php @@ -455,6 +455,7 @@ class zerobin $page->assign('EXPIRE', $expire); $page->assign('EXPIREDEFAULT', $this->_conf->getKey('default', 'expire')); $page->assign('EXPIRECLONE', !$this->_doesExpire || ($this->_doesExpire && $this->_conf->getKey('clone', 'expire'))); + $page->assign('URLSHORTENER', $this->_conf->getKey('urlshortener')); $page->draw($this->_conf->getKey('template')); } diff --git a/tpl/bootstrap-compact.html b/tpl/bootstrap-compact.html index 503a47e..7d44543 100644 --- a/tpl/bootstrap-compact.html +++ b/tpl/bootstrap-compact.html @@ -169,7 +169,11 @@
diff --git a/tpl/bootstrap-dark-page.html b/tpl/bootstrap-dark-page.html index df17e70..34c031e 100644 --- a/tpl/bootstrap-dark-page.html +++ b/tpl/bootstrap-dark-page.html @@ -165,7 +165,11 @@
diff --git a/tpl/bootstrap-dark.html b/tpl/bootstrap-dark.html index d39f8e2..289c647 100644 --- a/tpl/bootstrap-dark.html +++ b/tpl/bootstrap-dark.html @@ -165,7 +165,11 @@
diff --git a/tpl/bootstrap-page.html b/tpl/bootstrap-page.html index f9bbcf5..4b7f928 100644 --- a/tpl/bootstrap-page.html +++ b/tpl/bootstrap-page.html @@ -165,7 +165,11 @@
diff --git a/tpl/bootstrap.html b/tpl/bootstrap.html index a56d6fe..22bafae 100644 --- a/tpl/bootstrap.html +++ b/tpl/bootstrap.html @@ -165,7 +165,11 @@
diff --git a/tpl/page.html b/tpl/page.html index b8bd5f2..01328f6 100644 --- a/tpl/page.html +++ b/tpl/page.html @@ -84,7 +84,9 @@
{if="$FILEUPLOAD"}