From 2235a72d2fa0f8216a868698d31cd8774444d7a5 Mon Sep 17 00:00:00 2001 From: Shyam Sunder Date: Thu, 13 Sep 2018 15:48:13 -0400 Subject: [PATCH] server+client: added sound flag to video posts --- client/html/post_edit_sidebar.tpl | 5 +++++ client/html/post_readonly_sidebar.tpl | 3 +++ client/js/controls/post_edit_sidebar_control.js | 16 +++++++++++++--- server/szurubooru/func/posts.py | 1 + server/szurubooru/model/post.py | 1 + 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/client/html/post_edit_sidebar.tpl b/client/html/post_edit_sidebar.tpl index 4c05561..a66a375 100644 --- a/client/html/post_edit_sidebar.tpl +++ b/client/html/post_edit_sidebar.tpl @@ -50,6 +50,11 @@ name: 'loop', checked: ctx.post.flags.includes('loop'), }) %> + <%= ctx.makeCheckbox({ + text: 'Sound', + name: 'sound', + checked: ctx.post.flags.includes('sound'), + }) %> <% } %> diff --git a/client/html/post_readonly_sidebar.tpl b/client/html/post_readonly_sidebar.tpl index 54208ef..401ce20 100644 --- a/client/html/post_readonly_sidebar.tpl +++ b/client/html/post_readonly_sidebar.tpl @@ -14,6 +14,9 @@ }[ctx.post.mimeType] %> (<%- ctx.post.canvasWidth %>x<%- ctx.post.canvasHeight %>) + <% if (ctx.post.flags.includes('sound')) { %> + + <% } %>
diff --git a/client/js/controls/post_edit_sidebar_control.js b/client/js/controls/post_edit_sidebar_control.js index dd8b66d..a5af449 100644 --- a/client/js/controls/post_edit_sidebar_control.js +++ b/client/js/controls/post_edit_sidebar_control.js @@ -331,9 +331,7 @@ class PostEditSidebarControl extends events.EventTarget { .value.toLowerCase() : undefined, - flags: this._loopVideoInputNode ? - (this._loopVideoInputNode.checked ? ['loop'] : []) : - undefined, + flags: this._videoFlags, tags: this._tagInputNode ? misc.splitByWhitespace(this._tagInputNode.value) : @@ -375,6 +373,18 @@ class PostEditSidebarControl extends events.EventTarget { return this._formNode.querySelector('.flags input[name=loop]'); } + get _soundVideoInputNode() { + return this._formNode.querySelector('.flags input[name=sound]'); + } + + get _videoFlags() { + if (!this._loopVideoInputNode) return undefined; + let ret = []; + if (this._loopVideoInputNode.checked) ret.push('loop'); + if (this._soundVideoInputNode.checked) ret.push('sound'); + return ret; + } + get _relationsInputNode() { return this._formNode.querySelector('.relations input'); } diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py index 9589a30..4fcc087 100644 --- a/server/szurubooru/func/posts.py +++ b/server/szurubooru/func/posts.py @@ -81,6 +81,7 @@ TYPE_MAP = { FLAG_MAP = { model.Post.FLAG_LOOP: 'loop', + model.Post.FLAG_SOUND: 'sound', } diff --git a/server/szurubooru/model/post.py b/server/szurubooru/model/post.py index f04ffb5..d682c1b 100644 --- a/server/szurubooru/model/post.py +++ b/server/szurubooru/model/post.py @@ -154,6 +154,7 @@ class Post(Base): TYPE_FLASH = 'flash' FLAG_LOOP = 'loop' + FLAG_SOUND = 'sound' # basic meta post_id = sa.Column('id', sa.Integer, primary_key=True)