flexi_generators 0.2.10 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -16
- data/flexi_generators.gemspec +17 -114
- data/lib/flexi_generators.rb +11 -0
- data/lib/generators/flexi/config/config_generator.rb +25 -0
- data/lib/generators/flexi/config/templates/field_error.rb +9 -0
- data/lib/generators/flexi/config/templates/inflector_portuguese.rb +62 -0
- data/lib/generators/flexi/config/templates/pt-BR.yml +224 -0
- data/lib/generators/flexi/config/templates/will_paginate.rb +26 -0
- data/lib/generators/flexi/install/install_generator.rb +28 -0
- data/lib/generators/flexi/install/templates/application.css +15 -0
- data/lib/generators/flexi/install/templates/application.js +16 -0
- data/lib/generators/flexi/layout/layout_generator.rb +46 -0
- data/lib/generators/flexi/layout/templates/_flash.html.erb +4 -0
- data/lib/generators/flexi/layout/templates/_navbar.html.erb +6 -0
- data/lib/generators/flexi/layout/templates/_sidebar.html.erb +16 -0
- data/lib/generators/flexi/layout/templates/_user_dropdown.html.erb +11 -0
- data/lib/generators/flexi/layout/templates/application.css +16 -0
- data/lib/generators/flexi/layout/templates/dashboard.html.erb +49 -0
- data/lib/generators/flexi/layout/templates/error_messages_helper.rb +33 -0
- data/lib/generators/flexi/layout/templates/layout.css +8 -0
- data/lib/generators/flexi/layout/templates/layout.html.erb +76 -0
- data/lib/generators/flexi/layout/templates/layout_helper.rb +47 -0
- data/lib/generators/flexi/scaffold/scaffold_generator.rb +24 -109
- data/lib/generators/flexi/scaffold/templates/_form.html.erb +22 -0
- data/lib/generators/flexi/scaffold/templates/edit.html.erb +1 -0
- data/lib/generators/flexi/scaffold/templates/index.html.erb +36 -0
- data/lib/generators/flexi/scaffold/templates/new.html.erb +1 -0
- data/lib/generators/flexi/scaffold/templates/show.html.erb +21 -0
- data/lib/twitter-bootstrap/engine.rb +6 -0
- data/lib/twitter-bootstrap/railtie.rb +6 -0
- data/lib/twitter-bootstrap/version.rb +5 -0
- data/lib/version.rb +3 -0
- data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/bootstrap.js +1825 -0
- data/vendor/assets/stylesheets/bootstrap-responsive.css +815 -0
- data/vendor/assets/stylesheets/bootstrap.css +4983 -0
- metadata +51 -89
- data/README.textile +0 -64
- data/VERSION +0 -1
- data/lib/generators/flexi.rb +0 -16
- data/lib/generators/flexi/auth/USAGE +0 -5
- data/lib/generators/flexi/auth/auth_generator.rb +0 -122
- data/lib/generators/flexi/auth/templates/authentication.rb +0 -55
- data/lib/generators/flexi/auth/templates/authlogic_session.rb +0 -2
- data/lib/generators/flexi/auth/templates/fixtures.yml +0 -24
- data/lib/generators/flexi/auth/templates/migration.rb +0 -16
- data/lib/generators/flexi/auth/templates/sessions_controller.rb +0 -26
- data/lib/generators/flexi/auth/templates/sessions_helper.rb +0 -2
- data/lib/generators/flexi/auth/templates/tests/testunit/sessions_controller.rb +0 -20
- data/lib/generators/flexi/auth/templates/tests/testunit/user.rb +0 -4
- data/lib/generators/flexi/auth/templates/tests/testunit/users_controller.rb +0 -23
- data/lib/generators/flexi/auth/templates/user.rb +0 -3
- data/lib/generators/flexi/auth/templates/users_controller.rb +0 -43
- data/lib/generators/flexi/auth/templates/users_helper.rb +0 -2
- data/lib/generators/flexi/auth/templates/views/erb/_error_messages.html.erb +0 -11
- data/lib/generators/flexi/auth/templates/views/erb/_menu.html.erb +0 -16
- data/lib/generators/flexi/auth/templates/views/erb/application.html.erb +0 -39
- data/lib/generators/flexi/auth/templates/views/erb/edit.html.erb +0 -24
- data/lib/generators/flexi/auth/templates/views/erb/index.html.erb +0 -27
- data/lib/generators/flexi/auth/templates/views/erb/login.html.erb +0 -22
- data/lib/generators/flexi/auth/templates/views/erb/new.html.erb +0 -24
- data/lib/generators/flexi/auth/templates/views/erb/show.html.erb +0 -16
- data/lib/generators/flexi/prepare/USAGE +0 -6
- data/lib/generators/flexi/prepare/prepare_generator.rb +0 -68
- data/lib/generators/flexi/prepare/templates/add.png +0 -0
- data/lib/generators/flexi/prepare/templates/admin_home_controller.rb +0 -6
- data/lib/generators/flexi/prepare/templates/admin_home_index.html.erb +0 -16
- data/lib/generators/flexi/prepare/templates/application.css +0 -279
- data/lib/generators/flexi/prepare/templates/application_helper.rb +0 -44
- data/lib/generators/flexi/prepare/templates/back.png +0 -0
- data/lib/generators/flexi/prepare/templates/bg.png +0 -0
- data/lib/generators/flexi/prepare/templates/bg2.png +0 -0
- data/lib/generators/flexi/prepare/templates/boxheader.gif +0 -0
- data/lib/generators/flexi/prepare/templates/btn-bg-hover.png +0 -0
- data/lib/generators/flexi/prepare/templates/btn-bg.png +0 -0
- data/lib/generators/flexi/prepare/templates/custom_field_error.rb +0 -12
- data/lib/generators/flexi/prepare/templates/delete.png +0 -0
- data/lib/generators/flexi/prepare/templates/edit.png +0 -0
- data/lib/generators/flexi/prepare/templates/inflector_portuguese.rb +0 -60
- data/lib/generators/flexi/prepare/templates/login.css +0 -142
- data/lib/generators/flexi/prepare/templates/login.html.erb +0 -26
- data/lib/generators/flexi/prepare/templates/logo.png +0 -0
- data/lib/generators/flexi/prepare/templates/menu.png +0 -0
- data/lib/generators/flexi/prepare/templates/messages/Thumbs.db +0 -0
- data/lib/generators/flexi/prepare/templates/messages/error.png +0 -0
- data/lib/generators/flexi/prepare/templates/messages/info.png +0 -0
- data/lib/generators/flexi/prepare/templates/messages/success.png +0 -0
- data/lib/generators/flexi/prepare/templates/messages/tip.png +0 -0
- data/lib/generators/flexi/prepare/templates/messages/warning.png +0 -0
- data/lib/generators/flexi/prepare/templates/pt-BR.yml +0 -206
- data/lib/generators/flexi/prepare/templates/routes.rb +0 -3
- data/lib/generators/flexi/prepare/templates/show.png +0 -0
- data/lib/generators/flexi/prepare/templates/site.css +0 -72
- data/lib/generators/flexi/prepare/templates/site.html.erb +0 -20
- data/lib/generators/flexi/prepare/templates/site_controller.rb +0 -9
- data/lib/generators/flexi/prepare/templates/site_helper.rb +0 -2
- data/lib/generators/flexi/prepare/templates/site_index.html.erb +0 -27
- data/lib/generators/flexi/prepare/templates/users.png +0 -0
- data/lib/generators/flexi/scaffold/USAGE +0 -5
- data/lib/generators/flexi/scaffold/templates/controller.rb +0 -43
- data/lib/generators/flexi/scaffold/templates/fixtures.yml +0 -9
- data/lib/generators/flexi/scaffold/templates/helper.rb +0 -2
- data/lib/generators/flexi/scaffold/templates/migration.rb +0 -14
- data/lib/generators/flexi/scaffold/templates/model.rb +0 -3
- data/lib/generators/flexi/scaffold/templates/tests/controller.rb +0 -50
- data/lib/generators/flexi/scaffold/templates/tests/helper.rb +0 -4
- data/lib/generators/flexi/scaffold/templates/tests/model.rb +0 -8
- data/lib/generators/flexi/scaffold/templates/views/erb/_error_messages.html.erb +0 -11
- data/lib/generators/flexi/scaffold/templates/views/erb/_form.html.erb +0 -13
- data/lib/generators/flexi/scaffold/templates/views/erb/edit.html.erb +0 -3
- data/lib/generators/flexi/scaffold/templates/views/erb/index.html.erb +0 -29
- data/lib/generators/flexi/scaffold/templates/views/erb/new.html.erb +0 -3
- data/lib/generators/flexi/scaffold/templates/views/erb/show.html.erb +0 -15
- data/template.rb +0 -15
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexi_generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Leandro de Oliveira
|
@@ -15,99 +15,61 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-06-13 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
|
-
description:
|
22
|
-
email:
|
21
|
+
description: "Rails generators scripts for scaffolding and layout files containing Twitter\xE2\x80\x99s Bootstrap CSS"
|
22
|
+
email:
|
23
|
+
- ol.leandro@gmail.com
|
23
24
|
executables: []
|
24
25
|
|
25
26
|
extensions: []
|
26
27
|
|
27
|
-
extra_rdoc_files:
|
28
|
-
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
29
30
|
files:
|
30
|
-
-
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- LICENSE
|
34
|
+
- README.md
|
31
35
|
- Rakefile
|
32
|
-
- VERSION
|
33
36
|
- flexi_generators.gemspec
|
34
|
-
- lib/
|
35
|
-
- lib/generators/flexi/
|
36
|
-
- lib/generators/flexi/
|
37
|
-
- lib/generators/flexi/
|
38
|
-
- lib/generators/flexi/
|
39
|
-
- lib/generators/flexi/
|
40
|
-
- lib/generators/flexi/
|
41
|
-
- lib/generators/flexi/
|
42
|
-
- lib/generators/flexi/
|
43
|
-
- lib/generators/flexi/
|
44
|
-
- lib/generators/flexi/
|
45
|
-
- lib/generators/flexi/
|
46
|
-
- lib/generators/flexi/
|
47
|
-
- lib/generators/flexi/
|
48
|
-
- lib/generators/flexi/
|
49
|
-
- lib/generators/flexi/
|
50
|
-
- lib/generators/flexi/
|
51
|
-
- lib/generators/flexi/
|
52
|
-
- lib/generators/flexi/
|
53
|
-
- lib/generators/flexi/
|
54
|
-
- lib/generators/flexi/auth/templates/views/erb/login.html.erb
|
55
|
-
- lib/generators/flexi/auth/templates/views/erb/new.html.erb
|
56
|
-
- lib/generators/flexi/auth/templates/views/erb/show.html.erb
|
57
|
-
- lib/generators/flexi/prepare/USAGE
|
58
|
-
- lib/generators/flexi/prepare/prepare_generator.rb
|
59
|
-
- lib/generators/flexi/prepare/templates/add.png
|
60
|
-
- lib/generators/flexi/prepare/templates/admin_home_controller.rb
|
61
|
-
- lib/generators/flexi/prepare/templates/admin_home_index.html.erb
|
62
|
-
- lib/generators/flexi/prepare/templates/application.css
|
63
|
-
- lib/generators/flexi/prepare/templates/application_helper.rb
|
64
|
-
- lib/generators/flexi/prepare/templates/back.png
|
65
|
-
- lib/generators/flexi/prepare/templates/bg.png
|
66
|
-
- lib/generators/flexi/prepare/templates/bg2.png
|
67
|
-
- lib/generators/flexi/prepare/templates/boxheader.gif
|
68
|
-
- lib/generators/flexi/prepare/templates/btn-bg-hover.png
|
69
|
-
- lib/generators/flexi/prepare/templates/btn-bg.png
|
70
|
-
- lib/generators/flexi/prepare/templates/custom_field_error.rb
|
71
|
-
- lib/generators/flexi/prepare/templates/delete.png
|
72
|
-
- lib/generators/flexi/prepare/templates/edit.png
|
73
|
-
- lib/generators/flexi/prepare/templates/inflector_portuguese.rb
|
74
|
-
- lib/generators/flexi/prepare/templates/login.css
|
75
|
-
- lib/generators/flexi/prepare/templates/login.html.erb
|
76
|
-
- lib/generators/flexi/prepare/templates/logo.png
|
77
|
-
- lib/generators/flexi/prepare/templates/menu.png
|
78
|
-
- lib/generators/flexi/prepare/templates/messages/Thumbs.db
|
79
|
-
- lib/generators/flexi/prepare/templates/messages/error.png
|
80
|
-
- lib/generators/flexi/prepare/templates/messages/info.png
|
81
|
-
- lib/generators/flexi/prepare/templates/messages/success.png
|
82
|
-
- lib/generators/flexi/prepare/templates/messages/tip.png
|
83
|
-
- lib/generators/flexi/prepare/templates/messages/warning.png
|
84
|
-
- lib/generators/flexi/prepare/templates/pt-BR.yml
|
85
|
-
- lib/generators/flexi/prepare/templates/routes.rb
|
86
|
-
- lib/generators/flexi/prepare/templates/show.png
|
87
|
-
- lib/generators/flexi/prepare/templates/site.css
|
88
|
-
- lib/generators/flexi/prepare/templates/site.html.erb
|
89
|
-
- lib/generators/flexi/prepare/templates/site_controller.rb
|
90
|
-
- lib/generators/flexi/prepare/templates/site_helper.rb
|
91
|
-
- lib/generators/flexi/prepare/templates/site_index.html.erb
|
92
|
-
- lib/generators/flexi/prepare/templates/users.png
|
93
|
-
- lib/generators/flexi/scaffold/USAGE
|
37
|
+
- lib/flexi_generators.rb
|
38
|
+
- lib/generators/flexi/config/config_generator.rb
|
39
|
+
- lib/generators/flexi/config/templates/field_error.rb
|
40
|
+
- lib/generators/flexi/config/templates/inflector_portuguese.rb
|
41
|
+
- lib/generators/flexi/config/templates/pt-BR.yml
|
42
|
+
- lib/generators/flexi/config/templates/will_paginate.rb
|
43
|
+
- lib/generators/flexi/install/install_generator.rb
|
44
|
+
- lib/generators/flexi/install/templates/application.css
|
45
|
+
- lib/generators/flexi/install/templates/application.js
|
46
|
+
- lib/generators/flexi/layout/layout_generator.rb
|
47
|
+
- lib/generators/flexi/layout/templates/_flash.html.erb
|
48
|
+
- lib/generators/flexi/layout/templates/_navbar.html.erb
|
49
|
+
- lib/generators/flexi/layout/templates/_sidebar.html.erb
|
50
|
+
- lib/generators/flexi/layout/templates/_user_dropdown.html.erb
|
51
|
+
- lib/generators/flexi/layout/templates/application.css
|
52
|
+
- lib/generators/flexi/layout/templates/dashboard.html.erb
|
53
|
+
- lib/generators/flexi/layout/templates/error_messages_helper.rb
|
54
|
+
- lib/generators/flexi/layout/templates/layout.css
|
55
|
+
- lib/generators/flexi/layout/templates/layout.html.erb
|
56
|
+
- lib/generators/flexi/layout/templates/layout_helper.rb
|
94
57
|
- lib/generators/flexi/scaffold/scaffold_generator.rb
|
95
|
-
- lib/generators/flexi/scaffold/templates/
|
96
|
-
- lib/generators/flexi/scaffold/templates/
|
97
|
-
- lib/generators/flexi/scaffold/templates/
|
98
|
-
- lib/generators/flexi/scaffold/templates/
|
99
|
-
- lib/generators/flexi/scaffold/templates/
|
100
|
-
- lib/
|
101
|
-
- lib/
|
102
|
-
- lib/
|
103
|
-
- lib/
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
109
|
-
|
110
|
-
homepage: http://github.com/leandroo/flexi_generators
|
58
|
+
- lib/generators/flexi/scaffold/templates/_form.html.erb
|
59
|
+
- lib/generators/flexi/scaffold/templates/edit.html.erb
|
60
|
+
- lib/generators/flexi/scaffold/templates/index.html.erb
|
61
|
+
- lib/generators/flexi/scaffold/templates/new.html.erb
|
62
|
+
- lib/generators/flexi/scaffold/templates/show.html.erb
|
63
|
+
- lib/twitter-bootstrap/engine.rb
|
64
|
+
- lib/twitter-bootstrap/railtie.rb
|
65
|
+
- lib/twitter-bootstrap/version.rb
|
66
|
+
- lib/version.rb
|
67
|
+
- vendor/assets/images/glyphicons-halflings-white.png
|
68
|
+
- vendor/assets/images/glyphicons-halflings.png
|
69
|
+
- vendor/assets/javascripts/bootstrap.js
|
70
|
+
- vendor/assets/stylesheets/bootstrap-responsive.css
|
71
|
+
- vendor/assets/stylesheets/bootstrap.css
|
72
|
+
homepage: https://github.com/leandroo/flexi_generators
|
111
73
|
licenses: []
|
112
74
|
|
113
75
|
post_install_message:
|
@@ -136,9 +98,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
98
|
requirements: []
|
137
99
|
|
138
100
|
rubyforge_project:
|
139
|
-
rubygems_version: 1.
|
101
|
+
rubygems_version: 1.8.17
|
140
102
|
signing_key:
|
141
103
|
specification_version: 3
|
142
|
-
summary:
|
104
|
+
summary: ""
|
143
105
|
test_files: []
|
144
106
|
|
data/README.textile
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
h1. Flexi Generators
|
2
|
-
|
3
|
-
My Rails generator scripts. Generates controllers, views, layouts and stylesheets with:
|
4
|
-
|
5
|
-
* Login layout
|
6
|
-
* App layout
|
7
|
-
* Menus with Menu Builder plugin
|
8
|
-
* Pagination with Will Paginate plugin
|
9
|
-
|
10
|
-
h2. Instalation
|
11
|
-
|
12
|
-
Rail2
|
13
|
-
|
14
|
-
For more details about configuration in Rails 2 look "here":http://github.com/leandroo/flexi_generators/tree/v0.1.0
|
15
|
-
|
16
|
-
Rails3
|
17
|
-
|
18
|
-
<pre>
|
19
|
-
gem "flexi_generators"
|
20
|
-
</pre>
|
21
|
-
|
22
|
-
h2. Included Generators
|
23
|
-
|
24
|
-
* flexi_prepare: generates initial files anda configurations.
|
25
|
-
* flexi_auth: generates user model with sign up and log in.
|
26
|
-
* flexi_scaffold: generates custom scaffold.
|
27
|
-
|
28
|
-
h2. Quickstart Rails 3
|
29
|
-
|
30
|
-
These 4 simple steps are the essentials to get you smoothly up and running…
|
31
|
-
|
32
|
-
1. Create your app and configure all dependencies
|
33
|
-
@rails new appname -m http://leandroo.com.br/flexi_generators/template.rb@
|
34
|
-
2. Run @bundle install@, @rake db:migrate@ and @rake db:seed@ to installs all required gems and create your database
|
35
|
-
3. Start your server with @rails server@
|
36
|
-
4. Open up "http://localhost:3000":http://localhost:3000
|
37
|
-
|
38
|
-
h2. Usage
|
39
|
-
|
40
|
-
<pre>
|
41
|
-
rails g flexi_prepare
|
42
|
-
...
|
43
|
-
rails g flexi_auth
|
44
|
-
...
|
45
|
-
rails g flexi_scaffold Post title:string body:text
|
46
|
-
</pre>
|
47
|
-
|
48
|
-
h2. Screenshots
|
49
|
-
|
50
|
-
!http://img697.imageshack.us/img697/1245/flexigenerators.jpg(Flexi)!
|
51
|
-
|
52
|
-
h2. TODO
|
53
|
-
|
54
|
-
* i18n
|
55
|
-
* Tests, tests, tests
|
56
|
-
|
57
|
-
h2. Autor
|
58
|
-
|
59
|
-
*Leandro de Oliveira*
|
60
|
-
|
61
|
-
Blog: "http://leandroo.com.br":http://leandroo.com.br
|
62
|
-
Github: "http://github.com/leandroo":http://github.com/leandroo
|
63
|
-
|
64
|
-
Copyright (c) 2009 Leandro de Oliveira, released under the MIT license
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.10
|
data/lib/generators/flexi.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'rails/generators/base'
|
2
|
-
|
3
|
-
module Flexi
|
4
|
-
module Generators
|
5
|
-
class Base < Rails::Generators::Base #:nodoc:
|
6
|
-
def self.source_root
|
7
|
-
@_flexi_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'flexi', generator_name, 'templates'))
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.banner
|
11
|
-
"#{$0} flexi:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'generators/flexi'
|
2
|
-
require 'rails/generators/migration'
|
3
|
-
|
4
|
-
module Flexi
|
5
|
-
module Generators
|
6
|
-
class AuthGenerator < Base
|
7
|
-
include Rails::Generators::Migration
|
8
|
-
|
9
|
-
argument :user_name, :type => :string, :default => 'user', :banner => 'user_name'
|
10
|
-
argument :session_name, :type => :string, :default => "user_session", :banner => 'sessions_controller_name'
|
11
|
-
|
12
|
-
def generate_auth
|
13
|
-
gem 'authlogic', :git => 'git://github.com/binarylogic/authlogic.git'
|
14
|
-
end
|
15
|
-
|
16
|
-
def create_model_files
|
17
|
-
template 'user.rb', "app/models/#{user_singular_name}.rb"
|
18
|
-
template 'authlogic_session.rb', "app/models/#{user_singular_name}_session.rb"
|
19
|
-
end
|
20
|
-
|
21
|
-
def create_controller_files
|
22
|
-
template 'users_controller.rb', "app/controllers/admin/#{user_plural_name}_controller.rb"
|
23
|
-
template 'sessions_controller.rb', "app/controllers/#{session_plural_name}_controller.rb"
|
24
|
-
end
|
25
|
-
|
26
|
-
def create_helper_files
|
27
|
-
template 'users_helper.rb', "app/helpers/#{user_plural_name}_helper.rb"
|
28
|
-
template 'sessions_helper.rb', "app/helpers/#{session_plural_name}_helper.rb"
|
29
|
-
end
|
30
|
-
|
31
|
-
def create_view_files
|
32
|
-
template "views/erb/login.html.erb", "app/views/#{session_plural_name}/new.html.erb"
|
33
|
-
template "views/erb/index.html.erb", "app/views/admin/#{user_plural_name}/index.html.erb"
|
34
|
-
template "views/erb/show.html.erb", "app/views/admin/#{user_plural_name}/show.html.erb"
|
35
|
-
template "views/erb/new.html.erb", "app/views/admin/#{user_plural_name}/new.html.erb"
|
36
|
-
template "views/erb/_error_messages.html.erb", "app/views/shared/_error_messages.html.erb"
|
37
|
-
template "views/erb/edit.html.erb", "app/views/admin/#{user_plural_name}/edit.html.erb"
|
38
|
-
template "views/erb/application.html.erb", "app/views/layouts/application.html.erb"
|
39
|
-
template "views/erb/_menu.html.erb", "app/views/layouts/_menu.html.erb"
|
40
|
-
end
|
41
|
-
|
42
|
-
def create_lib_files
|
43
|
-
template 'authentication.rb', 'config/initializers/authentication.rb'
|
44
|
-
end
|
45
|
-
|
46
|
-
def create_routes
|
47
|
-
route "match 'admin' => '#{session_plural_name}#new'"
|
48
|
-
route "match 'login' => '#{session_plural_name}#new', :as => :login"
|
49
|
-
route "match 'logout' => '#{session_plural_name}#destroy', :as => :logout"
|
50
|
-
route "resources #{session_plural_name.to_sym.inspect}"
|
51
|
-
inject_into_file "config/routes.rb", "\n\tresources #{user_plural_name.to_sym.inspect}", :after => 'match "home" => "home#index"'
|
52
|
-
end
|
53
|
-
|
54
|
-
def create_include_line
|
55
|
-
inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " before_filter :login_required\n"
|
56
|
-
inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " include Authentication\n"
|
57
|
-
end
|
58
|
-
|
59
|
-
def create_test_files
|
60
|
-
template 'fixtures.yml', "test/fixtures/#{user_plural_name}.yml"
|
61
|
-
template "tests/testunit/user.rb", "test/unit/#{user_singular_name}_test.rb"
|
62
|
-
template "tests/testunit/users_controller.rb", "test/functional/#{user_plural_name}_controller_test.rb"
|
63
|
-
template "tests/testunit/sessions_controller.rb", "test/functional/#{session_plural_name}_controller_test.rb"
|
64
|
-
end
|
65
|
-
|
66
|
-
def create_migration
|
67
|
-
migration_template 'migration.rb', "db/migrate/create_#{user_plural_name}.rb"
|
68
|
-
end
|
69
|
-
|
70
|
-
def create_seed
|
71
|
-
append_file "db/seeds.rb","#{user_class_name}.create(:username => 'admin', :password => 'admin123', :password_confirmation => 'admin123', :email => 'admin@example.com')"
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
def session_name
|
77
|
-
user_name + '_session'
|
78
|
-
end
|
79
|
-
|
80
|
-
def user_singular_name
|
81
|
-
user_name.underscore
|
82
|
-
end
|
83
|
-
|
84
|
-
def user_plural_name
|
85
|
-
user_singular_name.pluralize
|
86
|
-
end
|
87
|
-
|
88
|
-
def user_class_name
|
89
|
-
user_name.camelize
|
90
|
-
end
|
91
|
-
|
92
|
-
def user_plural_class_name
|
93
|
-
user_plural_name.camelize
|
94
|
-
end
|
95
|
-
|
96
|
-
def session_singular_name
|
97
|
-
session_name.underscore
|
98
|
-
end
|
99
|
-
|
100
|
-
def session_plural_name
|
101
|
-
session_singular_name.pluralize
|
102
|
-
end
|
103
|
-
|
104
|
-
def session_class_name
|
105
|
-
session_name.camelize
|
106
|
-
end
|
107
|
-
|
108
|
-
def session_plural_class_name
|
109
|
-
session_plural_name.camelize
|
110
|
-
end
|
111
|
-
|
112
|
-
def self.next_migration_number(dirname) #:nodoc:
|
113
|
-
if ActiveRecord::Base.timestamped_migrations
|
114
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
115
|
-
else
|
116
|
-
"%.3d" % (current_migration_number(dirname) + 1)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This module is included in your application controller which makes
|
3
|
-
# several methods available to all controllers and views. Here's a
|
4
|
-
# common example you might add to your application layout file.
|
5
|
-
#
|
6
|
-
# <%% if logged_in? %>
|
7
|
-
# Welcome <%%= current_<%= user_singular_name %>.username %>! Not you?
|
8
|
-
# <%%= link_to "Log out", logout_path %>
|
9
|
-
# <%% else %>
|
10
|
-
# <%%= link_to "Sign up", signup_path %> or
|
11
|
-
# <%%= link_to "log in", login_path %>.
|
12
|
-
# <%% end %>
|
13
|
-
#
|
14
|
-
# You can also restrict unregistered users from accessing a controller using
|
15
|
-
# a before filter. For example.
|
16
|
-
#
|
17
|
-
# before_filter :login_required, :except => [:index, :show]
|
18
|
-
module Authentication
|
19
|
-
def self.included(controller)
|
20
|
-
controller.send :helper_method, :current_<%= user_singular_name %>, :logged_in?, :redirect_to_target_or_default
|
21
|
-
end
|
22
|
-
|
23
|
-
def current_<%= session_singular_name %>
|
24
|
-
return @current_<%= session_singular_name %> if defined?(@current_<%= session_singular_name %>)
|
25
|
-
@current_<%= session_singular_name %> = <%= session_class_name %>.find
|
26
|
-
end
|
27
|
-
|
28
|
-
def current_<%= user_singular_name %>
|
29
|
-
return @current_<%= user_singular_name %> if defined?(@current_<%= user_singular_name %>)
|
30
|
-
@current_<%= user_singular_name %> = current_<%= session_singular_name %> && current_<%= session_singular_name %>.record
|
31
|
-
end
|
32
|
-
|
33
|
-
def logged_in?
|
34
|
-
current_<%= user_singular_name %>
|
35
|
-
end
|
36
|
-
|
37
|
-
def login_required
|
38
|
-
unless logged_in?
|
39
|
-
flash[:error] = "Você precisa estar logado para poder acessar esta página."
|
40
|
-
store_target_location
|
41
|
-
redirect_to login_url
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def redirect_to_target_or_default(default)
|
46
|
-
redirect_to(session[:return_to] || default)
|
47
|
-
session[:return_to] = nil
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def store_target_location
|
53
|
-
session[:return_to] = request.request_uri
|
54
|
-
end
|
55
|
-
end
|