implemented url-shortener ajax integration
This commit is contained in:
parent
db7c7e2e16
commit
db3b44e796
@ -56,6 +56,12 @@ languageselection = false
|
|||||||
; the pastes encryption key
|
; the pastes encryption key
|
||||||
; urlshortener = "https://shortener.example.com/api?link="
|
; urlshortener = "https://shortener.example.com/api?link="
|
||||||
|
|
||||||
|
; you can set urlshortenerajax to yes if the shortener returns the url plain text
|
||||||
|
; YOU HAVE TO set Control-Allow-Origin header on the other side!
|
||||||
|
; https://enable-cors.org/server_apache.html
|
||||||
|
; https://enable-cors.org/server_nginx.html
|
||||||
|
; urlshortenerajax = "false"
|
||||||
|
|
||||||
; (optional) Let users create a QR code for sharing the paste URL with one click.
|
; (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.
|
; It works both when a new paste is created and when you view a paste.
|
||||||
; qrcode = true
|
; qrcode = true
|
||||||
|
@ -1195,8 +1195,17 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
|
|||||||
*/
|
*/
|
||||||
function sendToShortener()
|
function sendToShortener()
|
||||||
{
|
{
|
||||||
window.location.href = $shortenButton.data('shortener') +
|
var url = $shortenButton.data('shortener')+encodeURIComponent($pasteUrl.attr('href'));
|
||||||
encodeURIComponent($pasteUrl.attr('href'));
|
|
||||||
|
if($shortenButton.data('ajax'))
|
||||||
|
$.get(url, function(d) {
|
||||||
|
$pasteUrl.attr(d);
|
||||||
|
$pasteUrl.html(d);
|
||||||
|
Helper.selectText($pasteUrl[0]);
|
||||||
|
$shortenButton.remove();
|
||||||
|
})
|
||||||
|
else
|
||||||
|
window.location.href = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,6 +52,7 @@ class Configuration
|
|||||||
'languageselection' => false,
|
'languageselection' => false,
|
||||||
'languagedefault' => '',
|
'languagedefault' => '',
|
||||||
'urlshortener' => '',
|
'urlshortener' => '',
|
||||||
|
'urlshortenerajax' => '',
|
||||||
'qrcode' => true,
|
'qrcode' => true,
|
||||||
'icon' => 'identicon',
|
'icon' => 'identicon',
|
||||||
'cspheader' => 'default-src \'none\'; manifest-src \'self\'; connect-src *; script-src \'self\'; style-src \'self\'; font-src \'self\'; img-src \'self\' data:; media-src data:; object-src data:; Referrer-Policy: \'no-referrer\'; sandbox allow-same-origin allow-scripts allow-forms allow-popups',
|
'cspheader' => 'default-src \'none\'; manifest-src \'self\'; connect-src *; script-src \'self\'; style-src \'self\'; font-src \'self\'; img-src \'self\' data:; media-src data:; object-src data:; Referrer-Policy: \'no-referrer\'; sandbox allow-same-origin allow-scripts allow-forms allow-popups',
|
||||||
|
@ -447,6 +447,7 @@ class PrivateBin
|
|||||||
$page->assign('EXPIREDEFAULT', $this->_conf->getKey('default', 'expire'));
|
$page->assign('EXPIREDEFAULT', $this->_conf->getKey('default', 'expire'));
|
||||||
$page->assign('EXPIRECLONE', !$this->_doesExpire || ($this->_doesExpire && $this->_conf->getKey('clone', 'expire')));
|
$page->assign('EXPIRECLONE', !$this->_doesExpire || ($this->_doesExpire && $this->_conf->getKey('clone', 'expire')));
|
||||||
$page->assign('URLSHORTENER', $this->_conf->getKey('urlshortener'));
|
$page->assign('URLSHORTENER', $this->_conf->getKey('urlshortener'));
|
||||||
|
$page->assign('URLSHORTENERAJAX', $this->_conf->getKey('urlshortenerajax'));
|
||||||
$page->assign('QRCODE', $this->_conf->getKey('qrcode'));
|
$page->assign('QRCODE', $this->_conf->getKey('qrcode'));
|
||||||
$page->draw($this->_conf->getKey('template'));
|
$page->draw($this->_conf->getKey('template'));
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ if ($MARKDOWN):
|
|||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-5MEpLVeCKou7sL5U7X8uo5O0CG+1+aLGpN2O5Xvo9e31Ql7/7N8X03OCcwqBNEKv61IcSlxkCP9eLXZl8eMeBA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-pW9/DMkecULCxJA/5uLbi6op7C8Yl6K8YNw43o2BNyH/AxTPEZQGwX49KvNmrDoziRad+CiSAyBHjsvinuwZrw==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
@ -473,7 +473,7 @@ endif;
|
|||||||
<?php
|
<?php
|
||||||
if (strlen($URLSHORTENER)):
|
if (strlen($URLSHORTENER)):
|
||||||
?>
|
?>
|
||||||
<button id="shortenbutton" data-shortener="<?php echo htmlspecialchars($URLSHORTENER); ?>" type="button" class="btn btn-<?php echo $isDark ? 'warning' : 'primary'; ?>">
|
<button id="shortenbutton" data-shortener="<?php echo htmlspecialchars($URLSHORTENER); ?>" data-ajax="<?php echo htmlspecialchars($URLSHORTENERAJAX); ?>" type="button" class="btn btn-<?php echo $isDark ? 'warning' : 'primary'; ?>">
|
||||||
<span class="glyphicon glyphicon-send" aria-hidden="true"></span> <?php echo I18n::_('Shorten URL'), PHP_EOL; ?>
|
<span class="glyphicon glyphicon-send" aria-hidden="true"></span> <?php echo I18n::_('Shorten URL'), PHP_EOL; ?>
|
||||||
</button>
|
</button>
|
||||||
<?php
|
<?php
|
||||||
|
@ -54,7 +54,7 @@ if ($QRCODE):
|
|||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-5MEpLVeCKou7sL5U7X8uo5O0CG+1+aLGpN2O5Xvo9e31Ql7/7N8X03OCcwqBNEKv61IcSlxkCP9eLXZl8eMeBA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-pW9/DMkecULCxJA/5uLbi6op7C8Yl6K8YNw43o2BNyH/AxTPEZQGwX49KvNmrDoziRad+CiSAyBHjsvinuwZrw==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
@ -210,7 +210,7 @@ endif;
|
|||||||
<?php
|
<?php
|
||||||
if (strlen($URLSHORTENER)):
|
if (strlen($URLSHORTENER)):
|
||||||
?>
|
?>
|
||||||
<button id="shortenbutton" data-shortener="<?php echo htmlspecialchars($URLSHORTENER); ?>"><img src="img/icon_shorten.png" width="13" height="15" /><?php echo I18n::_('Shorten URL'); ?></button>
|
<button id="shortenbutton" data-shortener="<?php echo htmlspecialchars($URLSHORTENER); ?>" data-ajax="<?php echo htmlspecialchars($URLSHORTENERAJAX); ?>"><img src="img/icon_shorten.png" width="13" height="15" /><?php echo I18n::_('Shorten URL'); ?></button>
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user