citygate 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -2
- data/Rakefile +1 -2
- data/app/assets/javascripts/citygate/admin_users.coffee +14 -0
- data/app/assets/javascripts/citygate/application.js +1 -0
- data/app/assets/javascripts/citygate/global.coffee +14 -0
- data/app/controllers/citygate/admin/application_controller.rb +5 -0
- data/app/controllers/citygate/admin/users_controller.rb +17 -0
- data/app/controllers/citygate/application_controller.rb +24 -0
- data/app/controllers/citygate/home_controller.rb +7 -0
- data/app/controllers/{users → citygate/users}/omniauth_callbacks_controller.rb +6 -6
- data/app/controllers/citygate/users_controller.rb +7 -0
- data/app/models/citygate/ability.rb +31 -0
- data/app/models/citygate/authorization.rb +12 -0
- data/app/models/citygate/role.rb +6 -0
- data/app/models/citygate/user.rb +41 -0
- data/app/views/{admin/users/show.html.erb → citygate/admin/users/_user_show.html.erb} +0 -0
- data/app/views/citygate/admin/users/_users.html.erb +12 -0
- data/app/views/citygate/admin/users/index.html.erb +3 -0
- data/app/views/citygate/admin/users/index.js.erb +1 -0
- data/app/views/citygate/admin/users/show.html.erb +2 -0
- data/app/views/citygate/admin/users/show.js.erb +1 -0
- data/app/views/{devise → citygate/devise}/_links.erb +0 -0
- data/app/views/{devise → citygate/devise}/registrations/edit.html.haml +0 -0
- data/app/views/citygate/home/index.html.erb +6 -0
- data/app/views/{shared → citygate/shared}/_navigation.html.erb +6 -2
- data/app/views/{users → citygate/users}/show.html.erb +0 -0
- data/app/views/layouts/admin/application.html.erb +19 -0
- data/app/views/layouts/{citygate_layout.html.erb → application.html.erb} +1 -1
- data/config/initializers/devise.rb +4 -0
- data/config/routes.rb +7 -5
- data/db/migrate/20120303195052_devise_create_users.rb +3 -3
- data/db/migrate/20120303195103_add_name_to_users.rb +1 -2
- data/db/migrate/20120303195111_add_confirmable_to_users.rb +4 -5
- data/db/migrate/20120303195145_devise_invitable_add_to_users.rb +3 -3
- data/db/migrate/20120507112430_add_omniauth_to_devise.rb +3 -3
- data/db/migrate/20120523163700_create_roles.rb +10 -0
- data/db/seeds.rb +10 -3
- data/lib/app_controller_helpers.rb +1 -12
- data/lib/citygate/engine.rb +2 -2
- data/lib/citygate/version.rb +1 -1
- data/lib/citygate.rb +2 -2
- data/lib/gravatar.rb +13 -0
- metadata +85 -128
- data/app/controllers/admin/application_controller.rb +0 -3
- data/app/controllers/admin/users_controller.rb +0 -11
- data/app/controllers/application_controller.rb +0 -4
- data/app/controllers/home_controller.rb +0 -5
- data/app/controllers/users_controller.rb +0 -7
- data/app/models/authorization.rb +0 -6
- data/app/models/user.rb +0 -12
- data/app/views/admin/users/index.html.erb +0 -10
- data/app/views/home/index.html.erb +0 -8
- data/app/views/layouts/admin/application.html.haml +0 -0
- data/app/views/layouts/admin/citygate_admin_layout.html.erb +0 -32
- data/app/views/layouts/citygate.html.erb +0 -1
- data/config/initializers/devise-lol.rb +0 -4
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
-
= Citygate
|
1
|
+
= Citygate {<img src="https://secure.travis-ci.org/zamith/citygate.png" />}[http://travis-ci.org/zamith/citygate]
|
2
2
|
|
3
|
-
|
3
|
+
Citygate is a rails engine that provides your application with user authentication (on the site or through facebook or google) using Devise and fully customizable authorization using CanCan.
|
4
|
+
|
5
|
+
It also provides a customizable backend for administrating all your users, using pjax and pushState making your website as fast as responsive as you ever wanted it to be.
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
begin
|
3
3
|
require 'bundler/setup'
|
4
|
+
require 'bundler/gem_tasks'
|
4
5
|
rescue LoadError
|
5
6
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
7
|
end
|
@@ -23,8 +24,6 @@ end
|
|
23
24
|
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
25
|
load 'rails/tasks/engine.rake'
|
25
26
|
|
26
|
-
|
27
|
-
|
28
27
|
Bundler::GemHelper.install_tasks
|
29
28
|
|
30
29
|
require 'rake/testtask'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$ ->
|
2
|
+
# Every link that is click in the users area must push the state for the previous location and update the URL,
|
3
|
+
# since everything is AJAXified
|
4
|
+
$("#users a").live "click", ->
|
5
|
+
# Push the state before the click (when it's the first page load it starts the stack)
|
6
|
+
history.pushState buildState(), "", window.location.href
|
7
|
+
|
8
|
+
# Gets the content for the container through AJAX
|
9
|
+
$.getScript @href, =>
|
10
|
+
# If the last url to be pushed to the history is different the one we're at, then push the new state
|
11
|
+
history.replaceState buildState(), "", @href if history.state.page isnt @href
|
12
|
+
|
13
|
+
# Prevent the page refresh
|
14
|
+
false
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$ ->
|
2
|
+
# Is triggered every time the user clicks the browser's back button or at page load (except for firefox)
|
3
|
+
window.onpopstate = (event) ->
|
4
|
+
# If there is a state on the stack use to populate the container
|
5
|
+
$(event.state.holder).html(event.state.html) if event.state?
|
6
|
+
|
7
|
+
# Helper to build the state JSON object
|
8
|
+
buildState = ->
|
9
|
+
{
|
10
|
+
html: $("#container").html(),
|
11
|
+
holder: "#container",
|
12
|
+
page: window.location.href
|
13
|
+
}
|
14
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Citygate::Admin::UsersController < Citygate::Admin::ApplicationController
|
2
|
+
load_and_authorize_resource :class => "Citygate::User"
|
3
|
+
respond_to :html, :json, :js
|
4
|
+
|
5
|
+
def index
|
6
|
+
@users = Citygate::User.paginate(per_page: 1, page: params[:page])
|
7
|
+
|
8
|
+
respond_with @users
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
@user = Citygate::User.find(params[:id])
|
13
|
+
|
14
|
+
respond_with @user
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# You can change the way CanCan handles an access denied to the user
|
2
|
+
# by writing a rescue_from method in your application_controller.rb
|
3
|
+
# @example CanCan::AccessDenied handling
|
4
|
+
# rescue_from CanCan::AccessDenied do |exception|
|
5
|
+
# redirect_to my_custom_path, :alert => exception.message
|
6
|
+
# end
|
7
|
+
class Citygate::ApplicationController < ::ApplicationController
|
8
|
+
protect_from_forgery
|
9
|
+
|
10
|
+
rescue_from CanCan::AccessDenied do |exception|
|
11
|
+
redirect_to root_url, :alert => exception.message
|
12
|
+
end unless ::ApplicationController.rescue_handlers.assoc "CanCan::AccessDenied"
|
13
|
+
|
14
|
+
# Gets or creates an Ability instance for usage with CanCan
|
15
|
+
def current_ability
|
16
|
+
@current_ability ||= Citygate::Ability.new(current_user)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Change Devise's redirect after sign in url
|
20
|
+
# @param [Object] resource_or_scope Not used here
|
21
|
+
def stored_location_for(resource_or_scope)
|
22
|
+
root_url
|
23
|
+
end
|
24
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
1
|
+
class Citygate::Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
2
|
|
3
3
|
def facebook
|
4
4
|
oauthorize "Facebook"
|
@@ -77,27 +77,27 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
77
77
|
|
78
78
|
def find_for_oauth_by_uid(uid, resource=nil)
|
79
79
|
user = nil
|
80
|
-
if auth = Authorization.find_by_uid(uid.to_s)
|
80
|
+
if auth = Citygate::Authorization.find_by_uid(uid.to_s)
|
81
81
|
user = auth.user
|
82
82
|
end
|
83
83
|
return user
|
84
84
|
end
|
85
85
|
|
86
86
|
def find_for_oauth_by_email(email, resource=nil)
|
87
|
-
if user = User.find_by_email(email)
|
87
|
+
if user = Citygate::User.find_by_email(email)
|
88
88
|
user
|
89
89
|
else
|
90
|
-
user = User.new(:email => email, :password => Devise.friendly_token[0,20])
|
90
|
+
user = Citygate::User.new(:email => email, :password => Devise.friendly_token[0,20])
|
91
91
|
user.save
|
92
92
|
end
|
93
93
|
return user
|
94
94
|
end
|
95
95
|
|
96
96
|
def find_for_oauth_by_name(name, resource=nil)
|
97
|
-
if user = User.find_by_name(name)
|
97
|
+
if user = Citygate::User.find_by_name(name)
|
98
98
|
user
|
99
99
|
else
|
100
|
-
user = User.new(:name => name, :password => Devise.friendly_token[0,20], :email => "#{UUIDTools::UUID.random_create}@host")
|
100
|
+
user = Citygate::User.new(:name => name, :password => Devise.friendly_token[0,20], :email => "#{UUIDTools::UUID.random_create}@host")
|
101
101
|
user.save false
|
102
102
|
end
|
103
103
|
return user
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Citygate
|
2
|
+
# @author Zamith
|
3
|
+
class Ability
|
4
|
+
include CanCan::Ability
|
5
|
+
|
6
|
+
# Defines the permissions for a user wich is not logged in or if it is,
|
7
|
+
# calls the corresponding method to its role
|
8
|
+
# @param [Citygate::User] user the current user
|
9
|
+
def initialize(user)
|
10
|
+
@user = user || User.new # guest user (not logged in)
|
11
|
+
|
12
|
+
can :index, :home
|
13
|
+
|
14
|
+
if @user.role
|
15
|
+
send(@user.role.name.downcase)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Defines the permissions on a user with the role of member
|
20
|
+
def member
|
21
|
+
can :read, Citygate::User
|
22
|
+
end
|
23
|
+
|
24
|
+
# Defines the permissions on a user with the role of admin, which inherits from member
|
25
|
+
def admin
|
26
|
+
member
|
27
|
+
can :manage, :all
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Citygate
|
2
|
+
# @author Zamith
|
3
|
+
# Holds the authorizations given by the users to get information
|
4
|
+
# from their facebook and/or google accounts
|
5
|
+
class Authorization < ActiveRecord::Base
|
6
|
+
|
7
|
+
belongs_to :user
|
8
|
+
|
9
|
+
# @!visibility public
|
10
|
+
attr_accessible :provider, :uid, :user_id, :token, :secret, :name, :link, :image_url
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Citygate
|
2
|
+
|
3
|
+
# @author Zamith
|
4
|
+
# @!attribute name
|
5
|
+
# @return [String] the name of the user
|
6
|
+
# @!attribute email
|
7
|
+
# @return [String] the email of the user
|
8
|
+
class User < ActiveRecord::Base
|
9
|
+
include Gravatar
|
10
|
+
|
11
|
+
# @!group Devise configurations
|
12
|
+
devise :database_authenticatable, :registerable, :encryptable,
|
13
|
+
:recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable
|
14
|
+
|
15
|
+
devise :encryptor => :sha1
|
16
|
+
# @!endgroup
|
17
|
+
|
18
|
+
attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :confirmed_at
|
19
|
+
|
20
|
+
has_many :authorizations, :dependent => :destroy
|
21
|
+
belongs_to :role
|
22
|
+
|
23
|
+
# Get the json object for an user
|
24
|
+
# @example
|
25
|
+
# {
|
26
|
+
# "email": "user@example.com",
|
27
|
+
# "name": "First User",
|
28
|
+
# "link": null,
|
29
|
+
# "image": "https://secure.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af.png/rating=g"
|
30
|
+
# }
|
31
|
+
def as_json(options = {})
|
32
|
+
authorization = self.authorizations.first
|
33
|
+
{
|
34
|
+
email: email,
|
35
|
+
name: name || (authorization.name if authorization),
|
36
|
+
link: (authorization.link if authorization),
|
37
|
+
image: (authorization.image_url if authorization) || self.gravatar_url
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<% @users.each do |user| %>
|
2
|
+
<div class="user">
|
3
|
+
<span class="email"><%= user.email %></span>
|
4
|
+
<%= content_tag(:span, user.name) if user.name %>
|
5
|
+
<div class="user-links">
|
6
|
+
<%= link_to "Show", admin_user_path(user), :class => "show-link" %>
|
7
|
+
<%= link_to "Edit", edit_admin_user_path(user), :class => "edit-link" if can? :update, user %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= will_paginate @users %>
|
@@ -0,0 +1 @@
|
|
1
|
+
$("#users").html("<%= escape_javascript(render("users")) %>");
|
@@ -0,0 +1 @@
|
|
1
|
+
$("#container").html("<%= escape_javascript(render("user_show")) %>");
|
File without changes
|
File without changes
|
@@ -8,8 +8,12 @@
|
|
8
8
|
|
9
9
|
<li><%= link_to('Sign up', new_user_registration_path) %></li>
|
10
10
|
|
11
|
-
<% User.omniauth_providers.each do |provider| %>
|
12
|
-
<li><%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(User.new, provider) %></li>
|
11
|
+
<% Citygate::User.omniauth_providers.each do |provider| %>
|
12
|
+
<li><%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(Citygate::User.new, provider) %></li>
|
13
13
|
<% end -%>
|
14
14
|
<% end %>
|
15
|
+
|
16
|
+
<% if can?(:read, Citygate::User) && !params[:controller]["admin"] %>
|
17
|
+
<li><%= link_to("Admin", admin_users_path) %></li>
|
18
|
+
<% end %>
|
15
19
|
</ul>
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<%= stylesheet_link_tag "citygate/application", :media => "all" %>
|
5
|
+
<%= javascript_include_tag "citygate/application" %>
|
6
|
+
<%= csrf_meta_tags %>
|
7
|
+
<%= yield :head %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<%= render 'citygate/shared/navigation' %>
|
11
|
+
|
12
|
+
<% flash.each do |name, msg| %>
|
13
|
+
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
|
14
|
+
<% end %>
|
15
|
+
<div id="container" class="container">
|
16
|
+
<%= yield %>
|
17
|
+
</div>
|
18
|
+
</body>
|
19
|
+
</html>
|
data/config/routes.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
|
1
|
+
Citygate::Engine.routes.draw do
|
2
2
|
root :to => "home#index"
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
|
4
|
+
devise_for :users,
|
5
|
+
:controllers => { :omniauth_callbacks => "citygate/users/omniauth_callbacks" },
|
6
|
+
:class_name => "Citygate::User",
|
7
|
+
:module => :devise
|
6
8
|
resources :users, :only => [:show]
|
7
9
|
|
8
|
-
namespace "admin" do
|
10
|
+
namespace "admin", constraints: { format: /(json|html|js| )/ } do
|
9
11
|
resources :users
|
10
12
|
end
|
11
13
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class DeviseCreateUsers < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
create_table(:
|
3
|
+
create_table(:citygate_users) do |t|
|
4
4
|
## Database authenticatable
|
5
5
|
t.string :email, :null => false, :default => ""
|
6
6
|
t.string :encrypted_password, :null => false, :default => ""
|
@@ -40,8 +40,8 @@ class DeviseCreateUsers < ActiveRecord::Migration
|
|
40
40
|
t.timestamps
|
41
41
|
end
|
42
42
|
|
43
|
-
add_index :
|
44
|
-
add_index :
|
43
|
+
add_index :citygate_users, :email, :unique => true
|
44
|
+
add_index :citygate_users, :reset_password_token, :unique => true
|
45
45
|
# add_index :users, :confirmation_token, :unique => true
|
46
46
|
# add_index :users, :unlock_token, :unique => true
|
47
47
|
# add_index :users, :authentication_token, :unique => true
|
@@ -1,12 +1,11 @@
|
|
1
1
|
class AddConfirmableToUsers < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
add_column :
|
3
|
+
add_column :citygate_users, :confirmation_token, :string
|
4
4
|
|
5
|
-
add_column :
|
5
|
+
add_column :citygate_users, :confirmed_at, :datetime
|
6
6
|
|
7
|
-
add_column :
|
8
|
-
|
9
|
-
add_column :users, :unconfirmed_email, :string
|
7
|
+
add_column :citygate_users, :confirmation_sent_at, :datetime
|
10
8
|
|
9
|
+
add_column :citygate_users, :unconfirmed_email, :string
|
11
10
|
end
|
12
11
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class DeviseInvitableAddToUsers < ActiveRecord::Migration
|
2
2
|
def up
|
3
|
-
change_table :
|
3
|
+
change_table :citygate_users do |t|
|
4
4
|
t.string :invitation_token, :limit => 60
|
5
5
|
t.datetime :invitation_sent_at
|
6
6
|
t.datetime :invitation_accepted_at
|
@@ -11,11 +11,11 @@ class DeviseInvitableAddToUsers < ActiveRecord::Migration
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# And allow null encrypted_password and password_salt:
|
14
|
-
change_column_null :
|
14
|
+
change_column_null :citygate_users, :encrypted_password, true
|
15
15
|
end
|
16
16
|
|
17
17
|
def down
|
18
|
-
change_table :
|
18
|
+
change_table :citygate_users do |t|
|
19
19
|
t.remove_references :invited_by, :polymorphic => true
|
20
20
|
t.remove :invitation_limit, :invitation_sent_at, :invitation_accepted_at, :invitation_token
|
21
21
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class AddOmniauthToDevise < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
add_index :
|
4
|
-
add_column :
|
3
|
+
add_index :citygate_users, :confirmation_token, :unique => true
|
4
|
+
add_column :citygate_users , :password_salt, :string
|
5
5
|
|
6
|
-
create_table :
|
6
|
+
create_table :citygate_authorizations do |t|
|
7
7
|
t.string :provider
|
8
8
|
t.string :uid
|
9
9
|
t.integer :user_id
|
data/db/seeds.rb
CHANGED
@@ -5,6 +5,13 @@
|
|
5
5
|
#
|
6
6
|
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
7
|
# Mayor.create(name: 'Emanuel', city: cities.first)
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
|
9
|
+
puts 'SETTING UP ROLES...'
|
10
|
+
roles = [
|
11
|
+
{:name => "Member"},
|
12
|
+
{:name => "Admin"}
|
13
|
+
]
|
14
|
+
|
15
|
+
roles.each do |attributes|
|
16
|
+
Citygate::Role.find_or_initialize_by_name(attributes[:name]).save!
|
17
|
+
end
|
@@ -4,17 +4,6 @@ module AppControllerHelpers
|
|
4
4
|
end
|
5
5
|
|
6
6
|
module InstanceMethods
|
7
|
-
|
8
|
-
def stored_location_for(resource_or_scope)
|
9
|
-
root_url
|
10
|
-
end
|
11
|
-
|
12
|
-
def after_sign_in_path_for(resource)
|
13
|
-
# This should work, but session is lost. See https://github.com/plataformatec/devise/issues/1357
|
14
|
-
# return_to = session[:return_to]
|
15
|
-
# session[:return_to] = nil
|
16
|
-
return_to = request.env['omniauth.origin']
|
17
|
-
stored_location_for(resource) || return_to || root_path
|
18
|
-
end
|
7
|
+
|
19
8
|
end
|
20
9
|
end
|
data/lib/citygate/engine.rb
CHANGED
@@ -10,8 +10,7 @@ require 'omniauth-facebook'
|
|
10
10
|
require 'omniauth-openid'
|
11
11
|
require 'uuidtools'
|
12
12
|
require 'will_paginate'
|
13
|
-
|
14
|
-
require "citygate"
|
13
|
+
require 'cancan'
|
15
14
|
|
16
15
|
module Citygate
|
17
16
|
def self.root
|
@@ -19,5 +18,6 @@ module Citygate
|
|
19
18
|
end
|
20
19
|
|
21
20
|
class Engine < ::Rails::Engine
|
21
|
+
isolate_namespace Citygate
|
22
22
|
end
|
23
23
|
end
|
data/lib/citygate/version.rb
CHANGED
data/lib/citygate.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require "citygate/engine"
|
2
2
|
|
3
3
|
module Citygate
|
4
|
-
|
5
|
-
|
4
|
+
Dir["#{Citygate.root}/lib/*.rb"].each {|file| require file}
|
5
|
+
|
6
6
|
ActiveSupport.on_load(:action_controller) do
|
7
7
|
extend AppControllerHelpers::ClassMethods
|
8
8
|
include AppControllerHelpers::InstanceMethods
|
data/lib/gravatar.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module Gravatar
|
4
|
+
|
5
|
+
def gravatar_id
|
6
|
+
Digest::MD5.hexdigest(self.email.to_s.downcase)
|
7
|
+
end
|
8
|
+
|
9
|
+
def gravatar_url(options = { rating: 'g'})
|
10
|
+
"https://secure.gravatar.com/avatar/#{self.gravatar_id}.png/rating=#{options[:rating]}"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: citygate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Group Buddies
|
@@ -10,12 +10,10 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-05-
|
14
|
-
default_executable:
|
13
|
+
date: 2012-05-26 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: rails
|
18
|
-
prerelease: false
|
19
17
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
18
|
none: false
|
21
19
|
requirements:
|
@@ -23,10 +21,10 @@ dependencies:
|
|
23
21
|
- !ruby/object:Gem::Version
|
24
22
|
version: 3.2.2
|
25
23
|
type: :runtime
|
24
|
+
prerelease: false
|
26
25
|
version_requirements: *id001
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: haml
|
29
|
-
prerelease: false
|
30
28
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
29
|
none: false
|
32
30
|
requirements:
|
@@ -34,10 +32,10 @@ dependencies:
|
|
34
32
|
- !ruby/object:Gem::Version
|
35
33
|
version: 3.1.4
|
36
34
|
type: :runtime
|
35
|
+
prerelease: false
|
37
36
|
version_requirements: *id002
|
38
37
|
- !ruby/object:Gem::Dependency
|
39
38
|
name: devise
|
40
|
-
prerelease: false
|
41
39
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
40
|
none: false
|
43
41
|
requirements:
|
@@ -45,10 +43,10 @@ dependencies:
|
|
45
43
|
- !ruby/object:Gem::Version
|
46
44
|
version: 2.0.4
|
47
45
|
type: :runtime
|
46
|
+
prerelease: false
|
48
47
|
version_requirements: *id003
|
49
48
|
- !ruby/object:Gem::Dependency
|
50
49
|
name: devise-encryptable
|
51
|
-
prerelease: false
|
52
50
|
requirement: &id004 !ruby/object:Gem::Requirement
|
53
51
|
none: false
|
54
52
|
requirements:
|
@@ -56,10 +54,10 @@ dependencies:
|
|
56
54
|
- !ruby/object:Gem::Version
|
57
55
|
version: 0.1.1
|
58
56
|
type: :runtime
|
57
|
+
prerelease: false
|
59
58
|
version_requirements: *id004
|
60
59
|
- !ruby/object:Gem::Dependency
|
61
60
|
name: devise_invitable
|
62
|
-
prerelease: false
|
63
61
|
requirement: &id005 !ruby/object:Gem::Requirement
|
64
62
|
none: false
|
65
63
|
requirements:
|
@@ -67,10 +65,10 @@ dependencies:
|
|
67
65
|
- !ruby/object:Gem::Version
|
68
66
|
version: 1.0.0
|
69
67
|
type: :runtime
|
68
|
+
prerelease: false
|
70
69
|
version_requirements: *id005
|
71
70
|
- !ruby/object:Gem::Dependency
|
72
71
|
name: omniauth
|
73
|
-
prerelease: false
|
74
72
|
requirement: &id006 !ruby/object:Gem::Requirement
|
75
73
|
none: false
|
76
74
|
requirements:
|
@@ -78,10 +76,10 @@ dependencies:
|
|
78
76
|
- !ruby/object:Gem::Version
|
79
77
|
version: 1.0.2
|
80
78
|
type: :runtime
|
79
|
+
prerelease: false
|
81
80
|
version_requirements: *id006
|
82
81
|
- !ruby/object:Gem::Dependency
|
83
82
|
name: omniauth-facebook
|
84
|
-
prerelease: false
|
85
83
|
requirement: &id007 !ruby/object:Gem::Requirement
|
86
84
|
none: false
|
87
85
|
requirements:
|
@@ -89,10 +87,10 @@ dependencies:
|
|
89
87
|
- !ruby/object:Gem::Version
|
90
88
|
version: 1.2.0
|
91
89
|
type: :runtime
|
90
|
+
prerelease: false
|
92
91
|
version_requirements: *id007
|
93
92
|
- !ruby/object:Gem::Dependency
|
94
93
|
name: omniauth-openid
|
95
|
-
prerelease: false
|
96
94
|
requirement: &id008 !ruby/object:Gem::Requirement
|
97
95
|
none: false
|
98
96
|
requirements:
|
@@ -100,10 +98,10 @@ dependencies:
|
|
100
98
|
- !ruby/object:Gem::Version
|
101
99
|
version: 1.0.1
|
102
100
|
type: :runtime
|
101
|
+
prerelease: false
|
103
102
|
version_requirements: *id008
|
104
103
|
- !ruby/object:Gem::Dependency
|
105
104
|
name: uuidtools
|
106
|
-
prerelease: false
|
107
105
|
requirement: &id009 !ruby/object:Gem::Requirement
|
108
106
|
none: false
|
109
107
|
requirements:
|
@@ -111,10 +109,10 @@ dependencies:
|
|
111
109
|
- !ruby/object:Gem::Version
|
112
110
|
version: 2.1.2
|
113
111
|
type: :runtime
|
112
|
+
prerelease: false
|
114
113
|
version_requirements: *id009
|
115
114
|
- !ruby/object:Gem::Dependency
|
116
115
|
name: will_paginate
|
117
|
-
prerelease: false
|
118
116
|
requirement: &id010 !ruby/object:Gem::Requirement
|
119
117
|
none: false
|
120
118
|
requirements:
|
@@ -122,194 +120,140 @@ dependencies:
|
|
122
120
|
- !ruby/object:Gem::Version
|
123
121
|
version: 3.0.3
|
124
122
|
type: :runtime
|
123
|
+
prerelease: false
|
125
124
|
version_requirements: *id010
|
126
125
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
128
|
-
prerelease: false
|
126
|
+
name: cancan
|
129
127
|
requirement: &id011 !ruby/object:Gem::Requirement
|
130
128
|
none: false
|
131
129
|
requirements:
|
132
130
|
- - ">="
|
133
131
|
- !ruby/object:Gem::Version
|
134
|
-
version: 1.
|
135
|
-
type: :
|
132
|
+
version: 1.6.7
|
133
|
+
type: :runtime
|
134
|
+
prerelease: false
|
136
135
|
version_requirements: *id011
|
137
136
|
- !ruby/object:Gem::Dependency
|
138
|
-
name:
|
139
|
-
prerelease: false
|
137
|
+
name: thin
|
140
138
|
requirement: &id012 !ruby/object:Gem::Requirement
|
141
139
|
none: false
|
142
140
|
requirements:
|
143
141
|
- - ">="
|
144
142
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
143
|
+
version: 1.3.1
|
146
144
|
type: :development
|
145
|
+
prerelease: false
|
147
146
|
version_requirements: *id012
|
148
147
|
- !ruby/object:Gem::Dependency
|
149
|
-
name:
|
150
|
-
prerelease: false
|
148
|
+
name: haml-rails
|
151
149
|
requirement: &id013 !ruby/object:Gem::Requirement
|
152
150
|
none: false
|
153
151
|
requirements:
|
154
152
|
- - ">="
|
155
153
|
- !ruby/object:Gem::Version
|
156
|
-
version: 0.
|
154
|
+
version: 0.3.4
|
157
155
|
type: :development
|
156
|
+
prerelease: false
|
158
157
|
version_requirements: *id013
|
159
158
|
- !ruby/object:Gem::Dependency
|
160
|
-
name:
|
161
|
-
prerelease: false
|
159
|
+
name: rspec-rails
|
162
160
|
requirement: &id014 !ruby/object:Gem::Requirement
|
163
161
|
none: false
|
164
162
|
requirements:
|
165
163
|
- - ">="
|
166
164
|
- !ruby/object:Gem::Version
|
167
|
-
version:
|
165
|
+
version: 2.8.1
|
168
166
|
type: :development
|
167
|
+
prerelease: false
|
169
168
|
version_requirements: *id014
|
170
169
|
- !ruby/object:Gem::Dependency
|
171
|
-
name:
|
172
|
-
prerelease: false
|
170
|
+
name: email_spec
|
173
171
|
requirement: &id015 !ruby/object:Gem::Requirement
|
174
172
|
none: false
|
175
173
|
requirements:
|
176
174
|
- - ">="
|
177
175
|
- !ruby/object:Gem::Version
|
178
|
-
version:
|
176
|
+
version: 1.2.1
|
179
177
|
type: :development
|
178
|
+
prerelease: false
|
180
179
|
version_requirements: *id015
|
181
180
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
183
|
-
prerelease: false
|
181
|
+
name: factory_girl
|
184
182
|
requirement: &id016 !ruby/object:Gem::Requirement
|
185
183
|
none: false
|
186
184
|
requirements:
|
187
|
-
- - "
|
185
|
+
- - "="
|
188
186
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
187
|
+
version: 2.6.4
|
190
188
|
type: :development
|
189
|
+
prerelease: false
|
191
190
|
version_requirements: *id016
|
192
191
|
- !ruby/object:Gem::Dependency
|
193
|
-
name:
|
194
|
-
prerelease: false
|
192
|
+
name: cucumber-rails
|
195
193
|
requirement: &id017 !ruby/object:Gem::Requirement
|
196
194
|
none: false
|
197
195
|
requirements:
|
198
196
|
- - ">="
|
199
197
|
- !ruby/object:Gem::Version
|
200
|
-
version:
|
198
|
+
version: 1.3.0
|
201
199
|
type: :development
|
200
|
+
prerelease: false
|
202
201
|
version_requirements: *id017
|
203
202
|
- !ruby/object:Gem::Dependency
|
204
|
-
name:
|
205
|
-
prerelease: false
|
203
|
+
name: capybara
|
206
204
|
requirement: &id018 !ruby/object:Gem::Requirement
|
207
205
|
none: false
|
208
206
|
requirements:
|
209
207
|
- - ">="
|
210
208
|
- !ruby/object:Gem::Version
|
211
|
-
version:
|
209
|
+
version: 1.1.2
|
212
210
|
type: :development
|
211
|
+
prerelease: false
|
213
212
|
version_requirements: *id018
|
214
213
|
- !ruby/object:Gem::Dependency
|
215
|
-
name:
|
216
|
-
prerelease: false
|
214
|
+
name: database_cleaner
|
217
215
|
requirement: &id019 !ruby/object:Gem::Requirement
|
218
216
|
none: false
|
219
217
|
requirements:
|
220
218
|
- - ">="
|
221
219
|
- !ruby/object:Gem::Version
|
222
|
-
version: 0.
|
220
|
+
version: 0.7.1
|
223
221
|
type: :development
|
222
|
+
prerelease: false
|
224
223
|
version_requirements: *id019
|
225
224
|
- !ruby/object:Gem::Dependency
|
226
|
-
name:
|
227
|
-
prerelease: false
|
225
|
+
name: launchy
|
228
226
|
requirement: &id020 !ruby/object:Gem::Requirement
|
229
227
|
none: false
|
230
228
|
requirements:
|
231
229
|
- - ">="
|
232
230
|
- !ruby/object:Gem::Version
|
233
|
-
version: 0.
|
231
|
+
version: 2.0.5
|
234
232
|
type: :development
|
233
|
+
prerelease: false
|
235
234
|
version_requirements: *id020
|
236
235
|
- !ruby/object:Gem::Dependency
|
237
|
-
name:
|
238
|
-
prerelease: false
|
236
|
+
name: jasmine-rails
|
239
237
|
requirement: &id021 !ruby/object:Gem::Requirement
|
240
238
|
none: false
|
241
239
|
requirements:
|
242
240
|
- - ">="
|
243
241
|
- !ruby/object:Gem::Version
|
244
|
-
version:
|
242
|
+
version: 0.0.3
|
245
243
|
type: :development
|
244
|
+
prerelease: false
|
246
245
|
version_requirements: *id021
|
247
246
|
- !ruby/object:Gem::Dependency
|
248
|
-
name:
|
249
|
-
prerelease: false
|
247
|
+
name: jasmine-jquery-rails
|
250
248
|
requirement: &id022 !ruby/object:Gem::Requirement
|
251
249
|
none: false
|
252
250
|
requirements:
|
253
251
|
- - ">="
|
254
252
|
- !ruby/object:Gem::Version
|
255
|
-
version:
|
256
|
-
type: :development
|
257
|
-
version_requirements: *id022
|
258
|
-
- !ruby/object:Gem::Dependency
|
259
|
-
name: factory_girl
|
260
|
-
prerelease: false
|
261
|
-
requirement: &id023 !ruby/object:Gem::Requirement
|
262
|
-
none: false
|
263
|
-
requirements:
|
264
|
-
- - "="
|
265
|
-
- !ruby/object:Gem::Version
|
266
|
-
version: 2.6.4
|
267
|
-
type: :development
|
268
|
-
version_requirements: *id023
|
269
|
-
- !ruby/object:Gem::Dependency
|
270
|
-
name: cucumber-rails
|
271
|
-
prerelease: false
|
272
|
-
requirement: &id024 !ruby/object:Gem::Requirement
|
273
|
-
none: false
|
274
|
-
requirements:
|
275
|
-
- - ">="
|
276
|
-
- !ruby/object:Gem::Version
|
277
|
-
version: 1.3.0
|
278
|
-
type: :development
|
279
|
-
version_requirements: *id024
|
280
|
-
- !ruby/object:Gem::Dependency
|
281
|
-
name: capybara
|
282
|
-
prerelease: false
|
283
|
-
requirement: &id025 !ruby/object:Gem::Requirement
|
284
|
-
none: false
|
285
|
-
requirements:
|
286
|
-
- - ">="
|
287
|
-
- !ruby/object:Gem::Version
|
288
|
-
version: 1.1.2
|
289
|
-
type: :development
|
290
|
-
version_requirements: *id025
|
291
|
-
- !ruby/object:Gem::Dependency
|
292
|
-
name: database_cleaner
|
293
|
-
prerelease: false
|
294
|
-
requirement: &id026 !ruby/object:Gem::Requirement
|
295
|
-
none: false
|
296
|
-
requirements:
|
297
|
-
- - ">="
|
298
|
-
- !ruby/object:Gem::Version
|
299
|
-
version: 0.7.1
|
253
|
+
version: "0"
|
300
254
|
type: :development
|
301
|
-
version_requirements: *id026
|
302
|
-
- !ruby/object:Gem::Dependency
|
303
|
-
name: launchy
|
304
255
|
prerelease: false
|
305
|
-
|
306
|
-
none: false
|
307
|
-
requirements:
|
308
|
-
- - ">="
|
309
|
-
- !ruby/object:Gem::Version
|
310
|
-
version: 2.0.5
|
311
|
-
type: :development
|
312
|
-
version_requirements: *id027
|
256
|
+
version_requirements: *id022
|
313
257
|
description: Citygate is an Engine that provides user model with sign up and log in, admin backend for managing users.
|
314
258
|
email:
|
315
259
|
- zamith@groupbuddies.com
|
@@ -320,31 +264,36 @@ extensions: []
|
|
320
264
|
extra_rdoc_files: []
|
321
265
|
|
322
266
|
files:
|
267
|
+
- app/assets/javascripts/citygate/admin_users.coffee
|
323
268
|
- app/assets/javascripts/citygate/application.js
|
269
|
+
- app/assets/javascripts/citygate/global.coffee
|
324
270
|
- app/assets/stylesheets/citygate/application.css.scss
|
325
271
|
- app/assets/stylesheets/citygate/main.sass
|
326
|
-
- app/controllers/admin/application_controller.rb
|
327
|
-
- app/controllers/admin/users_controller.rb
|
328
|
-
- app/controllers/application_controller.rb
|
329
|
-
- app/controllers/home_controller.rb
|
330
|
-
- app/controllers/users/omniauth_callbacks_controller.rb
|
331
|
-
- app/controllers/users_controller.rb
|
272
|
+
- app/controllers/citygate/admin/application_controller.rb
|
273
|
+
- app/controllers/citygate/admin/users_controller.rb
|
274
|
+
- app/controllers/citygate/application_controller.rb
|
275
|
+
- app/controllers/citygate/home_controller.rb
|
276
|
+
- app/controllers/citygate/users/omniauth_callbacks_controller.rb
|
277
|
+
- app/controllers/citygate/users_controller.rb
|
332
278
|
- app/helpers/citygate/application_helper.rb
|
333
|
-
- app/models/
|
334
|
-
- app/models/
|
335
|
-
- app/
|
336
|
-
- app/
|
337
|
-
- app/views/
|
338
|
-
- app/views/
|
339
|
-
- app/views/
|
340
|
-
- app/views/
|
341
|
-
- app/views/
|
342
|
-
- app/views/
|
343
|
-
- app/views/
|
344
|
-
- app/views/
|
345
|
-
- app/views/
|
279
|
+
- app/models/citygate/ability.rb
|
280
|
+
- app/models/citygate/authorization.rb
|
281
|
+
- app/models/citygate/role.rb
|
282
|
+
- app/models/citygate/user.rb
|
283
|
+
- app/views/citygate/admin/users/_user_show.html.erb
|
284
|
+
- app/views/citygate/admin/users/_users.html.erb
|
285
|
+
- app/views/citygate/admin/users/index.html.erb
|
286
|
+
- app/views/citygate/admin/users/index.js.erb
|
287
|
+
- app/views/citygate/admin/users/show.html.erb
|
288
|
+
- app/views/citygate/admin/users/show.js.erb
|
289
|
+
- app/views/citygate/devise/_links.erb
|
290
|
+
- app/views/citygate/devise/registrations/edit.html.haml
|
291
|
+
- app/views/citygate/home/index.html.erb
|
292
|
+
- app/views/citygate/shared/_navigation.html.erb
|
293
|
+
- app/views/citygate/users/show.html.erb
|
294
|
+
- app/views/layouts/admin/application.html.erb
|
295
|
+
- app/views/layouts/application.html.erb
|
346
296
|
- config/cucumber.yml
|
347
|
-
- config/initializers/devise-lol.rb
|
348
297
|
- config/initializers/devise.rb
|
349
298
|
- config/locales/devise.en.yml
|
350
299
|
- config/locales/devise_invitable.en.yml
|
@@ -355,16 +304,17 @@ files:
|
|
355
304
|
- db/migrate/20120303195111_add_confirmable_to_users.rb
|
356
305
|
- db/migrate/20120303195145_devise_invitable_add_to_users.rb
|
357
306
|
- db/migrate/20120507112430_add_omniauth_to_devise.rb
|
307
|
+
- db/migrate/20120523163700_create_roles.rb
|
358
308
|
- db/seeds.rb
|
359
309
|
- lib/app_controller_helpers.rb
|
360
310
|
- lib/citygate/engine.rb
|
361
311
|
- lib/citygate/version.rb
|
362
312
|
- lib/citygate.rb
|
313
|
+
- lib/gravatar.rb
|
363
314
|
- lib/tasks/citygate_tasks.rake
|
364
315
|
- MIT-LICENSE
|
365
316
|
- Rakefile
|
366
317
|
- README.rdoc
|
367
|
-
has_rdoc: true
|
368
318
|
homepage:
|
369
319
|
licenses: []
|
370
320
|
|
@@ -378,19 +328,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
378
328
|
requirements:
|
379
329
|
- - ">="
|
380
330
|
- !ruby/object:Gem::Version
|
331
|
+
hash: 1496931421819216404
|
332
|
+
segments:
|
333
|
+
- 0
|
381
334
|
version: "0"
|
382
335
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
383
336
|
none: false
|
384
337
|
requirements:
|
385
338
|
- - ">="
|
386
339
|
- !ruby/object:Gem::Version
|
340
|
+
hash: 1496931421819216404
|
341
|
+
segments:
|
342
|
+
- 0
|
387
343
|
version: "0"
|
388
344
|
requirements: []
|
389
345
|
|
390
346
|
rubyforge_project:
|
391
|
-
rubygems_version: 1.
|
347
|
+
rubygems_version: 1.8.24
|
392
348
|
signing_key:
|
393
349
|
specification_version: 3
|
394
350
|
summary: Simple authentication and user management Engine.
|
395
351
|
test_files: []
|
396
352
|
|
353
|
+
has_rdoc:
|
data/app/models/authorization.rb
DELETED
data/app/models/user.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class User < ActiveRecord::Base
|
2
|
-
devise :database_authenticatable, :registerable, :encryptable,
|
3
|
-
:recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable
|
4
|
-
|
5
|
-
devise :encryptor => :sha1
|
6
|
-
|
7
|
-
# Setup accessible (or protected) attributes for your model
|
8
|
-
attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :confirmed_at
|
9
|
-
|
10
|
-
|
11
|
-
has_many :authorizations, :dependent => :destroy
|
12
|
-
end
|
File without changes
|
@@ -1,32 +0,0 @@
|
|
1
|
-
!!!
|
2
|
-
%html
|
3
|
-
%head
|
4
|
-
%title Citygate
|
5
|
-
%meta{:charset => "utf-8"}
|
6
|
-
%meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"}
|
7
|
-
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
|
8
|
-
= stylesheet_link_tag "citygate/application", :media => "all"
|
9
|
-
= javascript_include_tag "citygate/application"
|
10
|
-
= csrf_meta_tags
|
11
|
-
%body{:class => params[:controller]}
|
12
|
-
#container.container
|
13
|
-
%header
|
14
|
-
.navbar.navbar-fixed-top
|
15
|
-
.navbar-inner
|
16
|
-
.container
|
17
|
-
%ul.nav
|
18
|
-
%li.active
|
19
|
-
<a href="/">Home</a>
|
20
|
-
%li
|
21
|
-
<a href="#">Link</a>
|
22
|
-
%li
|
23
|
-
<a href="#">Link</a>
|
24
|
-
%h1 Admin PANEL
|
25
|
-
%nav
|
26
|
-
%ul.hmenu
|
27
|
-
= render 'shared/navigation'
|
28
|
-
- flash.each do |name, msg|
|
29
|
-
= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String)
|
30
|
-
#main{:role => "main"}
|
31
|
-
= yield
|
32
|
-
%footer
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= render :file => "layouts/citygate_layout", :layout => "layouts/application" %>
|