ujh/fountainpencompanion

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

Summary

Maintainability
Test Coverage
- content_for :title, @brand.name
- content_for :head
  meta property="og:title" content=@brand.name
  meta property="og:url" content=brand_url(@brand)
  meta property="og:description" content=@description

div class='brand-description'
  div class="content"
    = Slodown::Formatter.new(@brand.description).complete.to_s.html_safe
  - if @brand.description.present?
    div class="meta-data"
      - latest_version = @brand.versions.last
      - 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", brand_history_path(@brand)
  - if user_signed_in?
    div class="buttons"
      - if @brand.description.present?
        = link_to "Edit brand description", edit_brand_path(@brand), class: 'btn btn-success'
      - else
        = link_to "Add brand description", edit_brand_path(@brand), class: 'btn btn-success'

div class="fpc-table fpc-table--full-width fpc-inks-table fpc-scroll-shadow"
  table class="table table-striped"
    caption
      = "#{@brand.name} - #{@brand.public_ink_count} inks"
    thead
      tr
        th Count
        th Brand
        th Line
        th colspan="2" Ink
        th Tags
        th
        - if user_signed_in?
          th
    tbody
      - @inks.each do |ink|
        tr
          td= ink.collected_inks_count
          td= ink.brand_name
          td= ink.line_name
          td
            div style="background-color:#{ink.color};width:45px;height:45px;"
          td= ink.ink_name
          td
            ul class="tags"
              - ink.tags.each do |tag|
                li class="tag badge text-bg-secondary"
                  a href="#{inks_path(tag: tag)}"= tag
          td= link_to "Details", brand_ink_url(@brand, ink)
          - if user_signed_in?
            td
              div class="fpc-add-ink-button" data={ "macro-cluster-id" => ink.id }