Allow photo posts
This commit is contained in:
@@ -21,6 +21,10 @@ module Adamantium
|
||||
end
|
||||
end
|
||||
|
||||
def photos?
|
||||
photos.count > 0
|
||||
end
|
||||
|
||||
def prefix_emoji
|
||||
name ? "📝" : "📯"
|
||||
end
|
||||
|
@@ -11,6 +11,7 @@ module Adamantium
|
||||
attribute :published_at, Types::Nominal::DateTime.optional
|
||||
attribute :post_type, Types::Coercible::String
|
||||
attribute :syndicate_to, Types::Array.of(Types::Coercible::String)
|
||||
attribute :photos, Types::Array.of(Types::Hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -10,6 +10,7 @@ module Adamantium
|
||||
attribute :published_at, Types::Nominal::DateTime.optional
|
||||
attribute :post_type, Types::Coercible::String
|
||||
attribute :syndicate_to, Types::Array.of(Types::Coercible::String)
|
||||
attribute :photos, Types::Array.of(Types::Hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,6 +2,9 @@ div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:
|
||||
h1 = post.display_title
|
||||
|
||||
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"
|
||||
- if post.photos?
|
||||
- post.photos.each do |photo|
|
||||
img src=photo["value"] alt=photo["alt"]
|
||||
== post.content
|
||||
|
||||
div class="mb-4 max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"
|
||||
|
@@ -11,6 +11,7 @@ module Adamantium
|
||||
required(:slug).filled(:string)
|
||||
required(:post_type).value(included_in?: %w[bookmark])
|
||||
required(:syndicate_to).array(:string)
|
||||
required(:photos).array(:hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -10,6 +10,7 @@ module Adamantium
|
||||
required(:slug).filled(:string)
|
||||
required(:post_type).value(included_in?: %w[post])
|
||||
required(:syndicate_to).array(:string)
|
||||
required(:photos).array(:hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
9
db/migrate/20230131084956_add_photos_to_posts.rb
Normal file
9
db/migrate/20230131084956_add_photos_to_posts.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ROM::SQL.migration do
|
||||
change do
|
||||
alter_table :posts do
|
||||
add_column :photos, :json, default: "[]", null: false
|
||||
end
|
||||
end
|
||||
end
|
@@ -61,12 +61,14 @@ module Adamantium
|
||||
new_params[:content] = params[:properties][:content]&.first&.tr("\n", " ")
|
||||
new_params[:slug] = params[:slug] || params["mp-slug"]
|
||||
new_params[:syndicate_to] = params[:properties][:"mp-syndicate-to"] || []
|
||||
new_params[:photos] = params[:properties][:photo] || []
|
||||
else
|
||||
new_params[:syndicate_to] = params[:"mp-syndicate-to"]&.split(",") || []
|
||||
new_params[:name] = params[:name]
|
||||
new_params[:slug] = params[:slug] || params["mp-slug"]
|
||||
new_params[:published_at] = (params[:"post-status"] == "draft") ? nil : publish_time
|
||||
new_params[:category] = params[:category].split(",") || []
|
||||
new_params[:photos] = params[:photo] || []
|
||||
|
||||
content = if params[:content]
|
||||
if params[:content].is_a?(Hash) && params[:content][:html]
|
||||
|
Reference in New Issue
Block a user