mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Merge branch 'v2' of github.com:Tygs/0bin into v2
This commit is contained in:
commit
0c18aae662
@ -20,7 +20,7 @@ MENU = (
|
||||
|
||||
# Size limit of the paste content in bytes. Be careful, allowing a size too big can
|
||||
# slow down the user's browser
|
||||
MAX_SIZE = 1024 * 500
|
||||
MAX_SIZE = 1024 * 600
|
||||
|
||||
# Display a tiny counter for pastes created.
|
||||
DISPLAY_COUNTER = True
|
||||
@ -31,6 +31,3 @@ REFRESH_COUNTER = 60 # in seconds
|
||||
# total number of unique pastes can be calculated as 2^(6*PASTE_ID_LENGTH)
|
||||
# for PASTE_ID_LENGTH=8, for example, it's 2^(6*8) = 281 474 976 710 656
|
||||
PASTE_ID_LENGTH = 8
|
||||
|
||||
# The Bitcoin address displayed in the paste if the author didn't chose one
|
||||
DEFAULT_BTC_TIP_ADDRESS = "bc1q4x6nwp56s9enmwtsa8um0gywpxdzeyrdluga04"
|
||||
|
2
zerobin/static/css/style.min.css
vendored
2
zerobin/static/css/style.min.css
vendored
File diff suppressed because one or more lines are too long
@ -226,6 +226,45 @@ var app = new Vue({
|
||||
|
||||
},
|
||||
|
||||
compressImage: function (base64) {
|
||||
var canvas = document.createElement('canvas')
|
||||
var img = document.createElement('img')
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
img.onload = function () {
|
||||
var width = img.width;
|
||||
var height = img.height;
|
||||
var biggest = width > height ? width : height;
|
||||
var maxHeight = height;
|
||||
var maxWidth = width;
|
||||
|
||||
if (width > height) {
|
||||
if (width > maxWidth) {
|
||||
height = Math.round((height *= maxWidth / width));
|
||||
width = maxWidth;
|
||||
}
|
||||
} else {
|
||||
if (height > maxHeight) {
|
||||
width = Math.round((width *= maxHeight / height));
|
||||
height = maxHeight;
|
||||
}
|
||||
}
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(img, 0, 0, width, height);
|
||||
|
||||
resolve(canvas.toDataURL('image/jpeg', 0.7));
|
||||
}
|
||||
img.onerror = function (err) {
|
||||
reject(err);
|
||||
}
|
||||
img.src = base64;
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
On the create paste page:
|
||||
On click on the send button, compress and encrypt data before
|
||||
@ -258,7 +297,15 @@ var app = new Vue({
|
||||
|
||||
var key = zerobin.makeKey(256);
|
||||
|
||||
zerobin.encrypt(key, paste,
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
resolve(paste);
|
||||
}); // noop to avoid branching
|
||||
if (paste.indexOf('data:image') == 0) {
|
||||
promise = app.compressImage(paste);
|
||||
}
|
||||
|
||||
promise.then(function (base64) {
|
||||
zerobin.encrypt(key, base64,
|
||||
|
||||
function () {
|
||||
bar.set('Encoding to base64...', '45%')
|
||||
@ -290,8 +337,9 @@ var app = new Vue({
|
||||
form.forEach(function (node) {
|
||||
node.disabled = false;
|
||||
});
|
||||
zerobin.message('danger', ('The encrypted file was <strong class="file-size">' + readableFsize +
|
||||
'</strong>KB. You have reached the maximum size limit of ' + readableMaxsize + 'KB.'),
|
||||
|
||||
zerobin.message('danger', ('The file was <strong class="file-size">' + readableFsize +
|
||||
'</strong>KB after encryption. You have reached the maximum size limit of ' + readableMaxsize + 'KB.'),
|
||||
'Warning!', true);
|
||||
return;
|
||||
}
|
||||
@ -339,7 +387,18 @@ var app = new Vue({
|
||||
'Error');
|
||||
});
|
||||
|
||||
})
|
||||
}),
|
||||
function (err) {
|
||||
debugger;
|
||||
form.forEach(function (node) {
|
||||
node.disabled = false;
|
||||
});
|
||||
app.isLoading = false;
|
||||
zerobin.message('danger', 'Paste could not be encrypted. Aborting.',
|
||||
'Error');
|
||||
};
|
||||
|
||||
} catch (err) {
|
||||
form.forEach(function (node) {
|
||||
node.disabled = false;
|
||||
@ -878,7 +937,7 @@ if (content && key) {
|
||||
"The paste did not seem to be code, so it " +
|
||||
"was not colorized. ",
|
||||
'', false, undefined, {
|
||||
message: "Force coloration",
|
||||
message: "Click here to force coloration",
|
||||
callback: app.handleForceColoration
|
||||
});
|
||||
}
|
||||
|
2
zerobin/static/js/main.min.js
vendored
2
zerobin/static/js/main.min.js
vendored
File diff suppressed because one or more lines are too long
@ -99,8 +99,8 @@
|
||||
d="M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm0 18v-1.511h-.5v1.511h-1v-1.511h-2.484l.25-1.489h.539c.442 0 .695-.425.695-.854v-4.444c0-.416-.242-.702-.683-.702h-.817v-1.5h2.5v-1.5h1v1.5h.5v-1.5h1v1.526c2.158.073 3.012.891 3.257 1.812.29 1.09-.429 2.005-1.046 2.228.75.192 1.789.746 1.789 2.026 0 1.742-1.344 2.908-4 2.908v1.5h-1zm-.5-5.503v2.503c1.984 0 3.344-.188 3.344-1.258 0-1.148-1.469-1.245-3.344-1.245zm0-.997c1.105 0 2.789-.078 2.789-1.25 0-1-1.039-1.25-2.789-1.25v2.5z"
|
||||
fill="#eee" /></svg></span>
|
||||
<a class="btn btn-primary btc-tip-address"
|
||||
href="bitcoin:{{ paste.btc_tip_address or settings.DEFAULT_BTC_TIP_ADDRESS }}">
|
||||
{{ paste.btc_tip_address or settings.DEFAULT_BTC_TIP_ADDRESS}}
|
||||
href="bitcoin:{{ paste.btc_tip_address or 'bc1q4x6nwp56s9enmwtsa8um0gywpxdzeyrdluga04' }}">
|
||||
{{ paste.btc_tip_address or 'bc1q4x6nwp56s9enmwtsa8um0gywpxdzeyrdluga04'}}
|
||||
</a>
|
||||
<button v-if="support.clipboard" class="btn btn-secondary" @click.prevent="copyBTCAdressToClipboard()">
|
||||
{% this.btcCopied ? "copied :)" : "copy" %}
|
||||
|
Loading…
Reference in New Issue
Block a user