Archive bookmarks

This commit is contained in:
2023-05-07 11:42:08 +10:00
parent 3fddc1757e
commit 2de61827a6
4 changed files with 22 additions and 0 deletions

View File

@@ -69,6 +69,7 @@ module Adamantium
get "/bookmarks", to: "bookmarks.index"
delete "/bookmarks/:id", to: "bookmarks.delete"
post "/bookmarks/cache/:id", to: "bookmarks.cache"
post "/bookmarks/:id/archive", to: "bookmarks.archive"
end
end
end

View File

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

View File

@@ -15,6 +15,10 @@ module Admin
posts.where(id: id).delete
end
def archive(id:)
posts.where(id: id).update(published_at: nil)
end
def update(id:, cached_content:)
posts.where(id: id).update(cached_content: cached_content)
end

View File

@@ -24,6 +24,7 @@ div class="max-w-prose mx-auto"
= bookmark.published_at&.strftime("%d %b %Y")
td
button hx-delete="/admin/bookmarks/#{bookmark.id}" hx-target="#bookmark-#{bookmark.id}" delete
button hx-post="/admin/bookmarks/#{bookmark.id}/archive" archive
div class="max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"