splendeo-generators 0.1.0
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/CHANGELOG +119 -0
- data/LICENSE +20 -0
- data/README.rdoc +98 -0
- data/Rakefile +12 -0
- data/lib/nifty_generators.rb +3 -0
- data/rails_generators/splendeo_authentication/USAGE +50 -0
- data/rails_generators/splendeo_authentication/lib/insert_commands.rb +74 -0
- data/rails_generators/splendeo_authentication/splendeo_authentication_generator.rb +128 -0
- data/rails_generators/splendeo_authentication/templates/authentication.rb +61 -0
- data/rails_generators/splendeo_authentication/templates/authlogic_session.rb +2 -0
- data/rails_generators/splendeo_authentication/templates/fixtures.yml +24 -0
- data/rails_generators/splendeo_authentication/templates/migration.rb +20 -0
- data/rails_generators/splendeo_authentication/templates/sessions_controller.rb +45 -0
- data/rails_generators/splendeo_authentication/templates/sessions_helper.rb +2 -0
- data/rails_generators/splendeo_authentication/templates/tests/rspec/sessions_controller.rb +39 -0
- data/rails_generators/splendeo_authentication/templates/tests/rspec/user.rb +83 -0
- data/rails_generators/splendeo_authentication/templates/tests/rspec/users_controller.rb +26 -0
- data/rails_generators/splendeo_authentication/templates/tests/shoulda/sessions_controller.rb +40 -0
- data/rails_generators/splendeo_authentication/templates/tests/shoulda/user.rb +85 -0
- data/rails_generators/splendeo_authentication/templates/tests/shoulda/users_controller.rb +27 -0
- data/rails_generators/splendeo_authentication/templates/tests/testunit/sessions_controller.rb +36 -0
- data/rails_generators/splendeo_authentication/templates/tests/testunit/user.rb +88 -0
- data/rails_generators/splendeo_authentication/templates/tests/testunit/users_controller.rb +23 -0
- data/rails_generators/splendeo_authentication/templates/user.rb +42 -0
- data/rails_generators/splendeo_authentication/templates/users_controller.rb +18 -0
- data/rails_generators/splendeo_authentication/templates/users_helper.rb +2 -0
- data/rails_generators/splendeo_authentication/templates/views/erb/login.html.erb +30 -0
- data/rails_generators/splendeo_authentication/templates/views/erb/signup.html.erb +24 -0
- data/rails_generators/splendeo_authentication/templates/views/haml/login.html.haml +30 -0
- data/rails_generators/splendeo_authentication/templates/views/haml/signup.html.haml +24 -0
- data/rails_generators/splendeo_config/USAGE +23 -0
- data/rails_generators/splendeo_config/splendeo_config_generator.rb +32 -0
- data/rails_generators/splendeo_config/templates/config.yml +8 -0
- data/rails_generators/splendeo_config/templates/load_config.rb +2 -0
- data/rails_generators/splendeo_layout/USAGE +25 -0
- data/rails_generators/splendeo_layout/splendeo_layout_generator.rb +76 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/ie.sass +103 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/buttons/icons/cross.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/buttons/icons/key.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/buttons/icons/tick.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/buttons/readme.txt +32 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/buttons/screen.sass +104 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/fancy-type/readme.txt +14 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/fancy-type/screen.sass +34 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/link-icons/icons/doc.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/link-icons/icons/email.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/link-icons/icons/external.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/link-icons/icons/feed.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/link-icons/icons/im.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/link-icons/icons/pdf.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/link-icons/icons/visited.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/link-icons/icons/xls.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/link-icons/readme.txt +18 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/link-icons/screen.sass +50 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/rtl/readme.txt +10 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/plugins/rtl/screen.sass +272 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/print.sass +75 -0
- data/rails_generators/splendeo_layout/templates/blueprint-sass/screen.sass +1062 -0
- data/rails_generators/splendeo_layout/templates/blueprint/ie.css +35 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/buttons/icons/key.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/buttons/readme.txt +32 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/buttons/screen.css +97 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/fancy-type/screen.css +71 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/link-icons/readme.txt +18 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/link-icons/screen.css +40 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/rtl/readme.txt +10 -0
- data/rails_generators/splendeo_layout/templates/blueprint/plugins/rtl/screen.css +110 -0
- data/rails_generators/splendeo_layout/templates/blueprint/print.css +29 -0
- data/rails_generators/splendeo_layout/templates/blueprint/screen.css +258 -0
- data/rails_generators/splendeo_layout/templates/haml/init.rb +16 -0
- data/rails_generators/splendeo_layout/templates/helper.rb +22 -0
- data/rails_generators/splendeo_layout/templates/layout.html.erb +34 -0
- data/rails_generators/splendeo_layout/templates/layout.html.haml +31 -0
- data/rails_generators/splendeo_layout/templates/stylesheet.css +77 -0
- data/rails_generators/splendeo_layout/templates/stylesheet.sass +63 -0
- data/rails_generators/splendeo_scaffold/USAGE +51 -0
- data/rails_generators/splendeo_scaffold/splendeo_scaffold_generator.rb +232 -0
- data/rails_generators/splendeo_scaffold/templates/actions/create.rb +9 -0
- data/rails_generators/splendeo_scaffold/templates/actions/destroy.rb +6 -0
- data/rails_generators/splendeo_scaffold/templates/actions/edit.rb +3 -0
- data/rails_generators/splendeo_scaffold/templates/actions/index.rb +3 -0
- data/rails_generators/splendeo_scaffold/templates/actions/new.rb +3 -0
- data/rails_generators/splendeo_scaffold/templates/actions/show.rb +3 -0
- data/rails_generators/splendeo_scaffold/templates/actions/update.rb +9 -0
- data/rails_generators/splendeo_scaffold/templates/controller.rb +3 -0
- data/rails_generators/splendeo_scaffold/templates/fixtures.yml +9 -0
- data/rails_generators/splendeo_scaffold/templates/helper.rb +2 -0
- data/rails_generators/splendeo_scaffold/templates/migration.rb +16 -0
- data/rails_generators/splendeo_scaffold/templates/model.rb +3 -0
- data/rails_generators/splendeo_scaffold/templates/tests/rspec/actions/create.rb +11 -0
- data/rails_generators/splendeo_scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
- data/rails_generators/splendeo_scaffold/templates/tests/rspec/actions/edit.rb +4 -0
- data/rails_generators/splendeo_scaffold/templates/tests/rspec/actions/index.rb +4 -0
- data/rails_generators/splendeo_scaffold/templates/tests/rspec/actions/new.rb +4 -0
- data/rails_generators/splendeo_scaffold/templates/tests/rspec/actions/show.rb +4 -0
- data/rails_generators/splendeo_scaffold/templates/tests/rspec/actions/update.rb +11 -0
- data/rails_generators/splendeo_scaffold/templates/tests/rspec/controller.rb +8 -0
- data/rails_generators/splendeo_scaffold/templates/tests/rspec/model.rb +7 -0
- data/rails_generators/splendeo_scaffold/templates/tests/shoulda/actions/create.rb +13 -0
- data/rails_generators/splendeo_scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
- data/rails_generators/splendeo_scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
- data/rails_generators/splendeo_scaffold/templates/tests/shoulda/actions/index.rb +6 -0
- data/rails_generators/splendeo_scaffold/templates/tests/shoulda/actions/new.rb +6 -0
- data/rails_generators/splendeo_scaffold/templates/tests/shoulda/actions/show.rb +6 -0
- data/rails_generators/splendeo_scaffold/templates/tests/shoulda/actions/update.rb +13 -0
- data/rails_generators/splendeo_scaffold/templates/tests/shoulda/controller.rb +5 -0
- data/rails_generators/splendeo_scaffold/templates/tests/shoulda/model.rb +7 -0
- data/rails_generators/splendeo_scaffold/templates/tests/testunit/actions/create.rb +11 -0
- data/rails_generators/splendeo_scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
- data/rails_generators/splendeo_scaffold/templates/tests/testunit/actions/edit.rb +4 -0
- data/rails_generators/splendeo_scaffold/templates/tests/testunit/actions/index.rb +4 -0
- data/rails_generators/splendeo_scaffold/templates/tests/testunit/actions/new.rb +4 -0
- data/rails_generators/splendeo_scaffold/templates/tests/testunit/actions/show.rb +4 -0
- data/rails_generators/splendeo_scaffold/templates/tests/testunit/actions/update.rb +11 -0
- data/rails_generators/splendeo_scaffold/templates/tests/testunit/controller.rb +5 -0
- data/rails_generators/splendeo_scaffold/templates/tests/testunit/model.rb +7 -0
- data/rails_generators/splendeo_scaffold/templates/views/erb/_form.html.erb +10 -0
- data/rails_generators/splendeo_scaffold/templates/views/erb/edit.html.erb +14 -0
- data/rails_generators/splendeo_scaffold/templates/views/erb/index.html.erb +29 -0
- data/rails_generators/splendeo_scaffold/templates/views/erb/new.html.erb +7 -0
- data/rails_generators/splendeo_scaffold/templates/views/erb/show.html.erb +20 -0
- data/rails_generators/splendeo_scaffold/templates/views/haml/_form.html.haml +10 -0
- data/rails_generators/splendeo_scaffold/templates/views/haml/edit.html.haml +14 -0
- data/rails_generators/splendeo_scaffold/templates/views/haml/index.html.haml +25 -0
- data/rails_generators/splendeo_scaffold/templates/views/haml/new.html.haml +7 -0
- data/rails_generators/splendeo_scaffold/templates/views/haml/show.html.haml +20 -0
- data/test/test_helper.rb +119 -0
- data/test/test_splendeo_authentication_generator.rb +274 -0
- data/test/test_splendeo_config_generator.rb +37 -0
- data/test/test_splendeo_layout_generator.rb +42 -0
- data/test/test_splendeo_scaffold_generator.rb +534 -0
- metadata +212 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class <%= session_plural_class_name %>ControllerTest < ActionController::TestCase
|
|
4
|
+
def test_new
|
|
5
|
+
get :new
|
|
6
|
+
assert_template 'new'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
<%- if options[:authlogic] -%>
|
|
10
|
+
def test_create_invalid
|
|
11
|
+
post :create, :<%= session_singular_name %> => { :username => "foo", :password => "badpassword" }
|
|
12
|
+
assert_template 'new'
|
|
13
|
+
assert_nil <%= session_class_name %>.find
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_create_valid
|
|
17
|
+
post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
|
|
18
|
+
assert_redirected_to root_url
|
|
19
|
+
assert_equal <%= user_plural_name %>(:foo), <%= session_class_name %>.find.<%= user_singular_name %>
|
|
20
|
+
end
|
|
21
|
+
<%- else -%>
|
|
22
|
+
def test_create_invalid
|
|
23
|
+
<%= user_class_name %>.stubs(:authenticate).returns(nil)
|
|
24
|
+
post :create
|
|
25
|
+
assert_template 'new'
|
|
26
|
+
assert_nil session['<%= user_singular_name %>_id']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_create_valid
|
|
30
|
+
<%= user_class_name %>.stubs(:authenticate).returns(<%= user_class_name %>.first)
|
|
31
|
+
post :create
|
|
32
|
+
assert_redirected_to root_url
|
|
33
|
+
assert_equal <%= user_class_name %>.first.id, session['<%= user_singular_name %>_id']
|
|
34
|
+
end
|
|
35
|
+
<%- end -%>
|
|
36
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class <%= user_class_name %>Test < ActiveSupport::TestCase
|
|
4
|
+
<%- unless options[:authlogic] -%>
|
|
5
|
+
def new_<%= user_singular_name %>(attributes = {})
|
|
6
|
+
attributes[:username] ||= 'foo'
|
|
7
|
+
attributes[:email] ||= 'foo@example.com'
|
|
8
|
+
attributes[:password] ||= 'abc123'
|
|
9
|
+
attributes[:password_confirmation] ||= attributes[:password]
|
|
10
|
+
<%= user_singular_name %> = <%= user_class_name %>.new(attributes)
|
|
11
|
+
<%= user_singular_name %>.valid? # run validations
|
|
12
|
+
<%= user_singular_name %>
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def setup
|
|
16
|
+
<%= user_class_name %>.delete_all
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_valid
|
|
20
|
+
assert new_<%= user_singular_name %>.valid?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_require_username
|
|
24
|
+
assert new_<%= user_singular_name %>(:username => '').errors.on(:username)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_require_password
|
|
28
|
+
assert new_<%= user_singular_name %>(:password => '').errors.on(:password)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_require_well_formed_email
|
|
32
|
+
assert new_<%= user_singular_name %>(:email => 'foo@bar@example.com').errors.on(:email)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_validate_uniqueness_of_email
|
|
36
|
+
new_<%= user_singular_name %>(:email => 'bar@example.com').save!
|
|
37
|
+
assert new_<%= user_singular_name %>(:email => 'bar@example.com').errors.on(:email)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_validate_uniqueness_of_username
|
|
41
|
+
new_<%= user_singular_name %>(:username => 'uniquename').save!
|
|
42
|
+
assert new_<%= user_singular_name %>(:username => 'uniquename').errors.on(:username)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_validate_odd_characters_in_username
|
|
46
|
+
assert new_<%= user_singular_name %>(:username => 'odd ^&(@)').errors.on(:username)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_validate_password_length
|
|
50
|
+
assert new_<%= user_singular_name %>(:password => 'bad').errors.on(:password)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_require_matching_password_confirmation
|
|
54
|
+
assert new_<%= user_singular_name %>(:password_confirmation => 'nonmatching').errors.on(:password)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_generate_password_hash_and_salt_on_create
|
|
58
|
+
<%= user_singular_name %> = new_<%= user_singular_name %>
|
|
59
|
+
<%= user_singular_name %>.save!
|
|
60
|
+
assert <%= user_singular_name %>.password_hash
|
|
61
|
+
assert <%= user_singular_name %>.password_salt
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_authenticate_by_username
|
|
65
|
+
<%= user_class_name %>.delete_all
|
|
66
|
+
<%= user_singular_name %> = new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret')
|
|
67
|
+
<%= user_singular_name %>.save!
|
|
68
|
+
assert_equal <%= user_singular_name %>, <%= user_class_name %>.authenticate('foobar', 'secret')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_authenticate_by_email
|
|
72
|
+
<%= user_class_name %>.delete_all
|
|
73
|
+
<%= user_singular_name %> = new_<%= user_singular_name %>(:email => 'foo@bar.com', :password => 'secret')
|
|
74
|
+
<%= user_singular_name %>.save!
|
|
75
|
+
assert_equal <%= user_singular_name %>, <%= user_class_name %>.authenticate('foo@bar.com', 'secret')
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_authenticate_bad_username
|
|
79
|
+
assert_nil <%= user_class_name %>.authenticate('nonexisting', 'secret')
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_authenticate_bad_password
|
|
83
|
+
<%= user_class_name %>.delete_all
|
|
84
|
+
new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret').save!
|
|
85
|
+
assert_nil <%= user_class_name %>.authenticate('foobar', 'badpassword')
|
|
86
|
+
end
|
|
87
|
+
<%- end -%>
|
|
88
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class <%= user_plural_class_name %>ControllerTest < ActionController::TestCase
|
|
4
|
+
def test_new
|
|
5
|
+
get :new
|
|
6
|
+
assert_template 'new'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_create_invalid
|
|
10
|
+
<%= user_class_name %>.any_instance.stubs(:valid?).returns(false)
|
|
11
|
+
post :create
|
|
12
|
+
assert_template 'new'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_create_valid
|
|
16
|
+
<%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
|
|
17
|
+
post :create
|
|
18
|
+
assert_redirected_to root_url
|
|
19
|
+
<%- unless options[:authlogic] -%>
|
|
20
|
+
assert_equal assigns['<%= user_singular_name %>'].id, session['<%= user_singular_name %>_id']
|
|
21
|
+
<%- end -%>
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
class <%= user_class_name %> < ActiveRecord::Base
|
|
2
|
+
<%- if options[:authlogic] -%>
|
|
3
|
+
acts_as_authentic
|
|
4
|
+
<%- else -%>
|
|
5
|
+
# new columns need to be added here to be writable through mass assignment
|
|
6
|
+
attr_accessible :username, :email, :password, :password_confirmation
|
|
7
|
+
|
|
8
|
+
attr_accessor :password
|
|
9
|
+
before_save :prepare_password
|
|
10
|
+
|
|
11
|
+
validates_presence_of :username
|
|
12
|
+
validates_uniqueness_of :username, :email, :allow_blank => true
|
|
13
|
+
validates_format_of :username, :with => /^[-\w\._@]+$/i, :allow_blank => true, :message => "should only contain letters, numbers, or .-_@"
|
|
14
|
+
validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
|
|
15
|
+
validates_presence_of :password, :on => :create
|
|
16
|
+
validates_confirmation_of :password
|
|
17
|
+
validates_length_of :password, :minimum => 4, :allow_blank => true
|
|
18
|
+
|
|
19
|
+
# login can be either username or email address
|
|
20
|
+
def self.authenticate(login, pass)
|
|
21
|
+
<%= user_singular_name %> = find_by_username(login) || find_by_email(login)
|
|
22
|
+
return <%= user_singular_name %> if <%= user_singular_name %> && <%= user_singular_name %>.matching_password?(pass)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def matching_password?(pass)
|
|
26
|
+
self.password_hash == encrypt_password(pass)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def prepare_password
|
|
32
|
+
unless password.blank?
|
|
33
|
+
self.password_salt = Digest::SHA1.hexdigest([Time.now, rand].join)
|
|
34
|
+
self.password_hash = encrypt_password(password)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def encrypt_password(pass)
|
|
39
|
+
Digest::SHA1.hexdigest([pass, password_salt].join)
|
|
40
|
+
end
|
|
41
|
+
<%- end -%>
|
|
42
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class <%= user_plural_class_name %>Controller < ApplicationController
|
|
2
|
+
def new
|
|
3
|
+
@<%= user_singular_name %> = <%= user_class_name %>.new
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def create
|
|
7
|
+
@<%= user_singular_name %> = <%= user_class_name %>.new(params[:<%= user_singular_name %>])
|
|
8
|
+
if @<%= user_singular_name %>.save
|
|
9
|
+
<%- unless options[:authlogic] -%>
|
|
10
|
+
session[:<%= user_singular_name %>_id] = @<%= user_singular_name %>.id
|
|
11
|
+
<%- end -%>
|
|
12
|
+
flash[:notice] = "Thank you for signing up! You are now logged in."
|
|
13
|
+
redirect_to root_url
|
|
14
|
+
else
|
|
15
|
+
render :action => 'new'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%% title "Log in" %>
|
|
2
|
+
|
|
3
|
+
<p>Don't have an account? <%%= link_to "Sign up!", signup_path %></p>
|
|
4
|
+
|
|
5
|
+
<%- if options[:authlogic] -%>
|
|
6
|
+
<%% form_for @<%= session_singular_name %> do |f| %>
|
|
7
|
+
<%%= f.error_messages %>
|
|
8
|
+
<p>
|
|
9
|
+
<%%= f.label :username %><br />
|
|
10
|
+
<%%= f.text_field :username %>
|
|
11
|
+
</p>
|
|
12
|
+
<p>
|
|
13
|
+
<%%= f.label :password %><br />
|
|
14
|
+
<%%= f.password_field :password %>
|
|
15
|
+
</p>
|
|
16
|
+
<p><%%= f.submit "Log in" %></p>
|
|
17
|
+
<%% end %>
|
|
18
|
+
<%- else -%>
|
|
19
|
+
<%% form_tag <%= session_plural_name %>_path do %>
|
|
20
|
+
<p>
|
|
21
|
+
<%%= label_tag :login, "Username or Email Address" %><br />
|
|
22
|
+
<%%= text_field_tag :login, params[:login] %>
|
|
23
|
+
</p>
|
|
24
|
+
<p>
|
|
25
|
+
<%%= label_tag :password %><br />
|
|
26
|
+
<%%= password_field_tag :password %>
|
|
27
|
+
</p>
|
|
28
|
+
<p><%%= submit_tag "Log in" %></p>
|
|
29
|
+
<%% end %>
|
|
30
|
+
<%- end -%>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<%% title "Sign up" %>
|
|
2
|
+
|
|
3
|
+
<p>Already have an account? <%%= link_to "Log in", login_path %>.</p>
|
|
4
|
+
|
|
5
|
+
<%% form_for @<%= user_singular_name %> do |f| %>
|
|
6
|
+
<%%= f.error_messages %>
|
|
7
|
+
<p>
|
|
8
|
+
<%%= f.label :username %><br />
|
|
9
|
+
<%%= f.text_field :username %>
|
|
10
|
+
</p>
|
|
11
|
+
<p>
|
|
12
|
+
<%%= f.label :email, "Email Address" %><br />
|
|
13
|
+
<%%= f.text_field :email %>
|
|
14
|
+
</p>
|
|
15
|
+
<p>
|
|
16
|
+
<%%= f.label :password %><br />
|
|
17
|
+
<%%= f.password_field :password %>
|
|
18
|
+
</p>
|
|
19
|
+
<p>
|
|
20
|
+
<%%= f.label :password_confirmation, "Confirm Password" %><br />
|
|
21
|
+
<%%= f.password_field :password_confirmation %>
|
|
22
|
+
</p>
|
|
23
|
+
<p><%%= f.submit "Sign up" %></p>
|
|
24
|
+
<%% end %>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
- title "Log in"
|
|
2
|
+
|
|
3
|
+
%p== Don't have an account? #{link_to "Sign up!", signup_path}
|
|
4
|
+
|
|
5
|
+
<%- if options[:authlogic] -%>
|
|
6
|
+
- form_for @<%= session_singular_name %> do |f|
|
|
7
|
+
= f.error_messages
|
|
8
|
+
%p
|
|
9
|
+
= f.label :username
|
|
10
|
+
%br
|
|
11
|
+
= f.text_field :username
|
|
12
|
+
%p
|
|
13
|
+
= f.label :password
|
|
14
|
+
%br
|
|
15
|
+
= f.password_field :password
|
|
16
|
+
%p
|
|
17
|
+
= f.submit "Log in"
|
|
18
|
+
<%- else -%>
|
|
19
|
+
- form_tag <%= session_plural_name %>_path do
|
|
20
|
+
%p
|
|
21
|
+
= label_tag :login, "Username or Email Address"
|
|
22
|
+
%br
|
|
23
|
+
= text_field_tag :login, params[:login]
|
|
24
|
+
%p
|
|
25
|
+
= label_tag :password
|
|
26
|
+
%br
|
|
27
|
+
= password_field_tag :password
|
|
28
|
+
%p
|
|
29
|
+
= submit_tag "Log in"
|
|
30
|
+
<%- end -%>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
- title "Sign up"
|
|
2
|
+
|
|
3
|
+
%p== Already have an account? #{link_to "Log in", login_path}.
|
|
4
|
+
|
|
5
|
+
- form_for @<%= user_singular_name %> do |f|
|
|
6
|
+
= f.error_messages
|
|
7
|
+
%p
|
|
8
|
+
= f.label :username
|
|
9
|
+
%br
|
|
10
|
+
= f.text_field :username
|
|
11
|
+
%p
|
|
12
|
+
= f.label :email, "Email Address"
|
|
13
|
+
%br
|
|
14
|
+
= f.text_field :email
|
|
15
|
+
%p
|
|
16
|
+
= f.label :password
|
|
17
|
+
%br
|
|
18
|
+
= f.password_field :password
|
|
19
|
+
%p
|
|
20
|
+
= f.label :password_confirmation, "Confirm Password"
|
|
21
|
+
%br
|
|
22
|
+
= f.password_field :password_confirmation
|
|
23
|
+
%p
|
|
24
|
+
= f.submit "Sign up"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
The splendeo_config generator creates YAML file in your config
|
|
3
|
+
directory and an initializer to load this config. The config has a
|
|
4
|
+
separate section for each environment. This is a great place to put
|
|
5
|
+
any config settings you don't want in your app.
|
|
6
|
+
|
|
7
|
+
The config is loaded into a constant called APP_CONFIG by default,
|
|
8
|
+
this changes depending on the name you choose to pass the generator.
|
|
9
|
+
Use this constant to access the config settings like this.
|
|
10
|
+
|
|
11
|
+
APP_CONFIG[:some_setting]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Examples:
|
|
15
|
+
script/generate splendeo_config
|
|
16
|
+
|
|
17
|
+
Config: config/app_config.yml
|
|
18
|
+
Initializer: config/initializers/load_app_config.rb
|
|
19
|
+
|
|
20
|
+
script/generate splendeo_config passwords
|
|
21
|
+
|
|
22
|
+
Config: config/passwords_config.yml
|
|
23
|
+
Initializer: config/initializers/load_passwords_config.rb
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class SplendeoConfigGenerator < Rails::Generator::Base
|
|
2
|
+
def initialize(runtime_args, runtime_options = {})
|
|
3
|
+
super
|
|
4
|
+
@name = @args.first || 'app'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def manifest
|
|
8
|
+
record do |m|
|
|
9
|
+
m.directory 'config/initializers'
|
|
10
|
+
|
|
11
|
+
m.template "load_config.rb", "config/initializers/load_#{file_name}_config.rb"
|
|
12
|
+
m.file "config.yml", "config/#{file_name}_config.yml"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def file_name
|
|
17
|
+
@name.underscore
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def constant_name
|
|
21
|
+
@name.underscore.upcase
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
protected
|
|
25
|
+
def banner
|
|
26
|
+
<<-EOS
|
|
27
|
+
Creates config and loader files.
|
|
28
|
+
|
|
29
|
+
USAGE: #{$0} #{spec.name} [config_name]
|
|
30
|
+
EOS
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
The splendeo_layout generator creates a basic layout, stylesheet and
|
|
3
|
+
helper which will give some structure to a starting Rails app.
|
|
4
|
+
|
|
5
|
+
The generator takes one argument which will be the name of the
|
|
6
|
+
layout and stylesheet files. If no argument is passed then it defaults
|
|
7
|
+
to "application".
|
|
8
|
+
|
|
9
|
+
The helper module includes some methods which can be called in any
|
|
10
|
+
template or partial to set variables to be used in the layout, such as
|
|
11
|
+
page title and javascript/stylesheet includes.
|
|
12
|
+
|
|
13
|
+
Examples:
|
|
14
|
+
script/generate splendeo_layout
|
|
15
|
+
|
|
16
|
+
Layout: app/views/layouts/application.html.erb
|
|
17
|
+
Stylesheet: public/stylesheets/application.css
|
|
18
|
+
Helper: app/helpers/layout_helper.rb
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
script/generate splendeo_layout admin
|
|
22
|
+
|
|
23
|
+
Layout: app/views/layouts/admin.html.erb
|
|
24
|
+
Stylesheet: public/stylesheets/admin.css
|
|
25
|
+
Helper: app/helpers/layout_helper.rb
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
class SplendeoLayoutGenerator < Rails::Generator::Base
|
|
2
|
+
def initialize(runtime_args, runtime_options = {})
|
|
3
|
+
super
|
|
4
|
+
@name = @args.first || 'application'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def manifest
|
|
8
|
+
record do |m|
|
|
9
|
+
m.directory 'app/views/layouts'
|
|
10
|
+
m.directory 'public/stylesheets'
|
|
11
|
+
m.directory 'app/helpers'
|
|
12
|
+
|
|
13
|
+
if options[:haml]
|
|
14
|
+
m.directory 'vendor/plugins/haml'
|
|
15
|
+
m.directory 'public/stylesheets/sass'
|
|
16
|
+
m.directory 'public/stylesheets/sass/blueprint-sass'
|
|
17
|
+
m.directory 'public/stylesheets/sass/blueprint-sass/plugins'
|
|
18
|
+
m.directory 'public/stylesheets/sass/blueprint-sass/plugins/buttons'
|
|
19
|
+
m.directory 'public/stylesheets/sass/blueprint-sass/plugins/fancy-type'
|
|
20
|
+
m.directory 'public/stylesheets/sass/blueprint-sass/plugins/link-icons'
|
|
21
|
+
m.directory 'public/stylesheets/sass/blueprint-sass/plugins/rtl'
|
|
22
|
+
|
|
23
|
+
m.file 'haml/init.rb', 'vendor/plugins/haml/init.rb'
|
|
24
|
+
m.file 'blueprint-sass/ie.sass', 'public/stylesheets/sass/blueprint-sass/ie.sass'
|
|
25
|
+
m.file 'blueprint-sass/print.sass', 'public/stylesheets/sass/blueprint-sass/print.sass'
|
|
26
|
+
m.file 'blueprint-sass/screen.sass', 'public/stylesheets/sass/blueprint-sass/screen.sass'
|
|
27
|
+
m.file 'blueprint-sass/plugins/buttons/screen.sass', 'public/stylesheets/sass/blueprint-sass/plugins/buttons/screen.sass'
|
|
28
|
+
m.file 'blueprint-sass/plugins/fancy-type/screen.sass', 'public/stylesheets/sass/blueprint-sass/plugins/fancy-type/screen.sass'
|
|
29
|
+
m.file 'blueprint-sass/plugins/link-icons/screen.sass', 'public/stylesheets/sass/blueprint-sass/plugins/link-icons/screen.sass'
|
|
30
|
+
m.file 'blueprint-sass/plugins/rtl/screen.sass', 'public/stylesheets/sass/blueprint-sass/plugins/rtl/screen.sass'
|
|
31
|
+
|
|
32
|
+
m.template "layout.html.haml", "app/views/layouts/#{file_name}.html.haml"
|
|
33
|
+
m.file "stylesheet.sass", "public/stylesheets/sass/#{file_name}.sass"
|
|
34
|
+
else
|
|
35
|
+
m.directory 'public/stylesheets/blueprint'
|
|
36
|
+
m.directory 'public/stylesheets/blueprint/plugins'
|
|
37
|
+
m.directory 'public/stylesheets/blueprint/plugins/buttons'
|
|
38
|
+
m.directory 'public/stylesheets/blueprint/plugins/fancy-type'
|
|
39
|
+
m.directory 'public/stylesheets/blueprint/plugins/link-icons'
|
|
40
|
+
m.directory 'public/stylesheets/blueprint/plugins/rtl'
|
|
41
|
+
|
|
42
|
+
m.file 'blueprint/ie.css', 'public/stylesheets/blueprint/ie.css'
|
|
43
|
+
m.file 'blueprint/print.css', 'public/stylesheets/blueprint/print.css'
|
|
44
|
+
m.file 'blueprint/screen.css', 'public/stylesheets/blueprint/screen.css'
|
|
45
|
+
m.file 'blueprint/plugins/buttons/screen.css', 'public/stylesheets/blueprint/plugins/buttons/screen.css'
|
|
46
|
+
m.file 'blueprint/plugins/fancy-type/screen.css', 'public/stylesheets/blueprint/plugins/fancy-type/screen.css'
|
|
47
|
+
m.file 'blueprint/plugins/link-icons/screen.css', 'public/stylesheets/blueprint/plugins/link-icons/screen.css'
|
|
48
|
+
m.file 'blueprint/plugins/rtl/screen.css', 'public/stylesheets/blueprint/plugins/rtl/screen.css'
|
|
49
|
+
|
|
50
|
+
m.template "layout.html.erb", "app/views/layouts/#{file_name}.html.erb"
|
|
51
|
+
m.file "stylesheet.css", "public/stylesheets/#{file_name}.css"
|
|
52
|
+
end
|
|
53
|
+
m.file "helper.rb", "app/helpers/layout_helper.rb"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def file_name
|
|
58
|
+
@name.underscore
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
protected
|
|
62
|
+
|
|
63
|
+
def add_options!(opt)
|
|
64
|
+
opt.separator ''
|
|
65
|
+
opt.separator 'Options:'
|
|
66
|
+
opt.on("--haml", "Generate HAML for view, and SASS for stylesheet.") { |v| options[:haml] = v }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def banner
|
|
70
|
+
<<-EOS
|
|
71
|
+
Creates generic layout, stylesheet, and helper files.
|
|
72
|
+
|
|
73
|
+
USAGE: #{$0} #{spec.name} [layout_name]
|
|
74
|
+
EOS
|
|
75
|
+
end
|
|
76
|
+
end
|