More details on posts and error reporting
This commit is contained in:
@@ -4,6 +4,7 @@ module Admin
|
||||
def list
|
||||
posts
|
||||
.where(post_type: "bookmark")
|
||||
.order(Sequel.lit("published_at desc"))
|
||||
.to_a
|
||||
end
|
||||
|
||||
|
@@ -38,6 +38,7 @@ module Admin
|
||||
def list
|
||||
posts
|
||||
.where(post_type: "post")
|
||||
.order(Sequel.lit("published_at desc"))
|
||||
.to_a
|
||||
end
|
||||
|
||||
@@ -45,6 +46,10 @@ module Admin
|
||||
posts.where(id: id).delete
|
||||
end
|
||||
|
||||
def publish(id:)
|
||||
posts.where(id: id).update(published_at: Time.now)
|
||||
end
|
||||
|
||||
def archive(id:)
|
||||
posts.where(id: id).update(published_at: nil)
|
||||
end
|
||||
|
@@ -1,17 +1,42 @@
|
||||
div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||
h1 Admin // Bookmarks
|
||||
|
||||
div class="max-w-prose mx-auto"
|
||||
|
||||
button class="rounded bg-blue-100 hover:bg-blue-200 text-blue-600 px-2 hover:cursor-pointer" hx-post="/admin/bookmarks/clean" Check for dead links
|
||||
|
||||
div class="max-w-prose mx-auto" x-data="{ activeTab: 0 }"
|
||||
- if running_jobs
|
||||
div class="text-center bg-blue-100 mb-4 p-2 rounded" Job already queued
|
||||
- else
|
||||
button class="block rounded bg-blue-100 hover:bg-blue-200 text-blue-600 mb-4 p-2 hover:cursor-pointer" hx-post="/admin/bookmarks/clean" Check for dead links
|
||||
div class="flex"
|
||||
a href="#" class="text-gray-200 cursor-pointer p-2 border-2 mr-2 rounded border-blue-400" :class="{ 'bg-blue-400 text-blue-900': activeTab === 0 }" @click="activeTab = 0" class="tab-control" Published
|
||||
a href="#" class="text-gray-200 cursor-pointer p-2 border-2 rounded border-blue-400" :class="{ 'bg-blue-400 text-blue-900': activeTab === 1 }" @click="activeTab = 1" class="tab-control" Un published
|
||||
table class="prose dark:prose-invert table-auto prose-a:text-blue-600 prose-a:no-underline"
|
||||
thead
|
||||
th Details
|
||||
th Date
|
||||
th colspan="2" Actions
|
||||
tbody
|
||||
- bookmarks.each do |bookmark|
|
||||
tbody class="{ 'active': activeTab === 0 }" x-show.transition.in.opacity.duration.600="activeTab === 0"
|
||||
- published_bookmarks.each do |bookmark|
|
||||
tr id="bookmark-#{bookmark.id}"
|
||||
td
|
||||
div
|
||||
= bookmark.name
|
||||
a class="no-underline" href=bookmark.url
|
||||
small class="text-gray-400 dark:text-gray-600" = bookmark.url
|
||||
div
|
||||
- if bookmark.cached_content
|
||||
a href="/bookmark/#{bookmark.slug}" View cached version
|
||||
span —
|
||||
button hx-post="/admin/bookmarks/cache/#{bookmark.id}" Re-cache
|
||||
- else
|
||||
button hx-post="/admin/bookmarks/cache/#{bookmark.id}" No cached content, cache now?
|
||||
td
|
||||
= bookmark.published_at&.strftime("%d %b %Y")
|
||||
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
|
||||
tbody class="{ 'active': activeTab === 1 }" x-show.transition.in.opacity.duration.600="activeTab === 1"
|
||||
- unpublished_bookmarks.each do |bookmark|
|
||||
tr id="bookmark-#{bookmark.id}"
|
||||
td
|
||||
div
|
||||
|
@@ -18,4 +18,4 @@ div class="mb-4 max-w-prose mx-auto prose dark:prose-invert"
|
||||
div class="rounded max-w-xs" x-data=""
|
||||
img class="rounded object-cover hover:opacity-80 h-48 w-48" src="/#{photo.gsub("public/", "")}"
|
||||
button class="hover:text-blue-400 p-2 bg-blue-100 rounded text-blue-600 mr-4 no-underline" @click="$clipboard('#{Hanami.app.settings.micropub_site_url}/#{photo.gsub("public/", "")}')" Copy URL
|
||||
button class="text-red-600 hover:text-red-400" Delete
|
||||
button class="text-red-600 hover:text-red-400" hx-delete="/admin/media/#{photo}" hx-target="#post-#{photo}" Delete
|
@@ -1,26 +1,43 @@
|
||||
div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||
h1 Admin // Posts
|
||||
|
||||
div class="max-w-prose mx-auto"
|
||||
table class="prose dark:prose-invert table-auto prose-a:text-blue-600 prose-a:no-underline"
|
||||
thead
|
||||
th Details
|
||||
th Date
|
||||
th colspan="2" Actions
|
||||
tbody
|
||||
- posts.each do |post|
|
||||
tr id="post-#{post.id}"
|
||||
td
|
||||
div
|
||||
= post.name
|
||||
a class="no-underline" href="/post/#{post.slug}"
|
||||
small class="text-gray-400 dark:text-gray-600" = post.slug
|
||||
td
|
||||
= post.published_at&.strftime("%d %b %Y")
|
||||
td
|
||||
button class="text-red-600" hx-delete="/admin/bookmarks/#{post.id}" hx-target="#post-#{post.id}" delete
|
||||
td
|
||||
button hx-post="/admin/bookmarks/#{post.id}/archive" unpublish
|
||||
div class="max-w-prose mx-auto" x-data="{ activeTab: 0 }"
|
||||
div class="flex"
|
||||
a href="#" class="text-gray-200 cursor-pointer p-2 border-2 mr-2 rounded border-blue-400" :class="{ 'bg-blue-400 text-blue-900': activeTab === 0 }" @click="activeTab = 0" class="tab-control" Published
|
||||
a href="#" class="text-gray-200 cursor-pointer p-2 border-2 rounded border-blue-400" :class="{ 'bg-blue-400 text-blue-900': activeTab === 1 }" @click="activeTab = 1" class="tab-control" Un published
|
||||
table class="prose dark:prose-invert table-auto prose-a:text-blue-600 prose-a:no-underline"
|
||||
thead
|
||||
th Details
|
||||
th Date
|
||||
th colspan="2" Actions
|
||||
tbody class="{ 'active': activeTab === 0 }" x-show.transition.in.opacity.duration.600="activeTab === 0"
|
||||
- published_posts.each do |post|
|
||||
tr id="post-#{post.id}"
|
||||
td
|
||||
div
|
||||
= post.name
|
||||
a class="no-underline" href="/post/#{post.slug}"
|
||||
small class="text-gray-400 dark:text-gray-600" = post.slug
|
||||
td
|
||||
= post.published_at&.strftime("%d %b %Y")
|
||||
td
|
||||
button class="text-red-600" hx-delete="/admin/posts/#{post.id}" hx-target="#post-#{post.id}" delete
|
||||
td
|
||||
button hx-post="/admin/posts/#{post.id}/archive" unpublish
|
||||
tbody class="{ 'active': activeTab === 1 }" x-show.transition.in.opacity.duration.600="activeTab === 1"
|
||||
- unpublished_posts.each do |post|
|
||||
tr id="post-#{post.id}"
|
||||
td
|
||||
div
|
||||
= post.name
|
||||
a class="no-underline" href="/post/#{post.slug}"
|
||||
small class="text-gray-400 dark:text-gray-600" = post.slug
|
||||
td
|
||||
= post.published_at&.strftime("%d %b %Y")
|
||||
td
|
||||
button class="text-red-600" hx-delete="/admin/posts/#{post.id}" hx-target="#post-#{post.id}" delete
|
||||
td
|
||||
button hx-post="/admin/posts/#{post.id}/publish" publish
|
||||
|
||||
div class="max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"
|
||||
|
||||
|
@@ -1,3 +1,5 @@
|
||||
require "que"
|
||||
|
||||
module Admin
|
||||
module Views
|
||||
module Bookmarks
|
||||
@@ -5,8 +7,21 @@ module Admin
|
||||
|
||||
include Deps["repos.bookmark_repo"]
|
||||
|
||||
expose :published_bookmarks do |bookmarks|
|
||||
bookmarks[0]
|
||||
end
|
||||
|
||||
expose :unpublished_bookmarks do |bookmarks|
|
||||
bookmarks[1]
|
||||
end
|
||||
|
||||
expose :bookmarks do
|
||||
bookmark_repo.list
|
||||
bookmark_repo.list.partition{|p| p.published_at }
|
||||
end
|
||||
|
||||
expose :running_jobs do
|
||||
Que.connection = Adamantium::Container["persistence.db"]
|
||||
Que.job_stats.any? { |job| job[:job_class] == Adamantium::Jobs::RemoveDeadBookmarks.name }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -5,8 +5,16 @@ module Admin
|
||||
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :published_posts do |posts|
|
||||
posts[0]
|
||||
end
|
||||
|
||||
expose :unpublished_posts do |posts|
|
||||
posts[1]
|
||||
end
|
||||
|
||||
expose :posts do
|
||||
post_repo.list
|
||||
post_repo.list.partition{|p| p.published_at }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user