Commit 453c76bf

mo k <mo@mokhan.ca>
2011-06-20 03:41:38
display snippet of full description, move sign in/sign out links to top, tidy up ui.
1 parent ef79fd9
app/controllers/home_controller.rb
@@ -1,6 +1,6 @@
 class HomeController < ApplicationController
   def index
-    @creations = Creation.all.take(5).reverse
+    @creations = Creation.all.reverse.take(6)
 
     respond_to do |format|
       format.html # index.html.erb
app/controllers/profiles_controller.rb
@@ -1,4 +1,6 @@
 class ProfilesController < ApplicationController
+  before_filter :authenticate_user!, :except => [:show]
+
   def index
     @profiles = User.all
   end
app/helpers/application_helper.rb
@@ -2,6 +2,6 @@ module ApplicationHelper
   def avatar_url(user)
       default_url = "#{root_url}images/rails.png"
       gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
-      "http://gravatar.com/avatar/#{gravatar_id}.png?s=200&d=#{CGI.escape(default_url)}"
+      "http://gravatar.com/avatar/#{gravatar_id}.png?&d=#{CGI.escape(default_url)}"
   end
 end
app/models/creation.rb
@@ -9,4 +9,9 @@ class Creation < ActiveRecord::Base
     indexes :name
     indexes story
   end
+
+  def short_story
+    story.split[0...10].join(' ')
+  end
+
 end
app/views/creations/index.html.erb
@@ -8,6 +8,6 @@
     <%= image_tag creation.image_url.to_s, :width => "285px", :height => "140px", :class => "photo", :alt => creation.name %>
   </a>
   <h2><%= creation.name %></h2>
-  <p><%= creation.story %> <%= link_to 'more...', creation %></p>
+  <p><%= creation.short_story %> <%= link_to 'more...', creation %></p>
 </div>
 <% end %>
app/views/creations/mine.html.erb
@@ -12,7 +12,7 @@
       <a href="<%= url_for creation %>">
         <%= image_tag creation.image_url.to_s, :width => "285px", :height => "140px", :class => "photo" %>
       </a>
-      <p><%= creation.story %> <%= link_to 'more...', creation %></p>
+      <p><%= creation.short_story %> <%= link_to 'more...', creation %></p>
     </div>
   <% end %>
 <% end %>
app/views/creations/show.html.erb
@@ -27,16 +27,14 @@
 
 <h3> other creations by <%= @creation.user.name.to_s %> <em><%= link_to 'view more...', profile_path(@creation.user) %> </em> </h3>
 <% other_creations = @creation.user.creations.last(4) %>
-<% if other_creations.length > 0 %>
-  <% other_creations.each do |creation| %>
-    <% if creation != @creation %>
-    <div class="product_box">
-      <a href="<%= url_for creation %>">
-        <%= image_tag creation.image_url.to_s, :width => "285px", :height => "140px", :class => "photo", :alt => creation.name %>
-      </a>
-      <h2><%= @creation.name %></h2>
-      <p><%= creation.story %> <%= link_to 'more...', creation %></p>
-    </div>
-    <% end %>
+<% other_creations.each do |creation| %>
+  <% if creation != @creation %>
+  <div class="product_box">
+    <a href="<%= url_for creation %>">
+      <%= image_tag creation.image_url.to_s, :width => "285px", :height => "140px", :class => "photo", :alt => creation.name %>
+    </a>
+    <h2><%= @creation.name %></h2>
+    <p><%= creation.short_story %> <%= link_to 'more...', creation %></p>
+  </div>
   <% end %>
 <% end %>
app/views/home/index.html.erb
@@ -1,26 +1,13 @@
 <h1>Welcome to the CakeSide</h1>
 <p><em>An online community for cake artists, enthusiasists and eaters.</em></p>
-<div class="inner_right">
-  <a href="shop.html"><img src="/images/template/button_coffee.jpg" border="0" alt="Coffee" /></a> 
-  <br />
-  <br />
-  <a href="shop.html"><img src="/images/template/button_chocolate.jpg" border="0" alt="Coffee" /></a> 
-</div>
 <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec malesuada facilisis erat, id sollicitudin leo sollicitudin in. Quisque quis elit eget neque convallis imperdiet in ut odio. Nunc vel lectus turpis, nec tincidunt ipsum. Pellentesque turpis tellus, pulvinar vehicula sodales a, sollicitudin egestas mauris. </p>
-<ul class="ticklist">
-  <li>Vestibulum aliquet</li>
-  <li>Enim sit amet bibendum venenatis</li>
-  <li>Dolor risus ornare orci, ac mollis </li>
-</ul>
-<p>Eros rhoncus convallis. Aliquam condimentum rhoncus ante a elementum. Praesent massa ligula, fermentum ac aliquet eu, ultricies a elit. Aliquam tincidunt lacus in nisi volutpat eleifend. urna in vulputate porttitor, mi est placerat tellus, at sagittis risus enim sit amet sapien. </p>
 
