mconf/mconf-web

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

Summary

Maintainability
Test Coverage
- return if cannot?(:show, thread)

- if thread.parent
  - space = thread.parent.space
- else
  - space = thread.space

%div.thread.thread-post{class: "#{cycle("thread-even" , "thread-odd")}", id: "parent-#{thread.id}"}
  .logo-in-thread
    - if thread.author
      = link_logo_image(thread.author, size: '32', title: thread.author.name, url: user_path(thread.author), class: "logo logo-user")
    - else
      = logo_initials(:user, size: '32', class: "logo logo-user")
  .thread-content

    .thread-title
      = icon_comments t('post.home.one', space: thread.space.name)
      - if thread.author && thread.author.enabled?
        = link_to thread.author.name, user_path(thread.author), { class: "post-author" }
      - else
        %span.post-author= t('_other.user.removed')
      = t('post.posted')
      - if thread.parent
        = t('post.reply')
        = link_to first_words(thread.parent.title, 30), space_post_path(space, thread)
      - else
        = link_to first_words(thread.title, 30), space_post_path(space, thread)
      - unless thread.children.empty?
        %span
          = "(" + t('thread.comments', children: thread.children.size) + ")"
      = formatted_time_ago thread.updated_at

    .thread-description
      %p= thread.text

    %ul.thread-action-links
      - unless thread.children.empty?
        %li= link_to t('.read_more'), space_post_path(space, thread)
      - if can?(:create, thread.space.posts.build)
        %li= link_to t('reply').downcase, reply_post_space_post_path(thread.space, thread), { name: thread.id, title: t('comment.add'), class: "open-modal" }
      - if can?(:update, thread)
        %li= link_to t('edit').downcase, edit_space_post_path(thread.space, thread), { name: thread.id, title: t('edit'), class: "open-modal" }
      - if can?(:destroy, thread)
        %li= link_to t('remove').downcase, space_post_path(thread.space,thread), {method: :delete, title: t('delete.one'), data: { confirm: t('delete.confirm', element: thread.title) } }