Add Summary to trips

This commit is contained in:
2023-08-27 17:06:20 +10:00
parent ee3703853d
commit 425e93c056
7 changed files with 37 additions and 4 deletions

View File

@@ -3,13 +3,20 @@ module Admin
module Trips
class Update
include Dry::Monads[:result]
include Deps["repos.trip_repo"]
include Deps["repos.trip_repo", renderer: "renderers.markdown"]
def call(id:, trip:)
trip_repo.update(id, trip)
trip_repo.update(id, prepare(trip: trip))
Success()
end
private
def prepare(trip:)
trip[:summary] = renderer.call(content: trip[:summary])
trip
end
end
end
end

View File

@@ -7,6 +7,8 @@ div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:
a href=url
= name
button hx-post="/admin/posts/#{post.id}/syndicate/day_one" Send to Day One
// TODO: Add preview, save post, fix sending to DayOne
article class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200 prose-a:text-blue-600 prose-a:no-underline hover:prose-a:underline prose-img:rounded"
h1= post.name
textarea class="text-gray-800 w-full border-blue-200 border-2 rounded p-2" x-data="{ resize: () => { $el.style.height = '5px'; $el.style.height = $el.scrollHeight + 'px' } }" x-init="resize()" @input="resize()"

View File

@@ -13,6 +13,11 @@ div class="max-w-prose mx-auto mb-8 border-gray-400 border-b-4"
label class="text-gray-800 dark:text-gray-200 mr-2" for="subtitle" Subtitle:
input class="text-gray-800 p-1 border border-gray-400" type="text" id="subtitle" name="trip[subtitle]" value=trip.subtitle
div class="mb-4"
label class="text-gray-800 dark:text-gray-200 mr-2" for="subtitle" Summary:
textarea id="summary" name="trip[summary]" class="text-gray-800 w-full border-blue-200 border-2 rounded p-2" x-data="{ resize: () => { $el.style.height = '5px'; $el.style.height = $el.scrollHeight + 'px' } }" x-init="resize()" @input="resize()"
== trip_summary
div class="mb-4"
button class="rounded bg-blue-100 hover:bg-blue-200 text-blue-600 px-2 hover:cursor-pointer" type="submit"
= "Update"

View File

@@ -1,3 +1,5 @@
require "reverse_markdown"
module Admin
module Views
module Trips
@@ -5,7 +7,11 @@ module Admin
include Deps["repos.trip_repo", "repos.post_repo"]
expose :trip do |id:|
trip_repo.fetch(id)
trip = trip_repo.fetch(id)
end
expose :trip_summary do |trip|
ReverseMarkdown.convert(trip.summary, unknown_tags: :pass_through, github_flavored: true).to_s
end
expose :posts do |trip|