Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

login/logout popover

  • Loading branch information...
commit f20442b1bd12f797e784e7adfe8e4a9886cacfa0 1 parent b5fbf4c
Colin McCloskey authored
12 app/assets/javascripts/home.js
@@ -17,7 +17,19 @@ jQuery.fn.autoabbr = function () {
17 17 });
18 18 }
19 19
  20 +
20 21 $(function(){
  22 +
  23 + // Automatically wrap "WOSoMP" in <abbr> tags within primary content:
21 24 $("div#primary-content").autoabbr();
  25 +
  26 + // Make the account indicator menu item a popover:
  27 + $("#top-nav #link-account a").popover({placement:'bottom',trigger:'manual', content: $("#account-box-content").html() });
  28 + $("#top-nav #link-account a").click(function(e){
  29 + e.preventDefault();
  30 + $(this).popover('toggle');
  31 + return(false);
  32 + });
  33 +
22 34 });
23 35
2  app/controllers/home_controller.rb
@@ -3,7 +3,7 @@
3 3
4 4 class HomeController < ApplicationController
5 5
6   - before_filter :authenticate_user!
  6 + before_filter :authenticate_user!, :except=>[:index]
7 7
8 8 def index
9 9 flash.now[:info] = "You are wonderful and awesome!"
10 app/helpers/application_helper.rb
@@ -14,12 +14,12 @@ def login_logout_link(opts={})
14 14 logout_opts = opts.delete(:logout) || {}
15 15 login_opts = opts.delete(:login) || {}
16 16 if user_signed_in?
17   - opts = opts.merge(logout_opts).merge(:method=>:delete)
18   - link_to(raw("<i class='icon-user icon-white'></i> Logout"), destroy_user_session_path, opts)
  17 + opts = opts.merge(logout_opts).merge(:method=>:delete, :title=>"Your Account")
  18 + link_to(raw("<i class='icon-user icon-white'></i> #{current_user.name}"), destroy_user_session_path, opts)
19 19 else
20   - opts.merge!(login_opts)
21   - # link_to("Login", new_user_session_path, opts)
22   - link_to(raw("<i class='icon-user icon-white'></i> Login with Facebook"), user_omniauth_authorize_path(:facebook), opts)
  20 + opts = opts.merge(login_opts).merge(:title=>"Login")
  21 + # link_to(raw("<i class='icon-user icon-white'></i> Login with Facebook"), new_user_session_path, opts)
  22 + link_to(raw("<i class='icon-user icon-white'></i> Login or Register"), user_omniauth_authorize_path(:facebook), opts)
23 23 end
24 24 end
25 25
3  app/models/user.rb
@@ -11,6 +11,9 @@ class User < ActiveRecord::Base
11 11 # Setup accessible (or protected) attributes for your model
12 12 attr_accessible :email, :first_name, :last_name, :password, :password_confirmation, :remember_me
13 13
  14 + # Quick combined accessors:
  15 + def name; "#{first_name} #{last_name}"; end
  16 +
14 17
15 18
16 19 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
13 app/views/layouts/application.html.erb
@@ -41,7 +41,7 @@
41 41 <li id="link-about"><%=link_to raw("<i class='icon-question-sign icon-white'></i> About"), about_path%></li>
42 42 <li id="link-olympiad"><%=link_to raw("<i class='icon-fire icon-white'></i> #{next_olympiad_name}"), olympiad_path(next_olympiad) %></li>
43 43 <li id="link-history"><%=link_to raw("<i class='icon-time icon-white'></i> History"), olympiads_path%></li>
44   - <li id="link-login"><%=login_logout_link(:login=>{:id=>"facebook-login-button"})%></li>
  44 + <li id="link-account"><%=login_logout_link(:login=>{:id=>"facebook-login-button"})%></li>
45 45 </ul>
46 46 </div><!--/.nav-collapse -->
47 47 </div>
@@ -77,6 +77,17 @@
77 77 </footer>
78 78
79 79 </div> <!-- /container -->
  80 +
  81 + <div id="account-box-content">
  82 + <% if user_signed_in? %>
  83 + <p>You are super-cool. Thanks for being awesome, <%=current_user.name%></p>
  84 + <%=link_to(raw("<i class='icon-user icon-white'></i> #{current_user.name}"), destroy_user_session_path, {})-%>
  85 + <% else %>
  86 + <p>You can become cool by signing up or logging in:</p>
  87 + <%=link_to(raw("<i class='icon-user icon-white'></i> Login or Register"), user_omniauth_authorize_path(:facebook), {})%>
  88 + <% end %>
  89 + </div>
  90 +
80 91
81 92 <!-- Le javascript
82 93 ================================================== -->

0 comments on commit f20442b

Please sign in to comment.
Something went wrong with that request. Please try again.