indentlabs/notebook

View on GitHub
app/views/content/show.html.erb

Summary

Maintainability
Test Coverage
<%
  page_description = "#{@content.name}, #{@content.description} — a fictional #{@content.class.name.downcase} on Notebook.ai"
  page_description ||= "#{@content.name} is a fictional #{@content.class.name.downcase} on Notebook.ai"

  set_meta_tags title:       @content.name,
                description: page_description,
                image_src:   @content.first_public_image,
                og:          { type: 'website' },
                twitter:     { card: 'photo', image: @content.first_public_image }
%>

<%= content_for :full_width_page_header do %>
  <%= render partial: 'content/display/image_card_header' %>

  <!--
  <div class="row" style="margin-top: -1px; margin-bottom: 30px;">
    <div class="col s12 <%= content.class.color %>">
      <ul class="tabs tabs-fixed-width <%= content.class.color %>">
        <li class="tab"><a href="#test1" class="white-text active"><%= @content.class.name %> details</a></li>
        <li class="tab"><a href="#test2" class="white-text">References</a></li>
        <li class="tab"><a href="#test4" class="white-text">Comments</a></li>
      </ul>
    </div>
  </div>
  -->
        
<% end %>

<div class="row flex">
  <div class="col s12 m3">
    <div class="sticky-below-navbar">
      <%=
        render partial: 'content/display/sidelinks',
          locals: {
            editing: false,
            content: @serialized_content
          }
      %>
      <%=
        render partial: 'content/display/sideactions',
          locals: {
            editing: false,
            content: @serialized_content
          }
      %>

      <!--
      Enable this after the caches have all been busted/recomputed :)
      <% if @serialized_content.cached_word_count && @serialized_content.cached_word_count > 0 %>
        <div class="grey-text center">
          <%= number_with_delimiter @serialized_content.cached_word_count %>
          <%= 'word'.pluralize(@serialized_content.cached_word_count) %>  
        </div>
      <% end %>
      -->
    </div>
  </div>

  <div class="col s12 m9">
    <div class="card">
      <div class="card-image">
        <%= render partial: 'content/display/floating_action_buttons', locals: { editing: false } %>
      </div>
    </div>
    <% @serialized_content.data[:categories].each do |serialized_category| %>
      <%=
        # Some categories get special views. This switch checks for those and falls back on
        # the regular view if it's not a special case.
        case serialized_category[:name]
          when 'gallery'
            render partial: 'content/form/images/gallery',  locals: { content: content }

          when 'contributors'
            render partial: 'content/display/contributors', locals: { content: content } if @content.is_a?(Universe)

          else
            render partial: 'content/display/category_panel',
              locals: {
                content: @serialized_content,
                category: serialized_category
              }
        end
      %>
    <% end %>

    <%# For most pages, we also want to render a bunch of other panels in case they're needed %>
    <%= render partial: 'content/panels/in_this_universe', locals: { content: content } if @content.is_a?(Universe) %>
    <%= render partial: 'content/panels/documents',        locals: { content: content } if @serialized_content.documents.any? %>
    <%= render partial: 'content/panels/shares',           locals: { content: content } if @content.content_page_shares.any? %>
    <%= render partial: 'content/panels/timelines',        locals: { content: content } if @content.timelines.any? %>
    <%= render partial: 'content/panels/collections',      locals: { content: content } if @content.page_collection_submissions.accepted.any? %>
    <%= render partial: 'content/panels/associations',     locals: { content: content } %>
  </div>
</div>

<%= render partial: 'content/display/visitor_cta', locals: { content: @serialized_content } %>
<%= render partial: 'content/share', locals: { shared_content: @content} %>