Growstuff/growstuff

View on GitHub
app/views/posts/show.html.haml

Summary

Maintainability
Test Coverage
= 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_path(post_id: @post.id), 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
  .col-md-8.col-12
    .card.post{ id: "post-#{@post.id}" }
      .card-header
        %h2.display-3.float-left
          = @post.subject
        = 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-right
          - if can? :create, Comment
            = link_to new_comment_path(post_id: @post.id), class: 'btn' do
              = icon 'fas', 'comment'
              Comment

    %section.comments
      = render "comments", post: @post

  .col-md-4.col-12
    = render @post.author
    - 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