Cleaning up media page
This commit is contained in:
@@ -2,13 +2,11 @@ div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:
|
|||||||
h1 Admin // Media
|
h1 Admin // Media
|
||||||
|
|
||||||
div class="mb-4 max-w-prose mx-auto prose dark:prose-invert"
|
div class="mb-4 max-w-prose mx-auto prose dark:prose-invert"
|
||||||
form id='media_form' hx-headers='{"authorization": "Bearer #{Hanami.app.settings.shortcut_key}"}' hx-encoding='multipart/form-data' hx-target='#result' hx-swap='innerHTML' hx-post='/micropub/media'
|
form id='media_form' hx-headers='{"authorization": "Bearer #{Hanami.app.settings.shortcut_key}"}' hx-encoding='multipart/form-data' hx-post='/micropub/media'
|
||||||
fieldset class="mb-6"
|
fieldset class="mb-6"
|
||||||
input type='file' name='file'
|
input type='file' name='file'
|
||||||
fieldset
|
fieldset
|
||||||
button class="hover:text-blue-400 p-2 bg-blue-100 rounded text-blue-600 mr-4 no-underline" Upload
|
button class="hover:text-blue-400 p-2 bg-blue-100 rounded text-blue-600 mr-4 no-underline" Upload
|
||||||
progress id='progress' class="bg-blue-100 rounded" value='0' max='100'
|
|
||||||
code id="result"
|
|
||||||
- photos_buckets.each do |year, photos|
|
- photos_buckets.each do |year, photos|
|
||||||
- next unless photos.count > 0
|
- next unless photos.count > 0
|
||||||
h2 = year
|
h2 = year
|
||||||
|
@@ -3,12 +3,21 @@ module Admin
|
|||||||
module Photos
|
module Photos
|
||||||
class Index < Admin::View
|
class Index < Admin::View
|
||||||
MEDIA_DIR = "public/media/".freeze
|
MEDIA_DIR = "public/media/".freeze
|
||||||
|
IGNORE_PATHS = ["podcast_art"].freeze
|
||||||
|
|
||||||
expose :photos_buckets do
|
expose :photos_buckets do |available_paths|
|
||||||
Dir["#{MEDIA_DIR}*"].reverse.each_with_object({}) do |root, memo|
|
available_paths.each_with_object({}) do |root, memo|
|
||||||
memo[root.gsub(MEDIA_DIR, "")] = Dir["#{root}/**"]
|
memo[root.gsub(MEDIA_DIR, "")] = Dir["#{root}/**"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private_expose :available_paths do
|
||||||
|
Dir["#{MEDIA_DIR}*"]
|
||||||
|
.reverse
|
||||||
|
.reject do |path|
|
||||||
|
IGNORE_PATHS.any?{|ip| path.match(ip) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user