anthonymidili/Bullhorn

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

Summary

Maintainability
Test Coverage
- if post.persisted?
  = turbo_frame_tag post do
    - unless post.is_repost?
      -# Handle posts and quoted reposts.
      .callout
        .post
          - if correct_user?(post.user)
            .links-end
              = link_to edit_post_path(post), title: 'Edit' do
                %i.fa-solid.fa-pen-to-square
                Edit
              = button_to post_path(post, from_show: from_show ||= nil), method: :delete,
              data: { turbo_confirm: 'Are you sure?' }, 
              class: 'delete-link', title: 'Delete' do
                %i.fa-solid.fa-trash
          = render 'users/post_user', user: post.user
          .content= post.body
          .timestamp
            Posted #{time_ago_in_words(post.created_at)} ago
          = render "posts/controls", post: post, 
          quoted_post_form: quoted_post_form ||= false
          - if post.reposting
            .mt-3= render post.reposting
    - else
      -# Handle reposts.
      %div{id: "post_#{post.id}", class: 'post'}
        - if correct_user?(post.user)
          .links-end
            = link_to edit_post_path(post), title: 'Edit' do
              %i.fa-solid.fa-pen-to-square
              Edit
        = link_to post.user, data: { turbo: false } do
          %i.fa-solid.fa-repeat.fa-lg.me-2
          = post.user.username
          reposted
        - if post.reposting
          .mt-1= render post.reposting