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

@@ -4,6 +4,9 @@ div class="mb-4 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:t
h1 class="mb-0" #{trip.name}
/ p class="mt-2" class="text-gray-600 dark:text-gray-200 text-sm" (#{trip.start_date} - #{trip.end_date})
div class="mb-4 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200 bg-gray-100 p-2 rounded prose-p:mb-0 prose-ul:mt-0"
== trip.summary
div class="h-feed mb-12 max-w-prose mx-auto"
- posts.each do |post|
== render "shared/compact_post", post: post, trip: trip, first: post.id == posts.first.id, last: post.id == posts.last.id

View File

@@ -21,7 +21,8 @@ module Adamantium
config.logger.stream = "log/hanami.log"
config.shared_app_component_keys += [
"syndication.dayone"
"syndication.dayone",
"renderers.markdown"
]
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :trips do
add_column :summary, :text, default: nil
end
end
end

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|