crispgm/holy-images

View on GitHub
app/views/image/_image.html.erb

Summary

Maintainability
Test Coverage
<% unless defined?(style) %>
  <% style = :thumbnail %>
<% end %>
<div class="section section-image" id="image-<%= image.id %>">
  <div class="section-wrap hover-effect">
    <div class="section-item">
      <div class="section-time">
        <%= format_time(image.created_at) %>
      </div>
      <div class="section-title">
        <% if defined?(nolink) && nolink == true %>
          <%= image.title %>
        <% else %>
          <%= link_to image.title, "/image/#{image.id}" %>
        <% end %>
      </div>
      <div class="section-content">
        <% if defined?(nolink) && nolink == true %>
          <figure class="<%= image.filter_name %>">
            <%= image_tag(image.img_url(style)) %>
          </figure>
        <% else %>
          <a href="<%= "/image/#{image.id}" %>">
            <figure class="<%= image.filter_name %>">
              <%= image_tag(image.img_url(style)) %>
            </figure>
          </a>
        <% end %>
      </div>
      <div class="section-action">
        <% if image.liked %>
          <%= link_to icon("heart"), "/image/like/#{image.id}", remote: true, method: :post, :id => "image-like-#{image.id}", :class => "image-like" %>
        <% else %>
          <%= link_to icon("heart-o"), "/image/like/#{image.id}", remote: true, method: :post, :id => "image-like-#{image.id}", :class => "image-like" %>
        <% end %>
        <span class="like-count" id="like-count-<%= image.id %>"><%= image.likes.count %></span>
        <%= link_to icon("comment-o"), "/image/#{image.id}#comments" %>
        <span class="comment-count" id="comment-count-<%= image.id %>"><%= image.comments.count %></span>
      </div>
      <div class="section-footer">
        <div class="section-footer-icon gravatar">
          <%= image_tag(image.user.gravatar_url) %>
        </div>
        <div class="section-footer-name">
          <%= link_to "#{image.user.name}", "/u/#{image.user.name}" %>
        </div>
      </div>
    </div>
  </div>
</div>

<% if defined?(nolink) && nolink == true %>
<% unless image.exif.blank? %>
<div class="section" id="exif-data">
  <div class="section-wrap">
    <div class="section-item">
      <div class="section-title">
        <%= t(:exif_title) %>
      </div>
      <div class="section-content">
        <table>
          <% unless image.exif[:model].blank? %>
          <tr>
            <td><%= t(:exif_model) %></td>
            <td><%= image.exif[:model] %></td>
          </tr>
          <% end %>
          <% unless image.exif[:focal_length].blank? %>
          <tr>
            <td><%= t(:exif_focal) %></td>
            <td><%= image.exif[:focal_length] %>mm</td>
          </tr>
          <% end %>
          <% unless image.exif[:aperture].blank? %>
          <tr>
            <td><%= t(:exif_aperture) %></td>
            <td><%= image.exif[:aperture] %></td>
          </tr>
          <% end %>
          <% unless image.exif[:shutter_speed].blank? %>
          <tr>
            <td><%= t(:exif_shutter) %></td>
            <td><%= image.exif[:shutter_speed] %></td>
          </tr>
          <% end %>
          <% unless image.exif[:ISO].blank? %>
          <tr>
            <td><%= t(:exif_ISO) %></td>
            <td><%= image.exif[:ISO] %></td>
          </tr>
          <% end %>
          <% unless image.exif[:software].blank? %>
          <tr>
            <td><%= t(:exif_software) %></td>
            <td><%= image.exif[:software] %></td>
          </tr>
          <% end %>
          <% unless image.exif[:resolution].blank? %>
          <tr>
            <td><%= t(:exif_resolution) %></td>
            <td><%= image.exif[:resolution] %></td>
          </tr>
          <% end %>
        </table>
      </div>
    </div>
  </div>
</div>
<% end %>
<% end %>