From 9f569f76b1b264296d4b96f0df1198ec4d03b037 Mon Sep 17 00:00:00 2001 From: Fabricio Winter Date: Fri, 30 Dec 2022 13:07:34 -0300 Subject: [PATCH 1/5] Default upload tags --- client/css/post-upload.styl | 4 ++++ client/html/post_upload.tpl | 2 ++ client/js/views/post_upload_view.js | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/client/css/post-upload.styl b/client/css/post-upload.styl index ea79fcac..f24c3c9e 100644 --- a/client/css/post-upload.styl +++ b/client/css/post-upload.styl @@ -15,6 +15,7 @@ $cancel-button-color = tomato &.inactive .skip-duplicates &.inactive .always-upload-similar &.inactive .pause-remain-on-error + &.inactive #common-tags, &.uploading input[type=submit], &.uploading .skip-duplicates, &.uploading .always-upload-similar @@ -30,6 +31,9 @@ $cancel-button-color = tomato small font-size: 60% + label[for=common-tags] + display: none !important + input[type=submit] margin-top: 1em diff --git a/client/html/post_upload.tpl b/client/html/post_upload.tpl index 3c1b2388..54a9871d 100644 --- a/client/html/post_upload.tpl +++ b/client/html/post_upload.tpl @@ -29,6 +29,8 @@ }) %> + <%= ctx.makeTextInput({placeholder: 'Common tags', id: 'common-tags', name: 'common-tags', style: 'margin-top:1em;'}) %> + diff --git a/client/js/views/post_upload_view.js b/client/js/views/post_upload_view.js index fc98a19e..7d0f55da 100644 --- a/client/js/views/post_upload_view.js +++ b/client/js/views/post_upload_view.js @@ -8,6 +8,10 @@ const FileDropperControl = require("../controls/file_dropper_control.js"); const template = views.getTemplate("post-upload"); const rowTemplate = views.getTemplate("post-upload-row"); +const misc = require('../util/misc.js'); +const TagAutoCompleteControl = + require('../controls/tag_auto_complete_control.js'); + function _mimeTypeToPostType(mimeType) { return ( { @@ -183,6 +187,16 @@ class PostUploadView extends events.EventTarget { this._evtFormSubmit(e) ); this._formNode.classList.add("inactive"); + + if (this._commonTagsInputNode) { + this._autoCompleteControl = new TagAutoCompleteControl( + this._commonTagsInputNode, + { + confirm: tag => + this._autoCompleteControl.replaceSelectedText( + misc.escapeSearchTerm(tag.names[0]), true), + }); + } } enableForm() { @@ -305,6 +319,11 @@ class PostUploadView extends events.EventTarget { } uploadable.tags = []; + if (this._commonTagsInputNode) { + var tags = this._commonTagsInputNode.value.split(' '); + tags = tags.filter(t => t != ""); + uploadable.tags = uploadable.tags.concat(tags); + } uploadable.relations = []; for (let [i, lookalike] of uploadable.lookalikes.entries()) { let lookalikeNode = rowNode.querySelector( @@ -450,6 +469,10 @@ class PostUploadView extends events.EventTarget { get _contentInputNode() { return this._formNode.querySelector(".dropper-container"); } + + get _commonTagsInputNode() { + return this._formNode.querySelector('form [name=common-tags'); + } } module.exports = PostUploadView; From b9ddf08c6c6f1b05df0ac7919e34a663d47d9264 Mon Sep 17 00:00:00 2001 From: Fabricio Winter Date: Fri, 30 Dec 2022 13:15:25 -0300 Subject: [PATCH 2/5] Allow default anonymous uploads --- client/css/post-upload.styl | 3 +++ client/html/post_upload.tpl | 8 ++++++++ client/js/views/post_upload_view.js | 13 ++++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/client/css/post-upload.styl b/client/css/post-upload.styl index f24c3c9e..a571d348 100644 --- a/client/css/post-upload.styl +++ b/client/css/post-upload.styl @@ -53,6 +53,9 @@ $cancel-button-color = tomato .pause-remain-on-error margin-left: 1em + .upload-all-anonymous + margin-left: 1em + form>.messages margin-top: 1em diff --git a/client/html/post_upload.tpl b/client/html/post_upload.tpl index 54a9871d..de5d32ee 100644 --- a/client/html/post_upload.tpl +++ b/client/html/post_upload.tpl @@ -29,6 +29,14 @@ }) %> + + <%= ctx.makeCheckbox({ + text: 'Upload anonymously', + name: 'upload-all-anonymous', + checked: false, + }) %> + + <%= ctx.makeTextInput({placeholder: 'Common tags', id: 'common-tags', name: 'common-tags', style: 'margin-top:1em;'}) %> diff --git a/client/js/views/post_upload_view.js b/client/js/views/post_upload_view.js index 7d0f55da..6927ac30 100644 --- a/client/js/views/post_upload_view.js +++ b/client/js/views/post_upload_view.js @@ -311,12 +311,11 @@ class PostUploadView extends events.EventTarget { uploadable.safety = safetyNode.value; } - const anonymousNode = rowNode.querySelector( - ".anonymous input:checked" - ); - if (anonymousNode) { - uploadable.anonymous = true; + let anonymous = this._uploadAllAnonymous?.checked; + if (!anonymous) { + anonymous = rowNode.querySelector(".anonymous input:checked"); } + uploadable.anonymous = anonymous; uploadable.tags = []; if (this._commonTagsInputNode) { @@ -458,6 +457,10 @@ class PostUploadView extends events.EventTarget { ); } + get _uploadAllAnonymous() { + return this._hostNode.querySelector("form [name=upload-all-anonymous]"); + } + get _submitButtonNode() { return this._hostNode.querySelector("form [type=submit]"); } From 28d2de8a54978fc8b1070b538adb4dc0b5d2a6d8 Mon Sep 17 00:00:00 2001 From: Fabricio Winter Date: Fri, 30 Dec 2022 13:29:33 -0300 Subject: [PATCH 3/5] Remove nullcheck operator --- client/js/views/post_upload_view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/js/views/post_upload_view.js b/client/js/views/post_upload_view.js index 6927ac30..a1d8041a 100644 --- a/client/js/views/post_upload_view.js +++ b/client/js/views/post_upload_view.js @@ -311,7 +311,7 @@ class PostUploadView extends events.EventTarget { uploadable.safety = safetyNode.value; } - let anonymous = this._uploadAllAnonymous?.checked; + let anonymous = this._uploadAllAnonymous.checked; if (!anonymous) { anonymous = rowNode.querySelector(".anonymous input:checked"); } From 0d1fec51c54a65904c2f8747c55a20a3f00badd5 Mon Sep 17 00:00:00 2001 From: Fabricio Winter Date: Fri, 30 Dec 2022 13:47:08 -0300 Subject: [PATCH 4/5] Better layout for upload options --- client/css/post-upload.styl | 11 ++++++ client/html/post_upload.tpl | 60 +++++++++++++++-------------- client/js/views/post_upload_view.js | 2 +- 3 files changed, 43 insertions(+), 30 deletions(-) diff --git a/client/css/post-upload.styl b/client/css/post-upload.styl index a571d348..2b236b0c 100644 --- a/client/css/post-upload.styl +++ b/client/css/post-upload.styl @@ -15,11 +15,13 @@ $cancel-button-color = tomato &.inactive .skip-duplicates &.inactive .always-upload-similar &.inactive .pause-remain-on-error + &.inactive .upload-all-anonymous &.inactive #common-tags, &.uploading input[type=submit], &.uploading .skip-duplicates, &.uploading .always-upload-similar &.uploading .pause-remain-on-error + &.uploading .upload-all-anonymous &:not(.uploading) .cancel display: none @@ -59,6 +61,15 @@ $cancel-button-color = tomato form>.messages margin-top: 1em + .control-strip + display: flex + flex-direction: column + gap: 0.5em + + .control-options + display: flex + flex-direction: column + .uploadables-container list-style-type: none margin: 0 diff --git a/client/html/post_upload.tpl b/client/html/post_upload.tpl index de5d32ee..83968eb9 100644 --- a/client/html/post_upload.tpl +++ b/client/html/post_upload.tpl @@ -5,39 +5,41 @@
- - <%= ctx.makeCheckbox({ - text: 'Skip duplicate', - name: 'skip-duplicates', - checked: false, - }) %> - +
+ + <%= ctx.makeCheckbox({ + text: 'Skip duplicate', + name: 'skip-duplicates', + checked: false, + }) %> + - - <%= ctx.makeCheckbox({ - text: 'Force upload similar', - name: 'always-upload-similar', - checked: false, - }) %> - + + <%= ctx.makeCheckbox({ + text: 'Force upload similar', + name: 'always-upload-similar', + checked: false, + }) %> + - - <%= ctx.makeCheckbox({ - text: 'Pause on error', - name: 'pause-remain-on-error', - checked: true, - }) %> - + + <%= ctx.makeCheckbox({ + text: 'Pause on error', + name: 'pause-remain-on-error', + checked: true, + }) %> + - - <%= ctx.makeCheckbox({ - text: 'Upload anonymously', - name: 'upload-all-anonymous', - checked: false, - }) %> - + + <%= ctx.makeCheckbox({ + text: 'Upload anonymously', + name: 'upload-all-anonymous', + checked: false, + }) %> + +
- <%= ctx.makeTextInput({placeholder: 'Common tags', id: 'common-tags', name: 'common-tags', style: 'margin-top:1em;'}) %> + <%= ctx.makeTextInput({placeholder: 'Common tags', id: 'common-tags', name: 'common-tags'}) %>
diff --git a/client/js/views/post_upload_view.js b/client/js/views/post_upload_view.js index a1d8041a..212e1536 100644 --- a/client/js/views/post_upload_view.js +++ b/client/js/views/post_upload_view.js @@ -474,7 +474,7 @@ class PostUploadView extends events.EventTarget { } get _commonTagsInputNode() { - return this._formNode.querySelector('form [name=common-tags'); + return this._formNode.querySelector('form [name=common-tags]'); } } From da17f11e1abf8003483baf8d01de5a9b329d8806 Mon Sep 17 00:00:00 2001 From: Fabricio Winter Date: Fri, 30 Dec 2022 13:49:59 -0300 Subject: [PATCH 5/5] Fix tag name escaping on upload --- client/js/views/post_upload_view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/js/views/post_upload_view.js b/client/js/views/post_upload_view.js index 212e1536..7b0d6967 100644 --- a/client/js/views/post_upload_view.js +++ b/client/js/views/post_upload_view.js @@ -320,7 +320,7 @@ class PostUploadView extends events.EventTarget { uploadable.tags = []; if (this._commonTagsInputNode) { var tags = this._commonTagsInputNode.value.split(' '); - tags = tags.filter(t => t != ""); + tags = tags.filter(t => t != "").map(t => t.replace('\\', '')); uploadable.tags = uploadable.tags.concat(tags); } uploadable.relations = [];