diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index 4db8a33e..e693a325 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -56,6 +56,10 @@ languageselection = false ; the pastes encryption key ; urlshortener = "https://shortener.example.com/api?link=" +; (optional) Let users create a QR code for sharing the paste URL with one click. +; It works both when a new paste is created and when you view a paste. +; qrcode = true + ; (optional) IP based icons are a weak mechanism to detect if a comment was from ; a different user when the same username was used in a comment. It might be ; used to get the IP of a non anonymous comment poster if the server salt is diff --git a/css/bootstrap/privatebin.css b/css/bootstrap/privatebin.css index 37404755..e0dd81f2 100644 --- a/css/bootstrap/privatebin.css +++ b/css/bootstrap/privatebin.css @@ -79,16 +79,6 @@ body.loading { margin-left: 5px; } -#qrcodelink { - color: #337ab7; - float: right; - margin-left: 5px; - cursor: pointer; -} -#qrcodelink:hover, #qrcodelink:focus { - color: #23527c; -} - #qrcodemodalClose { float: right; } diff --git a/img/icon_qr.png b/img/icon_qr.png new file mode 100644 index 00000000..9d32efbf Binary files /dev/null and b/img/icon_qr.png differ diff --git a/js/kjua.min.js b/js/kjua-0.1.2.min.js similarity index 100% rename from js/kjua.min.js rename to js/kjua-0.1.2.min.js diff --git a/js/privatebin.js b/js/privatebin.js index 5b1789e1..a8c3b618 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -1206,8 +1206,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { var $pasteSuccess, $pasteUrl, $remainingTime, - $shortenButton, - $qrCodeLink; + $shortenButton; /** * forward to URL shortener @@ -1242,23 +1241,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { } } - /** - * Shows the QR code of the current paste. - * - * @name PasteStatus.displayQrCode - * @function - * @param {Event} event - */ - function displayQrCode(event) - { - var qrCanvas = kjua({ - render: 'canvas', - text: $pasteUrl.attr('href') - }); - $('#qrcode-display').html(qrCanvas); - - } - /** * creates a notification after a successfull paste upload * @@ -1355,11 +1337,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { // $pasteUrl is saved in me.createPasteNotification() after creation $remainingTime = $('#remainingtime'); $shortenButton = $('#shortenbutton'); - $qrCodeLink = $('#qrcodelink'); // bind elements $shortenButton.click(sendToShortener); - $qrCodeLink.click(displayQrCode); } return me; @@ -2429,6 +2409,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { $password, $passwordInput, $rawTextButton, + $qrCodeLink, $sendButton; var pasteExpiration = '1week'; @@ -2606,6 +2587,22 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { event.preventDefault(); } + /** + * Shows the QR code of the current paste (URL). + * + * @name TopNav.displayQrCode + * @function + * @param {Event} event + */ + function displayQrCode(event) + { + var qrCanvas = kjua({ + render: 'canvas', + text: window.location.href + }); + $('#qrcode-display').html(qrCanvas); + } + /** * Shows all elements belonging to viwing an existing pastes * @@ -2622,6 +2619,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { $newButton.removeClass('hidden'); $cloneButton.removeClass('hidden'); $rawTextButton.removeClass('hidden'); + $qrCodeLink.removeClass('hidden'); viewButtonsDisplayed = true; } @@ -2642,6 +2640,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { $newButton.addClass('hidden'); $cloneButton.addClass('hidden'); $rawTextButton.addClass('hidden'); + $qrCodeLink.addClass('hidden'); viewButtonsDisplayed = false; } @@ -2892,6 +2891,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { $passwordInput = $('#passwordinput'); $rawTextButton = $('#rawtextbutton'); $sendButton = $('#sendbutton'); + $qrCodeLink = $('#qrcodelink'); // bootstrap template drop down $('#language ul.dropdown-menu li a').click(setLanguage); @@ -2906,6 +2906,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { $cloneButton.click(Controller.clonePaste); $rawTextButton.click(rawText); $fileRemoveButton.click(removeAttachment); + $qrCodeLink.click(displayQrCode); // bootstrap template drop downs $('ul.dropdown-menu li a', $('#expiration').parent()).click(updateExpiration); diff --git a/lib/Configuration.php b/lib/Configuration.php index 274743ed..c7c84512 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -52,6 +52,7 @@ class Configuration 'languageselection' => false, 'languagedefault' => '', 'urlshortener' => '', + 'qrcode' => true, 'icon' => 'identicon', 'cspheader' => 'default-src \'none\'; manifest-src \'self\'; connect-src *; script-src \'self\'; style-src \'self\'; font-src \'self\'; img-src \'self\' data:; referrer no-referrer; sandbox allow-same-origin allow-scripts allow-forms allow-popups', 'zerobincompatibility' => false, diff --git a/lib/PrivateBin.php b/lib/PrivateBin.php index 7b53fa1d..f26abad1 100644 --- a/lib/PrivateBin.php +++ b/lib/PrivateBin.php @@ -448,6 +448,7 @@ class PrivateBin $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->assign('QRCODE', $this->_conf->getKey('qrcode')); $page->draw($this->_conf->getKey('template')); } diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 5b7cfe16..bdcd90bb 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -43,8 +43,12 @@ endif; - + + @@ -71,7 +75,7 @@ if ($MARKDOWN): - + @@ -174,6 +178,15 @@ endif; + + +