diff options
| author | mo k <mo@mokhan.ca> | 2013-02-09 15:01:45 -0700 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2013-02-09 15:01:45 -0700 |
| commit | ca645e06cdb5e9f271c71ae7cce23512bc5bdc83 (patch) | |
| tree | 19c528613837a5c39c0ccf8d81f38540da2a0233 | |
| parent | 31dc2165f3e650769dd3cf586cb1235f71b8257f (diff) | |
extract the me box
| -rw-r--r-- | app/controllers/profiles_controller.rb | 5 | ||||
| -rw-r--r-- | app/views/layouts/_header.html.erb | 6 | ||||
| -rw-r--r-- | app/views/profiles/_me_box.html.erb | 32 | ||||
| -rw-r--r-- | app/views/profiles/favorites.html.erb | 14 | ||||
| -rw-r--r-- | app/views/profiles/show.html.erb | 32 | ||||
| -rw-r--r-- | app/views/registrations/edit.html.erb | 21 |
6 files changed, 47 insertions, 63 deletions
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 76b77a02..a760f50b 100644 --- a/app/controllers/profiles_controller.rb +++ b/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 diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 727148aa..629e618e 100644 --- a/app/views/layouts/_header.html.erb +++ b/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> diff --git a/app/views/profiles/_me_box.html.erb b/app/views/profiles/_me_box.html.erb new file mode 100644 index 00000000..e3a3a6d6 --- /dev/null +++ b/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 %> diff --git a/app/views/profiles/favorites.html.erb b/app/views/profiles/favorites.html.erb index 683cc8ad..b107c399 100644 --- a/app/views/profiles/favorites.html.erb +++ b/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"> diff --git a/app/views/profiles/show.html.erb b/app/views/profiles/show.html.erb index c7425f52..d5ed5eae 100644 --- a/app/views/profiles/show.html.erb +++ b/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" %> diff --git a/app/views/registrations/edit.html.erb b/app/views/registrations/edit.html.erb index ac268494..dca6eaae 100644 --- a/app/views/registrations/edit.html.erb +++ b/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"> |
