diff --git a/Gemfile.lock b/Gemfile.lock index 51e8c19..3ae3d10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/config/routes.rb b/config/routes.rb index 25daa2d..d53e0e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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" diff --git a/slices/admin/actions/bookmarks/publish.rb b/slices/admin/actions/bookmarks/publish.rb new file mode 100644 index 0000000..658c2a9 --- /dev/null +++ b/slices/admin/actions/bookmarks/publish.rb @@ -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 diff --git a/slices/admin/repos/bookmark_repo.rb b/slices/admin/repos/bookmark_repo.rb index 099e80d..a31158b 100644 --- a/slices/admin/repos/bookmark_repo.rb +++ b/slices/admin/repos/bookmark_repo.rb @@ -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 diff --git a/slices/admin/templates/bookmarks/index.html.slim b/slices/admin/templates/bookmarks/index.html.slim index 49bb3c0..d2cdfd6 100644 --- a/slices/admin/templates/bookmarks/index.html.slim +++ b/slices/admin/templates/bookmarks/index.html.slim @@ -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"