mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-31 11:21:06 -04:00
- Added useDraftAutosave hook to handle automatic saving of post drafts. - Enhanced PostEditor component to include a preview tab that fetches and displays rendered markdown. - Updated Post model to manage draft state and associated published_at timestamp. - Introduced card_photo association to Post for representing a primary image. - Modified post form to support draft saving and publishing actions. - Updated navigation to include links to drafts. - Added tests for draft saving, preview functionality, and card photo validation. - Created migrations for new database fields related to drafts and card photos.
93 lines
3.5 KiB
Plaintext
93 lines
3.5 KiB
Plaintext
= content_for :title, @post.subject
|
|
- content_for :opengraph do
|
|
= tag("meta", property: "og:image", content: post_image_path(@post))
|
|
= tag("meta", property: "og:image", content: avatar_uri(@post.author, 200))
|
|
= tag("meta", property: "og:description", content: og_description(@post.body))
|
|
= tag("meta", property: "og:title", content: @post.subject)
|
|
= tag("meta", property: "og:type", content: "article")
|
|
= tag("meta", property: "og:url", content: request.original_url)
|
|
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
|
|
|
|
- if @post.author && !current_member
|
|
.alert.alert-info
|
|
= link_to @post.author.login_name, member_path(@post.author)
|
|
is using
|
|
= link_to ENV["GROWSTUFF_SITE_NAME"], root_path
|
|
to discuss #{@post.subject} with a community of food gardeners worldwide.
|
|
We have advice on growing
|
|
= succeed "," do
|
|
= link_to 'hundreds of different crops', crops_url
|
|
and a community from all around the world.
|
|
|
|
= render "shared/signin_signup",
|
|
to: "or to start using #{ENV['GROWSTUFF_SITE_NAME']} to track what you're planting and harvesting"
|
|
|
|
- content_for :buttonbar do
|
|
- if @post.comments.count > 10 && can?(:create, Comment)
|
|
= link_to 'Comment', '#new-comment', class: 'btn'
|
|
|
|
- content_for :breadcrumbs do
|
|
%li.breadcrumb-item= link_to @post.author, @post.author
|
|
%li.breadcrumb-item= link_to 'posts', member_posts_path(member_slug: @post.author.slug)
|
|
%li.breadcrumb-item.active{"aria-current" => "page"}= @post.subject
|
|
|
|
.row.record-page
|
|
.col-md-8.col-12
|
|
.card.post{ id: "post-#{@post.id}" }
|
|
- if (card_photo = @post.default_photo)
|
|
.post-card-photo
|
|
= image_tag card_photo.fullsize_url, alt: card_photo.title
|
|
- if can?(:update, @post) && @post.photos.any?
|
|
- content_for :scripts do
|
|
= javascript_include_tag 'react_islands', defer: true
|
|
.post-card-photo-change
|
|
= react_component('CardPhotoDialog', card_photo_dialog_props(@post))
|
|
.card-header
|
|
%h2.display-3.float-start
|
|
= @post.subject
|
|
- if @post.draft?
|
|
%span.badge.text-bg-warning.fs-6 Draft
|
|
= render 'posts/actions', post: @post
|
|
.card-body
|
|
.post-content= render 'posts/single', post: @post
|
|
.index-cards
|
|
- @post.photos.each do |photo|
|
|
= render 'photos/thumbnail', photo: photo
|
|
|
|
.card-footer
|
|
= render 'likes/likes', object: @post
|
|
.float-end
|
|
- if can? :create, Comment
|
|
= link_to '#new-comment', class: 'btn' do
|
|
= icon 'fas', 'comment'
|
|
Comment
|
|
|
|
%section.comments
|
|
= render "comments/comments", commentable: @post
|
|
- if can? :create, Comment
|
|
= render 'comments/inline_form', commentable: @post
|
|
|
|
.col-md-4.col-12
|
|
= render @post.author
|
|
- more = @post.more_from_author
|
|
- if more.any?
|
|
%section.more-from-author
|
|
%h2= t('posts.more_from', author: @post.author)
|
|
- more.each do |other|
|
|
= link_to other, class: 'post-compact d-flex gap-2 mb-2' do
|
|
= image_tag post_thumbnail_path(other), class: 'post-compact-photo', alt: ''
|
|
%span
|
|
%strong= other.subject
|
|
%br
|
|
%small.text-muted= l(other.created_at.to_date, format: :short)
|
|
- unless @post.crops.approved.empty?
|
|
%section.crops
|
|
%h2 Crops mentioned in this post
|
|
.index-cards
|
|
- @post.crops.approved.each do |c|
|
|
= render 'crops/thumbnail', crop: c
|
|
|
|
|
|
|
|
|