Refactor micropub specific things out to a slice

This commit is contained in:
2023-11-15 18:55:57 +11:00
parent 730ecb9ea4
commit 5b133363b3
63 changed files with 468 additions and 174 deletions

View File

@@ -0,0 +1,29 @@
module Micropub
module Actions
module Media
class Show < Action
include Deps["settings"]
def handle(req, res)
res.body = if req.params[:q] == "source"
{
items: media_url(req.params[:file])
}.to_json
else
"Micropub media endpoint"
end
res.status = 200
end
private
def media_url(filename)
pathname = Time.now.strftime("%m-%Y")
File.join(settings.micropub_site_url, "/media/", "/#{pathname}/", filename).to_s
end
end
end
end
end