lfzawacki/musical-artifacts

View on GitHub
app/views/artifacts/_artifact_list.html.haml

Summary

Maintainability
Test Coverage
- if artifacts.empty?
  .artifact-item.empty-search
    %p
      = t('.none')

      = t('.return_html', path: artifacts_path())


- artifacts.in_groups_of(per_row, false).each do |group|

  %div{class: "#{'row' if per_row > 1}"}
    - group.each do |artifact|

      - if per_row.present? && per_row > 0
        - col_class = "col-sm-#{12 / per_row}"

      .artifact-item{class: "#{cycle('dark', 'light')}-item #{col_class}"}
        - # If the artifact is new to the user, put a little ribbon on it
        = render 'artifacts/new_artifact_ribbon', artifact: artifact

        = render "artifacts/side_buttons", artifact: artifact

        .artifact-name-wrapper
          %h2.artifact-name
            = link_to artifact.name, artifact

          %span
            = render "artifacts/created_by", artifact: artifact

        .artifact-description
          -if artifact.description.present?
            = strip_tags(artifact.description_html).truncate(480)
          - else
            .no-description= t('artifacts.show.no_description')

        %p.more-info
          = link_to t('.more_info'), artifact_path(artifact)

        .artifact-tags
          = render 'artifacts/artifact_tags', artifact: artifact

        .artifact-license
          = render 'artifacts/license', artifact: artifact, small: true

        = render partial: 'artifacts/buttons', locals: { artifact: artifact }