From e06e9ad6fe73cf8aa8c14cfb301fecaa6947e7cc Mon Sep 17 00:00:00 2001 From: Andrei Marcu Date: Sat, 7 Mar 2020 17:52:07 -0800 Subject: [PATCH] Access key: Some cosmetic changes --- README.md | 2 +- static/css/linx.css | 19 +++++++++++++------ static/js/upload.js | 36 +++++++++++++++++++++--------------- templates/API.html | 2 +- templates/access.html | 5 +++-- templates/index.html | 28 +++++++++++++++++----------- 6 files changed, 56 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 8564e01..84da53d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You can see what it looks like using the demo: [https://demo.linx-server.net/](h - Display syntax-highlighted code with in-place editing - Documented API with keys if need to restrict uploads (can use [linx-client](https://github.com/andreimarcu/linx-client) for uploading through command-line) - Torrent download of files using web seeding -- File expiry, deletion key, and random filename options +- File expiry, deletion key, file access key, and random filename options ### Screenshots diff --git a/static/css/linx.css b/static/css/linx.css index 4d7bc7c..edb88c4 100644 --- a/static/css/linx.css +++ b/static/css/linx.css @@ -264,21 +264,28 @@ body { margin: 0; } +#access_key { + min-width: 100%; + line-height: 1.3em; +} + +#access_key input, span { + vertical-align: middle; +} + #access_key_checkbox { margin: 0; } -#access_key_checkbox:checked ~ #access_key { +#access_key_checkbox:checked ~ #access_key_input { display: inline-block; } -#access_key_checkbox:checked ~ #access_key_label { +#access_key_checkbox:checked ~ #access_key_text { display: none; } -#access_key { - line-height: 1em; - padding: 1px; - border: 3px; +#access_key_input { + padding: 0; display: none; } diff --git a/static/js/upload.js b/static/js/upload.js index fce6e77..c5ac28a 100644 --- a/static/js/upload.js +++ b/static/js/upload.js @@ -1,15 +1,15 @@ // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later Dropzone.options.dropzone = { - init: function() { + init: function () { var dzone = document.getElementById("dzone"); dzone.style.display = "block"; }, - addedfile: function(file) { + addedfile: function (file) { if (!this.options.autoProcessQueue) { var dropzone = this; var xhr = new XMLHttpRequest(); - xhr.onload = function() { + xhr.onload = function () { if (xhr.readyState !== XMLHttpRequest.DONE) { return; } @@ -39,7 +39,7 @@ Dropzone.options.dropzone = { var cancelAction = document.createElement("span"); cancelAction.className = "cancel"; cancelAction.innerHTML = "Cancel"; - cancelAction.addEventListener('click', function(ev) { + cancelAction.addEventListener('click', function (ev) { this.removeFile(file); }.bind(this)); file.cancelActionElement = cancelAction; @@ -53,19 +53,19 @@ Dropzone.options.dropzone = { document.getElementById("uploads").appendChild(upload); }, - uploadprogress: function(file, p, bytesSent) { + uploadprogress: function (file, p, bytesSent) { p = parseInt(p); file.progressElement.innerHTML = p + "%"; file.uploadElement.setAttribute("style", 'background-image: -webkit-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: -moz-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: -ms-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: -o-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%)'); }, - sending: function(file, xhr, formData) { + sending: function (file, xhr, formData) { var randomize = document.getElementById("randomize"); - if(randomize != null) { + if (randomize != null) { formData.append("randomize", randomize.checked); } formData.append("expires", document.getElementById("expires").value); }, - success: function(file, resp) { + success: function (file, resp) { file.fileActions.removeChild(file.progressElement); var fileLabelLink = document.createElement("a"); @@ -79,11 +79,11 @@ Dropzone.options.dropzone = { var deleteAction = document.createElement("span"); deleteAction.innerHTML = "Delete"; deleteAction.className = "cancel"; - deleteAction.addEventListener('click', function(ev) { + deleteAction.addEventListener('click', function (ev) { xhr = new XMLHttpRequest(); xhr.open("DELETE", resp.url, true); xhr.setRequestHeader("Linx-Delete-Key", resp.delete_key); - xhr.onreadystatechange = function(file) { + xhr.onreadystatechange = function (file) { if (xhr.readyState == 4 && xhr.status === 200) { var text = document.createTextNode("Deleted "); file.fileLabel.insertBefore(text, file.fileLabelLink); @@ -97,15 +97,15 @@ Dropzone.options.dropzone = { file.cancelActionElement = deleteAction; file.fileActions.appendChild(deleteAction); }, - canceled: function(file) { + canceled: function (file) { this.options.error(file); }, - error: function(file, resp, xhrO) { + error: function (file, resp, xhrO) { file.fileActions.removeChild(file.cancelActionElement); file.fileActions.removeChild(file.progressElement); if (file.status === "canceled") { - file.fileLabel.innerHTML = file.name + ": Canceled "; + file.fileLabel.innerHTML = file.name + ": Canceled "; } else { if (resp.error) { @@ -125,12 +125,12 @@ Dropzone.options.dropzone = { maxFilesize: Math.round(parseInt(document.getElementById("dropzone").getAttribute("data-maxsize"), 10) / 1024 / 1024), previewsContainer: "#uploads", parallelUploads: 5, - headers: {"Accept": "application/json"}, + headers: { "Accept": "application/json" }, dictDefaultMessage: "Click or Drop file(s) or Paste image", dictFallbackMessage: "" }; -document.onpaste = function(event) { +document.onpaste = function (event) { var items = (event.clipboardData || event.originalEvent.clipboardData).items; for (index in items) { var item = items[index]; @@ -140,4 +140,10 @@ document.onpaste = function(event) { } }; +document.getElementById("access_key_checkbox").onchange = function (event) { + if (event.target.checked == false) { + document.getElementById("access_key_input").value = ""; + } +}; + // @end-license diff --git a/templates/API.html b/templates/API.html index 0a395f2..11d9ab1 100644 --- a/templates/API.html +++ b/templates/API.html @@ -49,7 +49,7 @@ “direct_url”: the url to access the file directly
“filename”: the (optionally generated) filename
“delete_key”: the (optionally generated) deletion key,
- “access_key”: the (optionally generated) access key,
+ “access_key”: the (optionally supplied) access key,
“expiry”: the unix timestamp at which the file will expire (0 if never)
“size”: the size in bytes of the file
“mimetype”: the guessed mimetype of the file
diff --git a/templates/access.html b/templates/access.html index 4fd65cc..c61cf51 100644 --- a/templates/access.html +++ b/templates/access.html @@ -1,11 +1,12 @@ {% extends "base.html" %} {% block content %} -
+
- {{ filename }} is protected with password
+ {{ filename }} is protected with a password:

+

{% endblock %} diff --git a/templates/index.html b/templates/index.html index 132a488..9e73457 100644 --- a/templates/index.html +++ b/templates/index.html @@ -17,21 +17,27 @@
- + + + +
- -
- - - +
+ + +