-<br /><br /><br /><br />
-<% @creations.reverse.each_with_index do |creation, index| %>
+<% @creations.each_with_index do |creation, index| %>
   <div class="product_box">
     <h2><%= creation.name %></h2>
     <a href="<%= url_for creation %>">
       <%= image_tag creation.image_url.to_s, :width => "285px", :height => "140px", :alt => creation.name %>
     </a>
-    <p><%= creation.story %> <%= link_to 'more...', creation %></p>
+    <p><%= creation.short_story %> <%= link_to 'more...', creation %></p>
   </div>
 <% end %>
app/views/layouts/application.html.erb
@@ -18,6 +18,15 @@
 <div id="page_bg">
   <!-- start content -->
   <div id="container">
+    <div class="floatRight" style="padding-top:20px; padding-right:5px;">
+      <% if user_signed_in? %>
+        signed in as <%= link_to current_user.name, edit_user_registration_path %> |
+        <a href="<%= url_for my_creations_path %>">my creations</a> |
+        <%= link_to "sign out", destroy_user_session_path %>
+      <% else %>
+        <%= link_to "sign up", new_user_registration_path %> or <%= link_to "sign in", new_user_session_path %>
+      <% end %>
+    </div>
     <!-- start header -->
     <div id="header">
       <div id="header_logo"> <a href="/"><img src="/images/template/logo.png" alt="Logo" width="322" height="56" border="0" /></a> </div>
@@ -26,27 +35,21 @@
     <!-- end header -->
     <div id="menu_container">
       <ul id="navigation">
-        <li class="current"><%= link_to "home", home_index_path %></li>
-        <li><%= link_to "Browse", creations_path %></li>
-        <li class="last"><a href="contact.html">Contact</a></li>
+        <li><%= link_to "home", home_index_path %></li>
+        <li><%= link_to "artists", all_profiles_path %></li>
+        <li class="last"><%= link_to "Browse", creations_path %></li>
       </ul>
     </div>
     <div id="mainContent">
       <!-- start body content -->
       <div id="right_side">
-        <div id="s1" class="slide"> <img style="display: none;" src="/images/template/banner_cupcakes.jpg" alt="" width="666" height="226" /> <img style="display: none;" src="/images/template/banner_weddings.jpg" alt="" width="666" height="226" /> </div>
+        <div id="s1" class="slide"> 
+          <img style="display: none;" src="/images/template/banner_cupcakes.jpg" alt="" width="666" height="226" /> 
+          <img style="display: none;" src="/images/template/banner_weddings.jpg" alt="" width="666" height="226" />
+        </div>
         <div id="body_text">
           <!-- begin main page content -->
 
-<div class="floatRight">
-<% if user_signed_in? %>
-  signed in as <%= link_to current_user.name, edit_user_registration_path %> |
-  <a href="<%= url_for my_creations_path %>">my creations</a> |
-  <%= link_to "sign out", destroy_user_session_path %>
-<% else %>
-  <%= link_to "sign up", new_user_registration_path %> or <%= link_to "sign in", new_user_session_path %>
-<% end %>
-</div>
 
 <%= yield %>
 
@@ -90,10 +93,9 @@
     </div>
     <!-- start footer -->
     <div id="footer">
-      <div class="floatLeft">&copy; Candy Cakes</div>
+      <div class="floatLeft">&copy; 2011 CakeSide</div>
       <div class="floatRight">
-        <a href="/">Privacy Policy</a> | 
-        <a href="sitemap.php">Site Map</a>
+        <a href="/">Privacy Policy</a>
       </div>
     </div>
     <!-- end footer -->
app/views/profiles/index.html.erb
@@ -1,19 +1,19 @@
 
-<div>All <%= @profiles.length %> profiles</div>
+<h1>All <%= @profiles.length %> profiles</h1>
 
 <table class="simple-table">
   <thead>
     <tr>
+      <th></th>
       <th>name</th>
-      <th>email</th>
       <th>member since</th>
     </tr>
   </thead>
   <tbody>
   <% @profiles.each do |profile| %>
     <tr>
+      <td> <%= image_tag avatar_url(profile), :class => "photo" %> </td>
       <td><%= link_to profile.name, profile_path(profile) %></td>
-      <td><%= profile.email %></td>
       <td><%= profile.created_at %></td>
     </tr>
   <% end %>
app/views/profiles/show.html.erb
@@ -1,5 +1,5 @@
 <h1><%= @profile.name %></h1>
-<%= image_tag avatar_url(@profile), :class => "photo" %> 
+<%= image_tag avatar_url(@profile) + '&s=200', :class => "photo" %> 
 <% if @profile == current_user %>
   <a href="http://en.gravatar.com/">change your photo</a>
 <% end %>
@@ -13,7 +13,7 @@
     <%= image_tag creation.image_url.to_s, :width => "285px", :height => "140px", :class => "photo", :alt => creation.name %>
   </a>
   <h2><%= creation.name %></h2>
-  <p><%= creation.story %> <%= link_to 'more...', creation %></p>
+  <p><%= creation.short_story %> <%= link_to 'more...', creation %></p>
 </div>
 <% end %>