From 09c09b6310ff53b4f0c31da2878387768b2d9a66 Mon Sep 17 00:00:00 2001 From: ari melody Date: Sat, 8 Nov 2025 14:00:29 +0000 Subject: [PATCH 1/3] add set current date button to blog editor --- admin/static/edit-blog.css | 5 +++++ admin/static/edit-blog.js | 8 ++++++++ admin/templates/html/edit-blog.html | 1 + 3 files changed, 14 insertions(+) diff --git a/admin/static/edit-blog.css b/admin/static/edit-blog.css index 5e86b4b..77cfc48 100644 --- a/admin/static/edit-blog.css +++ b/admin/static/edit-blog.css @@ -32,6 +32,11 @@ input[type="text"] { margin-top: 0; } +#blogpost button#set-current-date { + margin: 0 .5em; + padding: .4em .8em; +} + #blogpost h2 { margin: 0; font-size: 2em; diff --git a/admin/static/edit-blog.js b/admin/static/edit-blog.js index 9047ee9..2c5911f 100644 --- a/admin/static/edit-blog.js +++ b/admin/static/edit-blog.js @@ -1,6 +1,7 @@ const blogID = document.getElementById("blogpost").dataset.id; const titleInput = document.getElementById("title"); const publishDateInput = document.getElementById("publish-date"); +const setCurrentDateBtn = document.getElementById("set-current-date"); const descInput = document.getElementById("description"); const mdInput = document.getElementById("markdown"); const blueskyActorInput = document.getElementById("bluesky-actor"); @@ -11,6 +12,13 @@ const visInput = document.getElementById("visibility"); const saveBtn = document.getElementById("save"); const deleteBtn = document.getElementById("delete"); +setCurrentDateBtn.addEventListener("click", () => { + let now = new Date; + now.setMinutes(now.getMinutes() - now.getTimezoneOffset()); + publishDateInput.value = now.toISOString().slice(0, 16); + saveBtn.disabled = false; +}); + saveBtn.addEventListener("click", () => { fetch("/api/v1/blog/" + blogID, { method: "PUT", diff --git a/admin/templates/html/edit-blog.html b/admin/templates/html/edit-blog.html index eba577d..4176e85 100644 --- a/admin/templates/html/edit-blog.html +++ b/admin/templates/html/edit-blog.html @@ -28,6 +28,7 @@ +