diff --git a/zerobin/paste.py b/zerobin/paste.py index de9b640..bb39ef8 100644 --- a/zerobin/paste.py +++ b/zerobin/paste.py @@ -228,3 +228,16 @@ class Paste(object): Delete the paste file. """ 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 diff --git a/zerobin/static/js/behavior.js b/zerobin/static/js/behavior.js index 7d40e25..fcad76b 100644 --- a/zerobin/static/js/behavior.js +++ b/zerobin/static/js/behavior.js @@ -23,7 +23,6 @@ const app = new Vue({ el: '#app', data: { previousPastes: [], - downloadLink: {}, displayBottomToolBar: false, openPreviousPastesMenu: false, readerMode: false, @@ -32,7 +31,8 @@ const app = new Vue({ ownerKey: '', id: '', type: '', - content: '' + content: '', + downloadLink: {}, }, newPaste: { expiration: '1_day', @@ -68,6 +68,10 @@ const app = new Vue({ }, methods: { + // handleDownload: function () { + // this.$refs.downloadLink.dispatchEvent(new Event("click")); + // }, + toggleReaderMode: function () { if (!this.readerMode) { this.messages = []; @@ -753,7 +757,7 @@ if (content && key) { let extension = /data:image\/([^;]+);base64/.exec(content)[1]; - app.downloadLink = { + app.currentPaste.downloadLink = { name: '0bin_' + document.location.pathname.split('/').pop() + '.' + extension, url: content } @@ -764,7 +768,7 @@ if (content && key) { document.querySelector('#paste-content').innerText = content; app.currentPaste.content = content - app.downloadLink = { + app.currentPaste.downloadLink = { name: '0bin_' + document.location.pathname.split('/').pop() + ".txt", url: "data:text/html;charset=UTF-8," + content } diff --git a/zerobin/views/paste.tpl b/zerobin/views/paste.tpl index b879394..2076a10 100644 --- a/zerobin/views/paste.tpl +++ b/zerobin/views/paste.tpl @@ -33,10 +33,8 @@