Re-publish bookmarks

This commit is contained in:
2023-07-20 21:49:02 +10:00
parent 0c49010f0d
commit e6936755da
5 changed files with 26 additions and 5 deletions

View File

@@ -91,7 +91,7 @@ GEM
dry-core (~> 1.0)
zeitwerk (~> 2.6)
dry-cli (1.0.0)
dry-configurable (1.0.1)
dry-configurable (1.1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-core (1.0.0)
@@ -257,7 +257,7 @@ GEM
llhttp-ffi (0.4.0)
ffi-compiler (~> 1.0)
rake (~> 13.0)
lumberjack (1.2.8)
lumberjack (1.2.9)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
@@ -423,9 +423,10 @@ GEM
rubocop (~> 1.52.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.1.0)
standard-custom (1.0.1)
standard-custom (1.0.2)
lint_roller (~> 1.0)
standard-performance (1.1.1)
rubocop (~> 1.50)
standard-performance (1.1.2)
lint_roller (~> 1.1)
rubocop-performance (~> 1.18.0)
standardrb (1.0.1)

View File

@@ -86,6 +86,7 @@ module Adamantium
post "/bookmarks/clean", to: "bookmarks.clean"
post "/bookmarks/cache/:id", to: "bookmarks.cache"
post "/bookmarks/:id/archive", to: "bookmarks.archive"
post "/bookmarks/:id/publish", to: "bookmarks.publish"
get "/posts", to: "posts.index"
delete "/posts/:id", to: "posts.delete"

View File

@@ -0,0 +1,15 @@
module Admin
module Actions
module Bookmarks
class Publish < Action
include Deps["repos.bookmark_repo"]
def handle(req, res)
bookmark_id = req.params[:id]
bookmark_repo.publish(id: bookmark_id)
end
end
end
end
end

View File

@@ -27,6 +27,10 @@ module Admin
posts.where(id: id).update(published_at: nil)
end
def publish(id:)
posts.where(id: id).update(published_at: Time.now)
end
def update(id:, cached_content:)
posts.where(id: id).update(cached_content: cached_content)
end

View File

@@ -55,7 +55,7 @@ div class="max-w-prose mx-auto" x-data="{ activeTab: 0 }"
td
button class="text-red-600" hx-delete="/admin/bookmarks/#{bookmark.id}" hx-target="#bookmark-#{bookmark.id}" delete
td
button hx-post="/admin/bookmarks/#{bookmark.id}/archive" archive
button hx-post="/admin/bookmarks/#{bookmark.id}/publish" publish
div class="max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"