mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Add batch paste methods and fix dl link glitch
This commit is contained in:
parent
e37ed06a47
commit
9b2f9911f2
@ -228,3 +228,16 @@ class Paste(object):
|
|||||||
Delete the paste file.
|
Delete the paste file.
|
||||||
"""
|
"""
|
||||||
os.remove(self.path)
|
os.remove(self.path)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def iter_all(cls):
|
||||||
|
for p in settings.PASTE_FILES_ROOT.rglob("*"):
|
||||||
|
if p.is_file() and "counter" not in str(p):
|
||||||
|
yield Paste.load_from_file(p)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_expired(self):
|
||||||
|
try:
|
||||||
|
return self.expiration < datetime.now()
|
||||||
|
except TypeError:
|
||||||
|
return False
|
||||||
|
@ -23,7 +23,6 @@ const app = new Vue({
|
|||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
previousPastes: [],
|
previousPastes: [],
|
||||||
downloadLink: {},
|
|
||||||
displayBottomToolBar: false,
|
displayBottomToolBar: false,
|
||||||
openPreviousPastesMenu: false,
|
openPreviousPastesMenu: false,
|
||||||
readerMode: false,
|
readerMode: false,
|
||||||
@ -32,7 +31,8 @@ const app = new Vue({
|
|||||||
ownerKey: '',
|
ownerKey: '',
|
||||||
id: '',
|
id: '',
|
||||||
type: '',
|
type: '',
|
||||||
content: ''
|
content: '',
|
||||||
|
downloadLink: {},
|
||||||
},
|
},
|
||||||
newPaste: {
|
newPaste: {
|
||||||
expiration: '1_day',
|
expiration: '1_day',
|
||||||
@ -68,6 +68,10 @@ const app = new Vue({
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
// handleDownload: function () {
|
||||||
|
// this.$refs.downloadLink.dispatchEvent(new Event("click"));
|
||||||
|
// },
|
||||||
|
|
||||||
toggleReaderMode: function () {
|
toggleReaderMode: function () {
|
||||||
if (!this.readerMode) {
|
if (!this.readerMode) {
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
@ -753,7 +757,7 @@ if (content && key) {
|
|||||||
|
|
||||||
let extension = /data:image\/([^;]+);base64/.exec(content)[1];
|
let extension = /data:image\/([^;]+);base64/.exec(content)[1];
|
||||||
|
|
||||||
app.downloadLink = {
|
app.currentPaste.downloadLink = {
|
||||||
name: '0bin_' + document.location.pathname.split('/').pop() + '.' + extension,
|
name: '0bin_' + document.location.pathname.split('/').pop() + '.' + extension,
|
||||||
url: content
|
url: content
|
||||||
}
|
}
|
||||||
@ -764,7 +768,7 @@ if (content && key) {
|
|||||||
document.querySelector('#paste-content').innerText = content;
|
document.querySelector('#paste-content').innerText = content;
|
||||||
app.currentPaste.content = content
|
app.currentPaste.content = content
|
||||||
|
|
||||||
app.downloadLink = {
|
app.currentPaste.downloadLink = {
|
||||||
name: '0bin_' + document.location.pathname.split('/').pop() + ".txt",
|
name: '0bin_' + document.location.pathname.split('/').pop() + ".txt",
|
||||||
url: "data:text/html;charset=UTF-8," + content
|
url: "data:text/html;charset=UTF-8," + content
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<span class="paste-option btn-group">
|
<span class="paste-option btn-group">
|
||||||
<button class="btn btn-clone btn-secondary" @click.prevent="handleClone()">Clone</button>
|
<button class="btn btn-clone btn-secondary" @click.prevent="handleClone()">Clone</button>
|
||||||
<button class="btn btn-secondary download-link" v-if="downloadLink.url">
|
<a class="btn btn-secondary download-link" :href="currentPaste.downloadLink.url"
|
||||||
<a :href="downloadLink.url" :download="downloadLink.name">Download</a>
|
:download="currentPaste.downloadLink.name">Download</a>
|
||||||
</button>
|
|
||||||
|
|
||||||
<button class="btn btn-secondary">New Paste</button>
|
<button class="btn btn-secondary">New Paste</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -72,9 +70,8 @@
|
|||||||
<span class="paste-option btn-group">
|
<span class="paste-option btn-group">
|
||||||
<button class="btn btn-clone btn-secondary" @click.prevent="handleClone()">Clone</button>
|
<button class="btn btn-clone btn-secondary" @click.prevent="handleClone()">Clone</button>
|
||||||
|
|
||||||
<button class="btn btn-secondary download-link" v-if="downloadLink.url">
|
<a class="btn btn-secondary download-link" :href="currentPaste.downloadLink.url"
|
||||||
<a :href="downloadLink.url" :download="downloadLink.name"> Download</a>
|
:download="currentPaste.downloadLink.name"> Download</a>
|
||||||
</button>
|
|
||||||
|
|
||||||
<button class="btn btn-secondary">New Paste</button>
|
<button class="btn btn-secondary">New Paste</button>
|
||||||
</span>
|
</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user