ujh/fountainpencompanion

View on GitHub
app/views/inks/show.html.slim

Summary

Maintainability
Test Coverage
- content_for :title, "#{@ink.name}"
- content_for :head
  meta property="og:title" content=@ink.name
  meta property="og:url" content=ink_url(@ink)
  meta property="og:description" content=@description

div class='ink-description'
  div class="content"
    = Slodown::Formatter.new(@ink.description).complete.to_s.html_safe
  - if @ink.description.present?
    div class="meta-data"
      - latest_version = @ink.description_versions.first
      - user = User.find_by(id: latest_version.whodunnit)
      ' Latest edit
      = time_ago_in_words(latest_version.created_at)
      '  ago
      - if user
        ' by
        = link_to user.public_name, user_path(user)
        = patron_tiny(user)
      div= link_to "History", ink_history_path(@ink)
  - if user_signed_in?
    div class="buttons"
      - if @ink.description.present?
        = link_to "Edit ink description", edit_brand_ink_path(@ink.brand_cluster, @ink), class: 'btn btn-success'
      - else
        = link_to "Add ink description", edit_brand_ink_path(@ink.brand_cluster, @ink), class: 'btn btn-success'

div class="row fpc-ink-details"
  div class="col-sm-12 col-md-6"
    h2 class="h4" Details
    div class="fpc-table fpc-table--full-width fpc-scroll-shadow"
      table class="table"
        tbody
          tr
            td Brand
            td= link_to @ink.brand_name, brand_url(@ink.brand_cluster)
          tr
            td Line
            td= @ink.line_name
          tr
            td Name
            td= @ink.ink_name
          tr
            td Owner count
            td= @ink.public_collected_inks_count
          tr
            td Average Color
            td style="background-color:#{@ink.color};"
    - if user_signed_in?
      div class="fpc-add-ink-button" data={ "macro-cluster-id" => @ink.id, "details" => "true" }

  div class="col-sm-12 col-md-6"
    h3 class="h4" Colors for this ink
    div
      - @ink.collected_inks.pluck(:color).uniq.each do |c|
        - next if c.blank?
        div class="fpc-ink-details__color-tile" style="background-color:#{c}"
    div style="clear: both;"
    div class="fpc-ink-details__tags"
      h3 class="h5" Tags
      ul class="tags"
        - @ink.tags.each do |tag|
          li class="tag badge text-bg-secondary"
            a href="#{inks_path(tag: tag)}"= tag
    div class="fpc-ink-details__error-reporting"
      h3 class="h5" Errors
      p
        ' If there are any inks that don't belong here or if there is anything
        ' else that is wrong, feel free to report this using the button below.
        ' We will try to fix it as soon as possible.
      = link_to "Report an error",
                "mailto:clustering-error@fountainpencompanion.com?subject=#{@ink.name}"

    div class="fpc-ink-details__submit-review"
      - if user_signed_in?
        h3 class="h5" Submit a review
        = simple_form_for InkReviewSubmission.new, url: brand_ink_ink_review_submissions_path(params[:brand_id], params[:id]), remote: true do |f|
          = f.input :url, as: :string, hint: "Enter the URL of the review you would like to submit", label: false
          = f.submit "Submit a review", class: "btn btn-success mb-3"

  - if @ink.approved_ink_reviews.exists?
    h2 Reviews
    div class="fpc-ink-details__reviews"
      -@ink.approved_ink_reviews.in_groups_of(2, false) do |group|
        div class="row"
          - group.each do |ink_review|
            div class="col-sm-12 col-md-6"
              div class="fpc-ink-review row"
                div class="col-sm-12 col-md-6"
                  = link_to ink_review.title, ink_review.url
                  - if admin?
                    |  
                    = link_to "❌", admins_review_path(ink_review), method: :delete, data: { confirm: 'Reject?' }
                  div class="fpc-ink-review__source"
                    = URI(ink_review.url).host
                    - if ink_review.author
                      = " | #{ink_review.author}"
                  div class="description"= truncate(ink_review.description, length: 200)
                div class="col-sm-12 col-md-6"
                  = image_tag ink_review.image

  h2 Names for this ink

  div class="fpc-table fpc-table--full-width fpc-scroll-shadow"
    table class="table table-striped"
      thead
        tr
          th Count
          th Brand
          th Line
          th
      tbody
        - @ink.all_names.each do |ink|
          tr
            td= ink.collected_inks_count
            td= ink.brand_name
            td= ink.line_name
            td= ink.ink_name