Commit ca645e06

mo k <mo@mokhan.ca>
2013-02-09 22:01:45
extract the me box
1 parent 31dc216
app/controllers/profiles_controller.rb
@@ -6,11 +6,12 @@ class ProfilesController < ApplicationController
   end
 
   def show
-    @profile = User.find(params[:id])
-    @creations = @profile.creations.page(params[:page]).per(18)
+    @user = User.find(params[:id])
+    @creations = @user.creations.page(params[:page]).per(18)
   end
 
   def favorites
+    @user = current_user
     @favorites = current_user.favorites
     @creations = @favorites.map {|f| f.creation }
   end
app/views/layouts/_header.html.erb
@@ -41,9 +41,9 @@
           <li class="dropdown">
           <a class="dropdown-toggle" data-toggle="dropdown" href="#"><%= current_user.name %><b class="caret"></b></a>
           <ul class="dropdown-menu">
-            <li><%= link_to "Profile", profile_path(current_user) %></li>
-            <li><%= link_to "Favorites", profiles_favorites_path %></li>
-            <li><%= link_to "Settings", edit_user_registration_path %></li>
+            <li><%= link_to "My Creations", profile_path(current_user) %></li>
+            <li><%= link_to "My Favorites", profiles_favorites_path %></li>
+            <li><%= link_to "My Settings", edit_user_registration_path %></li>
             <li class="divider"></li>
             <li> <%= link_to "Sign Out", destroy_user_session_path %> </li>
           </ul>
app/views/profiles/_me_box.html.erb
@@ -0,0 +1,32 @@
+<div class="thumbnail">
+  <%= avatar_for(@user) %>
+  <div class="caption">
+    <h5><%= @user.name %></h5>
+    <hr>
+    <p><%= @user.city %></p>
+    <% unless @user.website.blank? %>
+      <p><a href="<%= @user.website %>" target="_blank">Website</a></p>
+    <% end %>
+    <% unless @user.twitter.blank? %>
+      <p><a href="https://twitter.com/<%= @user.twitter %>" target="_blank" class="twitter-follow-button" data-show-count="false">Follow @<%= @user.twitter %></a></p>
+      <script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
+    <% end %>
+    <% unless @user.facebook.blank? %>
+      <p><a  href="<%= @user.facebook %>" target="_blank"><img src="/assets/f_logo_16x16x32.png" alt="Like on Facebook"/> Like on Facebook</a></p>
+    <% end %>
+  </div>
+</div>
+<br />
+<% if user_signed_in? %>
+<div style="padding: 8px 0;" class="well">
+  <ul class="nav nav-list">
+    <li class="nav-header"><%= current_user.name %></li>
+    <li><a href="<%= url_for profile_path(current_user) %>"><i class="icon-user"></i> My Creations</a></li>
+    <li><a href="<%= url_for profiles_favorites_path -%>"><i class="icon-book"></i> My Favorites</a></li>
+    <li><a href="<%= url_for edit_user_registration_path %>"><i class="icon-cog"></i> My Settings</a></li>
+    <li class="nav-header">share</li>
+    <li><a href="<%= url_for new_creation_path %>"><i class="icon-plus"></i> Add Creation</a></li>
+    <li><a href="<%= url_for new_tutorial_path %>"><i class="icon-plus-sign"></i> Add Tutorial</a></li>
+  </ul>
+</div>
+<% end %>
app/views/profiles/favorites.html.erb
@@ -4,19 +4,7 @@
 <% end -%>
 <div class="row">
   <div class="span3">
-    <div class="thumbnail">
-      <%= avatar_for(current_user) %>
-      <div class="caption">
-        <h5><%= current_user.name %></h5>
-      </div>
-    </div>
-    <div style="padding: 8px 0;" class="well">
-      <ul class="nav nav-list">
-        <li><a href="<%= url_for profile_path(current_user) %>"><i class="icon-user"></i> Profile</a></li>
-        <li><a href="<%= url_for profiles_favorites_path -%>"><i class="icon-book"></i> Favorites</a></li>
-        <li><a href="<%= url_for edit_user_registration_path %>"><i class="icon-cog"></i> Settings</a></li>
-      </ul>
-    </div>
+    <%= render :partial => "me_box"  %>
   </div>
   <div class="span9">
     <ul class="thumbnails">
