Commit cf638c47

mo khan <mo@mokhan.ca>
2014-08-23 18:46:42
update tags page to match new layout.
1 parent 849fb4a
Changed files (2)
app
controllers
views
creation_tags
app/controllers/creation_tags_controller.rb
@@ -1,14 +1,12 @@
 class CreationTagsController < ApplicationController
   def index
     @tags = Creation.tag_counts_on(:tags)
-    expires_in(6.hours)
   end
 
   def show
     @tag = params[:id].downcase.gsub(/ /, '-')
     @total_tutorials = Tutorial.tagged_with(@tag).count
     @total_creations = Creation.tagged_with(@tag).count
-    @creations = Creation.includes([:user, :tags, :photos]).tagged_with([@tag]).where('photos_count > 0').page(params[:page]).per(15)
-    expires_in(6.hours)
+    @creations = Creation.includes([:user, :tags, :photos]).tagged_with([@tag]).where('photos_count > 0').page(params[:page]).per(12)
   end
 end
app/views/creation_tags/show.html.erb
@@ -1,15 +1,4 @@
 <% provide(:title, "#{@tag}") -%>
-<% content_for :javascript do -%>
-<script type="text/javascript">  
-  var ready = function(){ 
-    var container = $('#creations-div');
-    container.imagesLoaded(function(){
-      container.masonry({ itemSelector : '.span4', isResizable: true });
-    });
-  };
-  $(document).ready(ready);
-</script>
-<% end -%>
 <div class="row-fluid">
   <div class="span9">
     <h1><%= @total_creations %> creations tagged <em><%= @tag %></em></h1>
@@ -18,32 +7,26 @@
     <p class="pull-right"><%= link_to "#{@total_tutorials} tutorials", tutorial_tag_path(@tag) %> &raquo;</p>
   </div>
 </div>
-<div id="creations-div" class="row-fluid">
-  <div class="span12">
-    <ul class="thumbnails">
-    <% @creations.each do |creation| %>
-      <div class="span4">
-        <div class="thumbnail">
-          <%= link_to creation do %>
-            <%= image_tag creation.primary_image.url_for(:large) %>
-          <% end %>
-          <div class="caption">
-            <h3><%= link_to creation.name, creation %> <em><small>by <%= link_to shrink(creation.user.name, 20), profile_path(creation.user) %></small></em></h3>
-            <p>
-            <% creation.tags.each do |tag| -%>
-              <%= link_to creation_tag_path(tag.name) do %>
-                <span class="label"><%= tag.name %></span>
-              <% end %>
-            <% end -%>
-            </p>
-            <p><%= creation.story %></p>
+<div class="row-fluid">
+  <% @creations.each_slice(6).each do |batch| %>
+    <ul class='thumbnails'>
+      <% batch.each do |creation| %>
+        <li class="span2">
+          <div class="thumbnail">
+            <%= link_to creation do %>
+              <%= image_tag creation.primary_image.url_for(:thumb) %>
+            <% end %>
+            <div class="caption">
+              <h4><%= link_to shrink(creation.name, 12), creation %></h4>
+              <p><%= link_to shrink(creation.user.name, 20), profile_path(creation.user) %></p>
+              <p><small><%= time_ago_in_words(creation.created_at) %> ago.</small></p>
+            </div>
           </div>
-        </div>
-      </div>
-    <% end %>
+        </li>
+      <% end %>
     </ul>
-  </div>
+  <% end %>
 </div>
 <div class="row-fluid">
-  <div class="span12 text-center"> <%= paginate @creations %> </div>
+  <%= render "shared/paging", items: @creations %>
 </div>