From 77c0dea122d837858409c811c8bf23318142cd94 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 20:14:25 +1200 Subject: [PATCH] Tidy up posts#show --- app/views/posts/show.html.haml | 82 ++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index cca0f813d..01438393c 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -18,33 +18,67 @@ = link_to 'hundreds of different crops', crops_url and a community from all around the world. - = render partial: "shared/signin_signup", - locals: { to: "or to start using #{ENV['GROWSTUFF_SITE_NAME']} to track what you're planting and harvesting" } + = render "shared/signin_signup", + to: "or to start using #{ENV['GROWSTUFF_SITE_NAME']} to track what you're planting and harvesting" -= render partial: "single", locals: { post: @post, subject: false, hide_comments: true } +.row + .col-8.col-xs-12 -- unless @post.crops.empty? - %h3 Crops mentioned in this post - - @post.crops.each do |c| - .col-md-2 - = render partial: 'crops/thumbnail', locals: { crop: c } + / Section: Blog v.4 + %section.blog-post + .card.post{ id: "post-#{@post.id}" } + .card-header + %h2.display-3= @post.subject + .card-body + %p + Posted by + - if @post.author + = link_to @post.author.login_name, member_path(@post.author) + - else + Member Deleted + - if @post.forum + in + = link_to @post.forum, @post.forum + on + = @post.created_at + - if @post.updated_at > @post.created_at + and edited at + = @post.updated_at + :growstuff_markdown + #{ strip_tags @post.body } -.col-md-11 - - if can?(:edit, @post) || can?(:destroy, @post) - .post-actions - - if can? :edit, @post - = link_to 'Edit Post', edit_post_path(@post), class: 'btn btn-default btn-xs' - - if can? :destroy, @post - = link_to 'Delete Post', @post, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn btn-default btn-xs' + .card-footer + - if can? :create, Comment + = link_to new_comment_path(post_id: @post.id), class: 'btn' do + = icon 'fas', 'comment' + Comment - - if @post.comments.count > 10 && can?(:create, Comment) - .post-actions - = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn btn-primary' + - if can?(:edit, @post) || can?(:destroy, @post) + - if can? :edit, @post + = link_to 'Edit Post', edit_post_path(@post), class: 'btn' - = render partial: "comments", locals: { post: @post } + - if can? :destroy, @post + = link_to 'Delete Post', @post, method: :delete, + data: { confirm: 'Are you sure?' }, + class: 'btn' + + - if @post.comments.count > 10 && can?(:create, Comment) + = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn' + + + .col-4.col-xs-12 + = render @post.author + + - unless @post.crops.empty? + %hr/ + .row + .col-md-12 + %h3 Crops mentioned in this post + - @post.crops.each do |c| + .col-md-6= render 'crops/thumbnail', crop: c + + + + .col-md-12 + = render "comments", post: @post - - if can? :create, Comment - .post-actions - = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn btn-primary'