app/views/profiles/show.html.erb
@@ -1,36 +1,10 @@
-<% provide(:title, "#{@profile.name}") -%>
+<% provide(:title, "#{@user.name}") -%>
 <% content_for :page_header do -%>
-    <h1><%= @profile.name %> <small>A member since <%= @profile.created_at.to_s :foomat %>, with <%= @profile.creations.length %> creations.</small> </h1>
+  <h1><%= @user.name %> <small>A member since <%= @user.created_at.to_s :foomat %>, with <%= @user.creations.length %> creations.</small> </h1>
 <% end -%>
 <div class="row">
   <div class="span3">
-    <div class="thumbnail">
-      <%= avatar_for(@profile) %>
-      <div class="caption">
-        <h5><%= @profile.name %></h5>
-        <hr>
-        <p><%= @profile.city %></p>
-        <% unless @profile.website.blank? %>
-          <p><a  href="<%= @profile.website %>" target="_blank"><%= @profile.website %></a></p>
-        <% end %>
-        <% unless @profile.twitter.blank? %>
-          <p><a href="https://twitter.com/<%= @profile.twitter %>" target="_blank" class="twitter-follow-button" data-show-count="false">Follow @<%= @profile.twitter %></a></p>
-          <script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
-        <% end %>
-        <% unless @profile.facebook.blank? %>
-          <p><a  href="<%= @profile.facebook %>" target="_blank"><img src="/assets/f_logo_16x16x32.png" alt="Like on Facebook"/> Like on Facebook</a></p>
-        <% end %>
-      </div>
-    </div>
-    <% if user_signed_in? %>
-    <div style="padding: 8px 0;" class="well">
-      <ul class="nav nav-list">
-        <li><a href="<%= url_for profile_path(current_user) %>"><i class="icon-user"></i> My Profile</a></li>
-        <li><a href="<%= url_for profiles_favorites_path -%>"><i class="icon-book"></i> My Favorites</a></li>
-        <li><a href="<%= url_for edit_user_registration_path %>"><i class="icon-cog"></i> My Settings</a></li>
-      </ul>
-    </div>
-    <% end %>
+    <%= render "me_box" %>
   </div>
   <div class="span9">
     <%= render "shared/creation_image_gallery" %>
app/views/registrations/edit.html.erb
@@ -1,28 +1,15 @@
-<% provide(:title, "Update My Account") -%>
+<% provide(:title, "My Settings") -%>
 <% content_for :javascript do %>
 <script type="text/javascript" charset="utf-8">
 $(function(){ DeviseUsers.Edit.initialize(jQuery); });
 </script>
 <% end %>
 <% content_for :page_header do -%>
-  <h1>Settings</h1>
+  <h1>My Settings</h1>
 <% end -%>
   <div class="row">
     <div class="span3">
-      <div class="thumbnail">
-        <a href="#change-avatar-dialog" data-toggle="modal"><%= avatar_for current_user %></a>
-        <div class="caption">
-          <h5><%= current_user.name %></h5>
-          <p>last signed in: <%= current_user.last_sign_in_at.to_s :foomat %></p>
-        </div>
-      </div>
-      <div style="padding: 8px 0;" class="well">
-        <ul class="nav nav-list">
-          <li><a href="<%= url_for profile_path(current_user) %>"><i class="icon-user"></i> Profile</a></li>
-          <li><a href="<%= url_for profiles_favorites_path -%>"><i class="icon-book"></i> Favorites</a></li>
-          <li><a href="<%= url_for edit_user_registration_path %>"><i class="icon-cog"></i> Settings</a></li>
-        </ul>
-      </div>
+      <%= render "profiles/me_box" %>
     </div>
     <div class="span7">
       <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class=> "form-horizontal" }) do |f| %>
@@ -77,8 +64,10 @@ $(function(){ DeviseUsers.Edit.initialize(jQuery); });
     <div class="span2">
       <p><a id="change-avatar" class="btn btn-primary" data-toggle="modal" href="#change-avatar-dialog">Change My Picture</a></p>
       <p><a id="change-password-button" class="btn btn-primary" data-toggle="modal" href="#change-password-dialog">Change My Password</a></p>
+      <!--
       <h4>Cancel My Account</h4>
       <p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete, :class => "btn btn-danger" %></p>
+      -->
     </div>
   </div>
   <div id="change-avatar-dialog" class="modal hide fade">