citygate 0.0.1
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 +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/citygate/application.js +15 -0
- data/app/assets/stylesheets/citygate/application.css.scss +41 -0
- data/app/controllers/admin/application_controller.rb +4 -0
- data/app/controllers/admin/users_controller.rb +9 -0
- data/app/controllers/application_controller.rb +8 -0
- data/app/controllers/home_controller.rb +5 -0
- data/app/controllers/users/omniauth_callbacks_controller.rb +103 -0
- data/app/controllers/users/omniauth_dummy.rb +6 -0
- data/app/controllers/users/omniauth_interface.rb +6 -0
- data/app/controllers/users_controller.rb +8 -0
- data/app/helpers/citygate/application_helper.rb +4 -0
- data/app/models/authorization.rb +5 -0
- data/app/models/user.rb +12 -0
- data/app/views/admin/users/index.html.haml +4 -0
- data/app/views/devise/_links.erb +25 -0
- data/app/views/devise/registrations/edit.html.haml +31 -0
- data/app/views/devise/registrations/new.html.haml +21 -0
- data/app/views/home/index.html.haml +4 -0
- data/app/views/layouts/admin/application.html.haml +32 -0
- data/app/views/layouts/application.html.haml +22 -0
- data/app/views/shared/_navigation.html.erb +13 -0
- data/app/views/users/show.html.haml +4 -0
- data/config/cucumber.yml +8 -0
- data/config/initializers/devise-lol.rb +4 -0
- data/config/initializers/devise.rb +233 -0
- data/config/locales/devise.en.yml +57 -0
- data/config/locales/devise_invitable.en.yml +10 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +10 -0
- data/db/migrate/20120303195052_devise_create_users.rb +49 -0
- data/db/migrate/20120303195103_add_name_to_users.rb +6 -0
- data/db/migrate/20120303195111_add_confirmable_to_users.rb +12 -0
- data/db/migrate/20120303195145_devise_invitable_add_to_users.rb +23 -0
- data/db/migrate/20120507112430_add_omniauth_to_devise.rb +19 -0
- data/db/seeds.rb +10 -0
- data/lib/abstract_interface.rb +36 -0
- data/lib/citygate/engine.rb +6 -0
- data/lib/citygate/version.rb +3 -0
- data/lib/citygate.rb +4 -0
- data/lib/tasks/citygate_tasks.rake +4 -0
- data/test/citygate_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +277 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Miguel Regedor
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Citygate'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
33
|
+
t.libs << 'lib'
|
34
|
+
t.libs << 'test'
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
36
|
+
t.verbose = false
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,41 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
14
|
+
|
15
|
+
@import 'bootstrap';
|
16
|
+
|
17
|
+
body {
|
18
|
+
background-color: #cccccc;
|
19
|
+
}
|
20
|
+
|
21
|
+
header nav ul {
|
22
|
+
list-style: none;
|
23
|
+
margin: 0 0 2em;
|
24
|
+
padding: 0;
|
25
|
+
}
|
26
|
+
header nav ul li {
|
27
|
+
display: inline;
|
28
|
+
}
|
29
|
+
#flash_notice, #flash_alert {
|
30
|
+
padding: 5px 8px;
|
31
|
+
margin: 10px 0;
|
32
|
+
}
|
33
|
+
#flash_notice {
|
34
|
+
background-color: #CFC;
|
35
|
+
border: solid 1px #6C6;
|
36
|
+
}
|
37
|
+
#flash_alert {
|
38
|
+
background-color: #FCC;
|
39
|
+
border: solid 1px #C66;
|
40
|
+
}
|
41
|
+
|
@@ -0,0 +1,103 @@
|
|
1
|
+
class Users::OmniauthCallbacksController < Users::OmniauthInterface
|
2
|
+
|
3
|
+
def facebook
|
4
|
+
oauthorize "Facebook"
|
5
|
+
end
|
6
|
+
|
7
|
+
def google
|
8
|
+
oauthorize "Google"
|
9
|
+
end
|
10
|
+
|
11
|
+
def passthru
|
12
|
+
render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def oauthorize(kind)
|
18
|
+
@user = find_for_ouath(kind, env["omniauth.auth"], current_user)
|
19
|
+
if @user.persisted?
|
20
|
+
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => kind
|
21
|
+
session["devise.#{kind.downcase}_data"] = env["omniauth.auth"]
|
22
|
+
sign_in_and_redirect @user, :event => :authentication
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def find_for_ouath(provider, access_token, resource=nil)
|
27
|
+
user, email, name, uid, auth_attr = nil, nil, nil, {}
|
28
|
+
case provider
|
29
|
+
when "Facebook"
|
30
|
+
uid = access_token['uid']
|
31
|
+
email = access_token['extra']['raw_info']['email']
|
32
|
+
auth_attr = {
|
33
|
+
:uid => uid,
|
34
|
+
:token => access_token['credentials']['token'],
|
35
|
+
:secret => nil,
|
36
|
+
:name => access_token['extra']['raw_info']['name'],
|
37
|
+
:link => access_token['extra']['raw_info']['link'],
|
38
|
+
:image_url => access_token['info']['image']
|
39
|
+
}
|
40
|
+
when "Google"
|
41
|
+
uid = access_token['uid']
|
42
|
+
email = access_token['info']['email']
|
43
|
+
auth_attr = {
|
44
|
+
:uid => uid,
|
45
|
+
:token => access_token['credentials']['token'],
|
46
|
+
:secret => nil,
|
47
|
+
:name => access_token['info']['name'],
|
48
|
+
}
|
49
|
+
else
|
50
|
+
raise 'Provider #{provider} not handled'
|
51
|
+
end
|
52
|
+
if resource.nil?
|
53
|
+
if email
|
54
|
+
user = find_for_oauth_by_email(email, resource)
|
55
|
+
elsif uid && name
|
56
|
+
user = find_for_oauth_by_uid(uid, resource)
|
57
|
+
if user.nil?
|
58
|
+
user = find_for_oauth_by_name(name, resource)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
else
|
62
|
+
user = resource
|
63
|
+
end
|
64
|
+
|
65
|
+
auth = user.authorizations.find_by_provider(provider)
|
66
|
+
if auth.nil?
|
67
|
+
auth = user.authorizations.build(:provider => provider)
|
68
|
+
user.authorizations << auth
|
69
|
+
end
|
70
|
+
auth.update_attributes auth_attr
|
71
|
+
|
72
|
+
return user
|
73
|
+
end
|
74
|
+
|
75
|
+
def find_for_oauth_by_uid(uid, resource=nil)
|
76
|
+
user = nil
|
77
|
+
if auth = Authorization.find_by_uid(uid.to_s)
|
78
|
+
user = auth.user
|
79
|
+
end
|
80
|
+
return user
|
81
|
+
end
|
82
|
+
|
83
|
+
def find_for_oauth_by_email(email, resource=nil)
|
84
|
+
if user = User.find_by_email(email)
|
85
|
+
user
|
86
|
+
else
|
87
|
+
user = User.new(:email => email, :password => Devise.friendly_token[0,20])
|
88
|
+
user.save
|
89
|
+
end
|
90
|
+
return user
|
91
|
+
end
|
92
|
+
|
93
|
+
def find_for_oauth_by_name(name, resource=nil)
|
94
|
+
if user = User.find_by_name(name)
|
95
|
+
user
|
96
|
+
else
|
97
|
+
user = User.new(:name => name, :password => Devise.friendly_token[0,20], :email => "#{UUIDTools::UUID.random_create}@host")
|
98
|
+
user.save false
|
99
|
+
end
|
100
|
+
return user
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
data/app/models/user.rb
ADDED
@@ -0,0 +1,12 @@
|
|
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
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%- if controller_name != 'sessions' %>
|
2
|
+
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
3
|
+
<% end -%>
|
4
|
+
|
5
|
+
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
6
|
+
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
10
|
+
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
11
|
+
<% end -%>
|
12
|
+
|
13
|
+
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
14
|
+
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
15
|
+
<% end -%>
|
16
|
+
|
17
|
+
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
18
|
+
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
19
|
+
<% end -%>
|
20
|
+
|
21
|
+
<%- if devise_mapping.omniauthable? %>
|
22
|
+
<%- resource_class.omniauth_providers.each do |provider| %>
|
23
|
+
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
|
24
|
+
<% end -%>
|
25
|
+
<% end -%>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
%h2
|
2
|
+
Edit #{resource_name.to_s.humanize}
|
3
|
+
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f|
|
4
|
+
= devise_error_messages!
|
5
|
+
%p
|
6
|
+
= f.label :name
|
7
|
+
%br/
|
8
|
+
= f.text_field :name
|
9
|
+
%p
|
10
|
+
= f.label :email
|
11
|
+
%br/
|
12
|
+
= f.email_field :email
|
13
|
+
%p
|
14
|
+
= f.label :password
|
15
|
+
%i (leave blank if you don't want to change it)
|
16
|
+
%br/
|
17
|
+
= f.password_field :password
|
18
|
+
%p
|
19
|
+
= f.label :password_confirmation
|
20
|
+
%br/
|
21
|
+
= f.password_field :password_confirmation
|
22
|
+
%p
|
23
|
+
= f.label :current_password
|
24
|
+
%i (we need your current password to confirm your changes)
|
25
|
+
%br/
|
26
|
+
= f.password_field :current_password
|
27
|
+
%p= f.submit "Update"
|
28
|
+
%h3 Cancel my account
|
29
|
+
%p
|
30
|
+
Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}.
|
31
|
+
= link_to "Back", :back
|
@@ -0,0 +1,21 @@
|
|
1
|
+
%h2 Sign up
|
2
|
+
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
|
3
|
+
= devise_error_messages!
|
4
|
+
%p
|
5
|
+
= f.label :name
|
6
|
+
%br/
|
7
|
+
= f.text_field :name
|
8
|
+
%p
|
9
|
+
= f.label :email
|
10
|
+
%br/
|
11
|
+
= f.email_field :email
|
12
|
+
%p
|
13
|
+
= f.label :password
|
14
|
+
%br/
|
15
|
+
= f.password_field :password
|
16
|
+
%p
|
17
|
+
= f.label :password_confirmation
|
18
|
+
%br/
|
19
|
+
= f.password_field :password_confirmation
|
20
|
+
%p= f.submit "Sign up"
|
21
|
+
= render "links"
|
@@ -0,0 +1,32 @@
|
|
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
|
@@ -0,0 +1,22 @@
|
|
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
|
+
%h1 NORMAL PANEL
|
15
|
+
%nav
|
16
|
+
%ul.hmenu
|
17
|
+
= render 'shared/navigation'
|
18
|
+
- flash.each do |name, msg|
|
19
|
+
= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String)
|
20
|
+
#main{:role => "main"}
|
21
|
+
= yield
|
22
|
+
%footer
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% if user_signed_in? %>
|
2
|
+
<li><%= link_to('Logout', destroy_user_session_path, :method=>'delete') %></li>
|
3
|
+
<li><%= link_to('Edit account', edit_user_registration_path) %></li>
|
4
|
+
<% else %>
|
5
|
+
<li><%= link_to('Login', new_user_session_path) %></li>
|
6
|
+
<li><%= link_to('Sign up', new_user_registration_path) %></li>
|
7
|
+
<% User.omniauth_providers.each do |provider| %>
|
8
|
+
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(User.new,provider) %>
|
9
|
+
<% end -%>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
|
13
|
+
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
+
std_opts = "-r features/support/ -r features/step_definitions --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
|
5
|
+
%>
|
6
|
+
default: <%= std_opts %> features
|
7
|
+
wip: --tags @wip:3 --wip features
|
8
|
+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|