From db2531d2ac7d3b1410a52657d2353a2315cb4c2d Mon Sep 17 00:00:00 2001 From: Nick Coad Date: Wed, 4 Dec 2024 09:28:04 +1100 Subject: [PATCH] chore: wip --- client/Dockerfile | 6 +++--- client/html/post_edit_sidebar.tpl | 18 ++++++++++++++++++ client/html/post_readonly_sidebar.tpl | 1 + client/html/posts_page.tpl | 13 ++++++++++++- client/js/controllers/post_list_controller.js | 1 + .../js/controls/post_edit_sidebar_control.js | 14 +++++++++++++- client/js/models/post.js | 8 ++++++++ docker-compose.yml | 4 +++- rebuild-and-run.sh | 3 +++ server/.ash_history | 2 ++ server/szurubooru/func/posts.py | 8 ++++++++ 11 files changed, 72 insertions(+), 6 deletions(-) create mode 100755 rebuild-and-run.sh create mode 100644 server/.ash_history diff --git a/client/Dockerfile b/client/Dockerfile index ea5151fa..701e39f0 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=$BUILDPLATFORM node:lts as builder +FROM --platform=$BUILDPLATFORM node:lts AS builder WORKDIR /opt/app COPY package.json package-lock.json ./ @@ -11,7 +11,7 @@ ARG CLIENT_BUILD_ARGS="" RUN BASE_URL="__BASEURL__" node build.js --gzip ${CLIENT_BUILD_ARGS} -FROM --platform=$BUILDPLATFORM scratch as approot +FROM --platform=$BUILDPLATFORM scratch AS approot COPY docker-start.sh / @@ -22,7 +22,7 @@ WORKDIR /var/www COPY --from=builder /opt/app/public/ . -FROM nginx:alpine as release +FROM nginx:alpine AS release RUN apk --no-cache add dumb-init COPY --from=approot / / diff --git a/client/html/post_edit_sidebar.tpl b/client/html/post_edit_sidebar.tpl index 07dcf6f8..8a0fab69 100644 --- a/client/html/post_edit_sidebar.tpl +++ b/client/html/post_edit_sidebar.tpl @@ -4,6 +4,24 @@
+
+ <%= ctx.makeTextInput({ + text: 'Title', + name: 'title', + placeholder: '', + value: ctx.post.title, + }) %> +
+ +
+ <%= ctx.makeTextInput({ + text: 'Description', + name: 'description', + placeholder: '', + value: ctx.post.description, + }) %> +
+ <% if (ctx.enableSafety && ctx.canEditPostSafety) { %>
diff --git a/client/html/post_readonly_sidebar.tpl b/client/html/post_readonly_sidebar.tpl index 47094521..6dee5560 100644 --- a/client/html/post_readonly_sidebar.tpl +++ b/client/html/post_readonly_sidebar.tpl @@ -1,4 +1,5 @@
+

<%= ctx.post.title %>

diff --git a/client/html/posts_page.tpl b/client/html/posts_page.tpl index 52011ad1..be30d4f8 100644 --- a/client/html/posts_page.tpl +++ b/client/html/posts_page.tpl @@ -4,9 +4,20 @@ <% for (let post of ctx.response.results) { %>
  • ' + title='<%- post.title %> (<%- post.type %>) Tags: <%- post.tags.map(tag => '#' + tag.names[0]).join(' ') || 'none' %>' href='<%= ctx.canViewPosts ? ctx.getPostUrl(post.id, ctx.parameters) : '' %>'> <%= ctx.makeThumbnail(post.thumbnailUrl) %> + <%= post.title %> <% if (post.type == 'video' || post.type == 'flash' || post.type == 'animation') { %> diff --git a/client/js/controllers/post_list_controller.js b/client/js/controllers/post_list_controller.js index fdb7b844..5b1b0f4c 100644 --- a/client/js/controllers/post_list_controller.js +++ b/client/js/controllers/post_list_controller.js @@ -14,6 +14,7 @@ const EmptyView = require("../views/empty_view.js"); const fields = [ "id", "thumbnailUrl", + "title", "type", "safety", "score", diff --git a/client/js/controls/post_edit_sidebar_control.js b/client/js/controls/post_edit_sidebar_control.js index 3b1c16e7..67c4336d 100644 --- a/client/js/controls/post_edit_sidebar_control.js +++ b/client/js/controls/post_edit_sidebar_control.js @@ -55,7 +55,7 @@ class PostEditSidebarControl extends events.EventTarget { "post-info", "Basic info", this._hostNode.querySelectorAll( - ".safety, .relations, .flags, .post-source" + ".title, .description, .safety, .relations, .flags, .post-source" ) ); this._tagsExpander = new ExpanderControl( @@ -398,6 +398,10 @@ class PostEditSidebarControl extends events.EventTarget { detail: { post: this._post, + title: this._titleInputNode.value, + + description: this._descriptionInputNode.value, + safety: this._safetyButtonNodes.length ? Array.from(this._safetyButtonNodes) .filter((node) => node.checked)[0] @@ -481,6 +485,14 @@ class PostEditSidebarControl extends events.EventTarget { return ret; } + get _titleInputNode() { + return this._formNode.querySelector(".title input"); + } + + get _descriptionInputNode() { + return this._formNode.querySelector(".description input"); + } + get _relationsInputNode() { return this._formNode.querySelector(".relations input"); } diff --git a/client/js/models/post.js b/client/js/models/post.js index ffb81f6b..5a996491 100644 --- a/client/js/models/post.js +++ b/client/js/models/post.js @@ -162,6 +162,14 @@ class Post extends events.EventTarget { this._flags = value; } + set title(value) { + this._title = value; + } + + set description(value) { + this._description = value; + } + set safety(value) { this._safety = value; } diff --git a/docker-compose.yml b/docker-compose.yml index 8b2900b1..0d463884 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,9 @@ services: - "./server/config.yaml:/opt/app/config.yaml" client: - image: szurubooru/client:latest + # image: szurubooru/client:latest + build: + context: ./client depends_on: - server environment: diff --git a/rebuild-and-run.sh b/rebuild-and-run.sh new file mode 100755 index 00000000..2361a76b --- /dev/null +++ b/rebuild-and-run.sh @@ -0,0 +1,3 @@ +docker compose down --volumes +docker compose build client +docker compose up -d \ No newline at end of file diff --git a/server/.ash_history b/server/.ash_history new file mode 100644 index 00000000..d30fdd11 --- /dev/null +++ b/server/.ash_history @@ -0,0 +1,2 @@ +id -u +ls -ln / diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py index 064da4f3..28cb941b 100644 --- a/server/szurubooru/func/posts.py +++ b/server/szurubooru/func/posts.py @@ -169,6 +169,8 @@ class PostSerializer(serialization.BaseSerializer): "version": self.serialize_version, "creationTime": self.serialize_creation_time, "lastEditTime": self.serialize_last_edit_time, + "title": self.serialize_title, + "description": self.serialize_description, "safety": self.serialize_safety, "source": self.serialize_source, "type": self.serialize_type, @@ -213,6 +215,12 @@ class PostSerializer(serialization.BaseSerializer): def serialize_last_edit_time(self) -> Any: return self.post.last_edit_time + def serialize_title(self) -> Any: + return self.post.title + + def serialize_description(self) -> Any: + return self.post.description + def serialize_safety(self) -> Any: return SAFETY_MAP[self.post.safety]