lockdown 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/History.txt +8 -0
  2. data/Manifest.txt +0 -36
  3. data/lib/lockdown/controller.rb +2 -2
  4. data/lib/lockdown/version.rb +1 -1
  5. data/rails_generators/lockdown/lockdown_generator.rb +56 -57
  6. data/website/generator.html +1 -1
  7. data/website/index.html +1 -1
  8. metadata +2 -38
  9. data/app_generators/lockdown/lockdown_generator.rb.orig +0 -69
  10. data/rails_generators/lockdown_all/USAGE +0 -5
  11. data/rails_generators/lockdown_all/lockdown_all_generator.rb +0 -190
  12. data/rails_generators/lockdown_all/templates/app/controllers/permissions_controller.rb +0 -22
  13. data/rails_generators/lockdown_all/templates/app/controllers/sessions_controller.rb +0 -38
  14. data/rails_generators/lockdown_all/templates/app/controllers/user_groups_controller.rb +0 -113
  15. data/rails_generators/lockdown_all/templates/app/controllers/users_controller.rb +0 -124
  16. data/rails_generators/lockdown_all/templates/app/helpers/permissions_helper.rb +0 -13
  17. data/rails_generators/lockdown_all/templates/app/helpers/user_groups_helper.rb +0 -35
  18. data/rails_generators/lockdown_all/templates/app/helpers/users_helper.rb +0 -78
  19. data/rails_generators/lockdown_all/templates/app/models/permission.rb +0 -13
  20. data/rails_generators/lockdown_all/templates/app/models/profile.rb +0 -10
  21. data/rails_generators/lockdown_all/templates/app/models/user.rb +0 -72
  22. data/rails_generators/lockdown_all/templates/app/models/user_group.rb +0 -15
  23. data/rails_generators/lockdown_all/templates/app/views/permissions/_data.html.erb +0 -13
  24. data/rails_generators/lockdown_all/templates/app/views/permissions/index.html.erb +0 -16
  25. data/rails_generators/lockdown_all/templates/app/views/permissions/show.html.erb +0 -3
  26. data/rails_generators/lockdown_all/templates/app/views/sessions/new.html.erb +0 -12
  27. data/rails_generators/lockdown_all/templates/app/views/user_groups/_data.html.erb +0 -44
  28. data/rails_generators/lockdown_all/templates/app/views/user_groups/_form.html.erb +0 -11
  29. data/rails_generators/lockdown_all/templates/app/views/user_groups/edit.html.erb +0 -6
  30. data/rails_generators/lockdown_all/templates/app/views/user_groups/index.html.erb +0 -20
  31. data/rails_generators/lockdown_all/templates/app/views/user_groups/new.html.erb +0 -5
  32. data/rails_generators/lockdown_all/templates/app/views/user_groups/show.html.erb +0 -6
  33. data/rails_generators/lockdown_all/templates/app/views/users/_data.html.erb +0 -62
  34. data/rails_generators/lockdown_all/templates/app/views/users/_form.html.erb +0 -18
  35. data/rails_generators/lockdown_all/templates/app/views/users/_password.html.erb +0 -5
  36. data/rails_generators/lockdown_all/templates/app/views/users/edit.html.erb +0 -6
  37. data/rails_generators/lockdown_all/templates/app/views/users/index.html.erb +0 -22
  38. data/rails_generators/lockdown_all/templates/app/views/users/new.html.erb +0 -5
  39. data/rails_generators/lockdown_all/templates/app/views/users/show.html.erb +0 -4
  40. data/rails_generators/lockdown_all/templates/db/migrate/create_admin_user_and_user_group.rb +0 -19
  41. data/rails_generators/lockdown_all/templates/db/migrate/create_permissions.rb +0 -19
  42. data/rails_generators/lockdown_all/templates/db/migrate/create_profiles.rb +0 -26
  43. data/rails_generators/lockdown_all/templates/db/migrate/create_user_groups.rb +0 -19
  44. data/rails_generators/lockdown_all/templates/db/migrate/create_users.rb +0 -17
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.5.1 2008-05-25
2
+ * Fixed: bug with namespaced access having identical standard access. e.g. /users and /admin/users
3
+
4
+ == 0.5.0 2008-05-22
5
+ * Added: new generator options for more control over templates
6
+ * Fixed: sessions_controller successful_login didn't honor Lockdown::System options setting for :successful_login_path
7
+ * Modified: System had [] method which could cause issues in future releases. Use Lockdown::System.fetch(:option) to retrieve options
8
+
1
9
  == 0.4.6 2008-05-08
2
10
  * Fixed: link_to destroy/show conditionals were in wrong order and therefore not working.
3
11
 
data/Manifest.txt CHANGED
@@ -7,7 +7,6 @@ README.txt
7
7
  Rakefile
8
8
  app_generators/lockdown/USAGE
9
9
  app_generators/lockdown/lockdown_generator.rb
10
- app_generators/lockdown/lockdown_generator.rb.orig
11
10
  app_generators/lockdown/templates/init.rb
12
11
  app_generators/lockdown/templates/session.rb
13
12
  bin/lockdown
@@ -56,41 +55,6 @@ rails_generators/lockdown/templates/db/migrate/create_permissions.rb
56
55
  rails_generators/lockdown/templates/db/migrate/create_profiles.rb
57
56
  rails_generators/lockdown/templates/db/migrate/create_user_groups.rb
58
57
  rails_generators/lockdown/templates/db/migrate/create_users.rb
59
- rails_generators/lockdown_all/USAGE
60
- rails_generators/lockdown_all/lockdown_all_generator.rb
61
- rails_generators/lockdown_all/templates/app/controllers/permissions_controller.rb
62
- rails_generators/lockdown_all/templates/app/controllers/sessions_controller.rb
63
- rails_generators/lockdown_all/templates/app/controllers/user_groups_controller.rb
64
- rails_generators/lockdown_all/templates/app/controllers/users_controller.rb
65
- rails_generators/lockdown_all/templates/app/helpers/permissions_helper.rb
66
- rails_generators/lockdown_all/templates/app/helpers/user_groups_helper.rb
67
- rails_generators/lockdown_all/templates/app/helpers/users_helper.rb
68
- rails_generators/lockdown_all/templates/app/models/permission.rb
69
- rails_generators/lockdown_all/templates/app/models/profile.rb
70
- rails_generators/lockdown_all/templates/app/models/user.rb
71
- rails_generators/lockdown_all/templates/app/models/user_group.rb
72
- rails_generators/lockdown_all/templates/app/views/permissions/_data.html.erb
73
- rails_generators/lockdown_all/templates/app/views/permissions/index.html.erb
74
- rails_generators/lockdown_all/templates/app/views/permissions/show.html.erb
75
- rails_generators/lockdown_all/templates/app/views/sessions/new.html.erb
76
- rails_generators/lockdown_all/templates/app/views/user_groups/_data.html.erb
77
- rails_generators/lockdown_all/templates/app/views/user_groups/_form.html.erb
78
- rails_generators/lockdown_all/templates/app/views/user_groups/edit.html.erb
79
- rails_generators/lockdown_all/templates/app/views/user_groups/index.html.erb
80
- rails_generators/lockdown_all/templates/app/views/user_groups/new.html.erb
81
- rails_generators/lockdown_all/templates/app/views/user_groups/show.html.erb
82
- rails_generators/lockdown_all/templates/app/views/users/_data.html.erb
83
- rails_generators/lockdown_all/templates/app/views/users/_form.html.erb
84
- rails_generators/lockdown_all/templates/app/views/users/_password.html.erb
85
- rails_generators/lockdown_all/templates/app/views/users/edit.html.erb
86
- rails_generators/lockdown_all/templates/app/views/users/index.html.erb
87
- rails_generators/lockdown_all/templates/app/views/users/new.html.erb
88
- rails_generators/lockdown_all/templates/app/views/users/show.html.erb
89
- rails_generators/lockdown_all/templates/db/migrate/create_admin_user_and_user_group.rb
90
- rails_generators/lockdown_all/templates/db/migrate/create_permissions.rb
91
- rails_generators/lockdown_all/templates/db/migrate/create_profiles.rb
92
- rails_generators/lockdown_all/templates/db/migrate/create_user_groups.rb
93
- rails_generators/lockdown_all/templates/db/migrate/create_users.rb
94
58
  script/console
95
59
  script/destroy
96
60
  script/generate
@@ -38,7 +38,7 @@ module Lockdown
38
38
  req = Lockdown.format_controller_action(url)
39
39
  session[:access_rights] ||= Lockdown::System.public_access
40
40
  session[:access_rights].each do |ar|
41
- return true if req =~ /#{ar}$/
41
+ return true if req == ar
42
42
  end
43
43
  false
44
44
  end
@@ -51,7 +51,7 @@ module Lockdown
51
51
  end
52
52
 
53
53
  def store_location
54
- if request.method == :get && !(session[:thispage] == sent_from_uri)
54
+ if (request.method == :get) && (session[:thispage] != sent_from_uri)
55
55
  session[:prevpage] = session[:thispage] || ''
56
56
  session[:thispage] = sent_from_uri
57
57
  end
@@ -2,7 +2,7 @@ module Lockdown #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -24,48 +24,47 @@ class LockdownGenerator < Rails::Generator::Base
24
24
  protected
25
25
 
26
26
  def add_management(m)
27
- m.directory 'app/views/users'
28
- m.directory 'app/views/user_groups'
29
- m.directory 'app/views/permissions'
27
+ m.directory 'app/views/users'
28
+ m.directory 'app/views/user_groups'
29
+ m.directory 'app/views/permissions'
30
30
 
31
- m.file "app/controllers/permissions_controller.rb",
32
- "app/controllers/permissions_controller.rb"
31
+ m.file "app/controllers/permissions_controller.rb",
32
+ "app/controllers/permissions_controller.rb"
33
33
 
34
- m.file "app/controllers/users_controller.rb",
35
- "app/controllers/users_controller.rb"
34
+ m.file "app/controllers/users_controller.rb",
35
+ "app/controllers/users_controller.rb"
36
36
 
37
- m.file "app/controllers/user_groups_controller.rb",
38
- "app/controllers/user_groups_controller.rb"
37
+ m.file "app/controllers/user_groups_controller.rb",
38
+ "app/controllers/user_groups_controller.rb"
39
39
 
40
- m.file "app/helpers/permissions_helper.rb",
41
- "app/helpers/permissions_helper.rb"
40
+ m.file "app/helpers/permissions_helper.rb",
41
+ "app/helpers/permissions_helper.rb"
42
42
 
43
- m.file "app/helpers/users_helper.rb",
44
- "app/helpers/users_helper.rb"
43
+ m.file "app/helpers/users_helper.rb",
44
+ "app/helpers/users_helper.rb"
45
45
 
46
- m.file "app/helpers/user_groups_helper.rb",
47
- "app/helpers/user_groups_helper.rb"
46
+ m.file "app/helpers/user_groups_helper.rb",
47
+ "app/helpers/user_groups_helper.rb"
48
48
 
49
- copy_views(m, "users")
49
+ copy_views(m, "users")
50
50
 
51
- m.file "app/views/users/_password.html.erb",
52
- "app/views/users/_password.html.erb"
51
+ m.file "app/views/users/_password.html.erb",
52
+ "app/views/users/_password.html.erb"
53
53
 
54
- copy_views(m, "user_groups")
54
+ copy_views(m, "user_groups")
55
55
 
56
- m.file "app/views/permissions/_data.html.erb",
57
- "app/views/permissions/_data.html.erb"
56
+ m.file "app/views/permissions/_data.html.erb",
57
+ "app/views/permissions/_data.html.erb"
58
58
 
59
- m.file "app/views/permissions/index.html.erb",
60
- "app/views/permissions/index.html.erb"
59
+ m.file "app/views/permissions/index.html.erb",
60
+ "app/views/permissions/index.html.erb"
61
61
 
62
- m.file "app/views/permissions/show.html.erb",
63
- "app/views/permissions/show.html.erb"
62
+ m.file "app/views/permissions/show.html.erb",
63
+ "app/views/permissions/show.html.erb"
64
64
 
65
-
66
- m.route_resources "permissions"
67
- m.route_resources "user_groups"
68
- m.route_resources "users"
65
+ m.route_resources "permissions"
66
+ m.route_resources "user_groups"
67
+ m.route_resources "users"
69
68
 
70
69
  add_management_permissions(m)
71
70
  end
@@ -78,7 +77,7 @@ class LockdownGenerator < Rails::Generator::Base
78
77
 
79
78
  m.file "app/views/sessions/new.html.erb",
80
79
  "app/views/sessions/new.html.erb"
81
-
80
+
82
81
  m.route_resources "sessions"
83
82
 
84
83
  add_login_permissions(m)
@@ -141,22 +140,22 @@ class LockdownGenerator < Rails::Generator::Base
141
140
  end
142
141
  end # add_migrations
143
142
 
144
- def copy_views(m, vw)
145
- m.file "app/views/#{vw}/_data.html.erb", "app/views/#{vw}/_data.html.erb"
146
- m.file "app/views/#{vw}/_form.html.erb", "app/views/#{vw}/_form.html.erb"
147
- m.file "app/views/#{vw}/index.html.erb", "app/views/#{vw}/index.html.erb"
148
- m.file "app/views/#{vw}/show.html.erb", "app/views/#{vw}/show.html.erb"
149
- m.file "app/views/#{vw}/edit.html.erb", "app/views/#{vw}/edit.html.erb"
150
- m.file "app/views/#{vw}/new.html.erb", "app/views/#{vw}/new.html.erb"
151
- end
143
+ def copy_views(m, vw)
144
+ m.file "app/views/#{vw}/_data.html.erb", "app/views/#{vw}/_data.html.erb"
145
+ m.file "app/views/#{vw}/_form.html.erb", "app/views/#{vw}/_form.html.erb"
146
+ m.file "app/views/#{vw}/index.html.erb", "app/views/#{vw}/index.html.erb"
147
+ m.file "app/views/#{vw}/show.html.erb", "app/views/#{vw}/show.html.erb"
148
+ m.file "app/views/#{vw}/edit.html.erb", "app/views/#{vw}/edit.html.erb"
149
+ m.file "app/views/#{vw}/new.html.erb", "app/views/#{vw}/new.html.erb"
150
+ end
152
151
 
153
- def add_login_permissions(m)
152
+ def add_login_permissions(m)
154
153
  add_permissions m, "set_permission :sessions_management, all_methods(:sessions)"
155
154
 
156
155
  add_predefined_user_group m, "set_public_access :sessions_management"
157
156
  end
158
157
 
159
- def add_management_permissions(m)
158
+ def add_management_permissions(m)
160
159
  perms = []
161
160
  perms << "set_permission :users_management, all_methods(:users)"
162
161
  perms << "set_permission :user_groups_management, all_methods(:user_groups)"
@@ -166,32 +165,32 @@ class LockdownGenerator < Rails::Generator::Base
166
165
  add_permissions m, perms.join("\n ")
167
166
 
168
167
  add_predefined_user_group m, "set_protected_access :my_account"
169
- end
168
+ end
170
169
 
171
170
  def add_permissions(m, str)
172
- sentinel = '# Define your permissions here:'
173
- m.gsub_file 'lib/lockdown/init.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
174
- "#{match}\n #{str}"
175
- end
171
+ sentinel = '# Define your permissions here:'
172
+ m.gsub_file 'lib/lockdown/init.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
173
+ "#{match}\n #{str}"
174
+ end
176
175
  end
177
176
 
178
177
  def add_predefined_user_group(m, str)
179
- sentinel = '# Define the built-in user groups here:'
180
- m.gsub_file 'lib/lockdown/init.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
181
- "#{match}\n #{str}"
178
+ sentinel = '# Define the built-in user groups here:'
179
+ m.gsub_file 'lib/lockdown/init.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
180
+ "#{match}\n #{str}"
182
181
  end
183
182
  end
184
183
 
185
- def add_login_routes(m)
186
- home = %Q(map.home '', :controller => 'sessions', :action => 'new')
187
- login = %Q(map.login '/login', :controller => 'sessions', :action => 'new')
188
- logout =%Q(map.logout '/logout', :controller => 'sessions', :action => 'destroy')
184
+ def add_login_routes(m)
185
+ home = %Q(map.home '', :controller => 'sessions', :action => 'new')
186
+ login = %Q(map.login '/login', :controller => 'sessions', :action => 'new')
187
+ logout =%Q(map.logout '/logout', :controller => 'sessions', :action => 'destroy')
189
188
 
190
- sentinel = 'ActionController::Routing::Routes.draw do |map|'
191
-
192
- m.gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
193
- "#{match}\n #{home}\n\n #{login}\n\n #{logout}\n"
194
- end
189
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
190
+
191
+ m.gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
192
+ "#{match}\n #{home}\n\n #{login}\n\n #{logout}\n"
193
+ end
195
194
  end
196
195
 
197
196
  def banner
@@ -33,7 +33,7 @@
33
33
  <h1>Lockdown</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/lockdown"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/lockdown" class="numbers">0.5.0</a>
36
+ <a href="http://rubyforge.org/projects/lockdown" class="numbers">0.5.1</a>
37
37
  </div>
38
38
  <h2>What</h2>
39
39
 
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>Lockdown</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/lockdown"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/lockdown" class="numbers">0.5.0</a>
36
+ <a href="http://rubyforge.org/projects/lockdown" class="numbers">0.5.1</a>
37
37
  </div>
38
38
  <h2>What</h2>
39
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Stone
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-22 00:00:00 -04:00
12
+ date: 2008-05-25 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,6 @@ files:
46
46
  - Rakefile
47
47
  - app_generators/lockdown/USAGE
48
48
  - app_generators/lockdown/lockdown_generator.rb
49
- - app_generators/lockdown/lockdown_generator.rb.orig
50
49
  - app_generators/lockdown/templates/init.rb
51
50
  - app_generators/lockdown/templates/session.rb
52
51
  - bin/lockdown
@@ -95,41 +94,6 @@ files:
95
94
  - rails_generators/lockdown/templates/db/migrate/create_profiles.rb
96
95
  - rails_generators/lockdown/templates/db/migrate/create_user_groups.rb
97
96
  - rails_generators/lockdown/templates/db/migrate/create_users.rb
98
- - rails_generators/lockdown_all/USAGE
99
- - rails_generators/lockdown_all/lockdown_all_generator.rb
100
- - rails_generators/lockdown_all/templates/app/controllers/permissions_controller.rb
101
- - rails_generators/lockdown_all/templates/app/controllers/sessions_controller.rb
102
- - rails_generators/lockdown_all/templates/app/controllers/user_groups_controller.rb
103
- - rails_generators/lockdown_all/templates/app/controllers/users_controller.rb
104
- - rails_generators/lockdown_all/templates/app/helpers/permissions_helper.rb
105
- - rails_generators/lockdown_all/templates/app/helpers/user_groups_helper.rb
106
- - rails_generators/lockdown_all/templates/app/helpers/users_helper.rb
107
- - rails_generators/lockdown_all/templates/app/models/permission.rb
108
- - rails_generators/lockdown_all/templates/app/models/profile.rb
109
- - rails_generators/lockdown_all/templates/app/models/user.rb
110
- - rails_generators/lockdown_all/templates/app/models/user_group.rb
111
- - rails_generators/lockdown_all/templates/app/views/permissions/_data.html.erb
112
- - rails_generators/lockdown_all/templates/app/views/permissions/index.html.erb
113
- - rails_generators/lockdown_all/templates/app/views/permissions/show.html.erb
114
- - rails_generators/lockdown_all/templates/app/views/sessions/new.html.erb
115
- - rails_generators/lockdown_all/templates/app/views/user_groups/_data.html.erb
116
- - rails_generators/lockdown_all/templates/app/views/user_groups/_form.html.erb
117
- - rails_generators/lockdown_all/templates/app/views/user_groups/edit.html.erb
118
- - rails_generators/lockdown_all/templates/app/views/user_groups/index.html.erb
119
- - rails_generators/lockdown_all/templates/app/views/user_groups/new.html.erb
120
- - rails_generators/lockdown_all/templates/app/views/user_groups/show.html.erb
121
- - rails_generators/lockdown_all/templates/app/views/users/_data.html.erb
122
- - rails_generators/lockdown_all/templates/app/views/users/_form.html.erb
123
- - rails_generators/lockdown_all/templates/app/views/users/_password.html.erb
124
- - rails_generators/lockdown_all/templates/app/views/users/edit.html.erb
125
- - rails_generators/lockdown_all/templates/app/views/users/index.html.erb
126
- - rails_generators/lockdown_all/templates/app/views/users/new.html.erb
127
- - rails_generators/lockdown_all/templates/app/views/users/show.html.erb
128
- - rails_generators/lockdown_all/templates/db/migrate/create_admin_user_and_user_group.rb
129
- - rails_generators/lockdown_all/templates/db/migrate/create_permissions.rb
130
- - rails_generators/lockdown_all/templates/db/migrate/create_profiles.rb
131
- - rails_generators/lockdown_all/templates/db/migrate/create_user_groups.rb
132
- - rails_generators/lockdown_all/templates/db/migrate/create_users.rb
133
97
  - script/console
134
98
  - script/destroy
135
99
  - script/generate
@@ -1,69 +0,0 @@
1
- class LockdownGenerator < RubiGen::Base
2
-
3
- DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
4
- Config::CONFIG['ruby_install_name'])
5
-
6
- default_options :author => nil
7
-
8
- attr_reader :name
9
-
10
- def initialize(runtime_args, runtime_options = {})
11
- super
12
- usage if args.empty?
13
- @destination_root = File.expand_path(args.shift)
14
- @name = base_name
15
- extract_options
16
- end
17
-
18
- def manifest
19
- record do |m|
20
- # Ensure appropriate folder(s) exists
21
- m.directory ''
22
- BASEDIRS.each { |path| m.directory path }
23
-
24
- # Create stubs
25
- # m.template "template.rb", "some_file_after_erb.rb"
26
- # m.file "file", "some_file_copied"
27
-
28
- m.dependency "install_rubigen_scripts", [destination_root, 'lockdown'],
29
- :shebang => options[:shebang], :collision => :force
30
- end
31
- end
32
-
33
- protected
34
- def banner
35
- <<-EOS
36
- Creates a ...
37
-
38
- USAGE: #{spec.name} name
39
- EOS
40
- end
41
-
42
- def add_options!(opts)
43
- opts.separator ''
44
- opts.separator 'Options:'
45
- # For each option below, place the default
46
- # at the top of the file next to "default_options"
47
- # opts.on("-a", "--author=\"Your Name\"", String,
48
- # "Some comment about this option",
49
- # "Default: none") { |options[:author]| }
50
- opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
51
- end
52
-
53
- def extract_options
54
- # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
55
- # Templates can access these value via the attr_reader-generated methods, but not the
56
- # raw instance variable value.
57
- # @author = options[:author]
58
- end
59
-
60
- # Installation skeleton. Intermediate directories are automatically
61
- # created so don't sweat their absence here.
62
- BASEDIRS = %w(
63
- lib
64
- log
65
- script
66
- test
67
- tmp
68
- )
69
- end
@@ -1,5 +0,0 @@
1
- Description:
2
-
3
-
4
- Usage:
5
-
@@ -1,190 +0,0 @@
1
- class LockdownAllGenerator < Rails::Generator::Base
2
- attr_accessor :file_name
3
-
4
- def manifest
5
- record do |m|
6
- # Ensure appropriate folder(s) exists
7
- m.directory 'app/helpers'
8
- m.directory 'app/models'
9
- m.directory 'app/views'
10
- m.directory 'app/views/users'
11
- m.directory 'app/views/user_groups'
12
- m.directory 'app/views/permissions'
13
- m.directory 'app/views/sessions'
14
- m.directory 'app/controllers'
15
-
16
- #Controllers
17
- m.file "app/controllers/permissions_controller.rb",
18
- "app/controllers/permissions_controller.rb"
19
-
20
- m.file "app/controllers/users_controller.rb",
21
- "app/controllers/users_controller.rb"
22
-
23
- m.file "app/controllers/user_groups_controller.rb",
24
- "app/controllers/user_groups_controller.rb"
25
-
26
- m.file "app/controllers/sessions_controller.rb",
27
- "app/controllers/sessions_controller.rb"
28
-
29
- #Models
30
- m.file "app/models/permission.rb",
31
- "app/models/permission.rb"
32
-
33
- m.file "app/models/user.rb",
34
- "app/models/user.rb"
35
-
36
- m.file "app/models/user_group.rb",
37
- "app/models/user_group.rb"
38
-
39
- m.file "app/models/profile.rb",
40
- "app/models/profile.rb"
41
-
42
-
43
- #Route file (i like having them on individual lines)
44
- m.route_resources "permissions"
45
- m.route_resources "user_groups"
46
- m.route_resources "users"
47
- m.route_resources "sessions"
48
-
49
- #Helpers
50
- m.file "app/helpers/permissions_helper.rb",
51
- "app/helpers/permissions_helper.rb"
52
-
53
- m.file "app/helpers/users_helper.rb",
54
- "app/helpers/users_helper.rb"
55
-
56
- m.file "app/helpers/user_groups_helper.rb",
57
- "app/helpers/user_groups_helper.rb"
58
-
59
- #Views
60
- copy_views(m, "users")
61
-
62
- m.file "app/views/users/_password.html.erb",
63
- "app/views/users/_password.html.erb"
64
-
65
- copy_views(m, "user_groups")
66
-
67
- m.file "app/views/permissions/_data.html.erb",
68
- "app/views/permissions/_data.html.erb"
69
-
70
- m.file "app/views/permissions/index.html.erb",
71
- "app/views/permissions/index.html.erb"
72
-
73
- m.file "app/views/permissions/show.html.erb",
74
- "app/views/permissions/show.html.erb"
75
-
76
- m.file "app/views/sessions/new.html.erb",
77
- "app/views/sessions/new.html.erb"
78
-
79
- #Migrations
80
- begin
81
- m.migration_template "db/migrate/create_profiles.rb", "db/migrate",
82
- :migration_file_name => "create_profiles"
83
- rescue
84
- puts "Profiles migration exists"
85
- end
86
-
87
- begin
88
- m.migration_template "db/migrate/create_users.rb", "db/migrate",
89
- :migration_file_name => "create_users"
90
-
91
- rescue
92
- puts "Users migration exists"
93
- end
94
-
95
- begin
96
- m.migration_template "db/migrate/create_user_groups.rb", "db/migrate",
97
- :migration_file_name => "create_user_groups"
98
-
99
- rescue
100
- puts "User Groups migration exists"
101
- end
102
-
103
- begin
104
- m.migration_template "db/migrate/create_permissions.rb", "db/migrate",
105
- :migration_file_name => "create_permissions"
106
-
107
- rescue
108
- puts "Permissions migration exists"
109
- end
110
-
111
- begin
112
- m.migration_template "db/migrate/create_admin_user_and_user_group.rb",
113
- "db/migrate",
114
- :migration_file_name => "create_admin_user_and_user_group"
115
-
116
- rescue
117
- puts "Admin User Group... migration exists"
118
- end
119
-
120
- add_standard_routes(m)
121
- add_permissions(m)
122
- end
123
- end
124
-
125
- protected
126
-
127
- def banner
128
- <<-EOS
129
- Installs the lockdown framework to managing users user_groups
130
- and viewing permissions. Also includes a login screen.
131
-
132
- USAGE: #{$0} #{spec.name}
133
- EOS
134
- end
135
-
136
- def copy_views(m, vw)
137
- m.file "app/views/#{vw}/_data.html.erb", "app/views/#{vw}/_data.html.erb"
138
- m.file "app/views/#{vw}/_form.html.erb", "app/views/#{vw}/_form.html.erb"
139
- m.file "app/views/#{vw}/index.html.erb", "app/views/#{vw}/index.html.erb"
140
- m.file "app/views/#{vw}/show.html.erb", "app/views/#{vw}/show.html.erb"
141
- m.file "app/views/#{vw}/edit.html.erb", "app/views/#{vw}/edit.html.erb"
142
- m.file "app/views/#{vw}/new.html.erb", "app/views/#{vw}/new.html.erb"
143
- end
144
-
145
- def add_standard_routes(m)
146
- home = %Q(map.home '', :controller => 'sessions', :action => 'new')
147
- login = %Q(map.login '/login', :controller => 'sessions', :action => 'new')
148
- logout =%Q(map.logout '/logout', :controller => 'sessions', :action => 'destroy')
149
-
150
- sentinel = 'ActionController::Routing::Routes.draw do |map|'
151
-
152
- m.gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
153
- "#{match}\n #{home}\n #{login}\n #{logout}"
154
- end
155
- end
156
-
157
- def add_permissions(m)
158
- perms = <<-PERMS
159
-
160
- set_permission :sessions_management, all_methods(:sessions)
161
-
162
- set_permission :users_management, all_methods(:users)
163
-
164
- set_permission :user_groups_management, all_methods(:user_groups)
165
-
166
- set_permission :permissions_management, all_methods(:permissions)
167
-
168
- set_permission :my_account, only_methods(:users, :edit, :update, :show)
169
-
170
- PERMS
171
-
172
- sentinel = '# Define your permissions here:'
173
- m.gsub_file 'lib/lockdown/init.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
174
- "#{match}\n#{perms}"
175
- end
176
-
177
- predefined_user_groups = <<-PUG
178
- set_public_access :sessions_management
179
-
180
- set_protected_access :my_account
181
- PUG
182
-
183
- sentinel = '# Define the built-in user groups here:'
184
- m.gsub_file 'lib/lockdown/init.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
185
- "#{match}\n#{predefined_user_groups}"
186
- end
187
-
188
-
189
- end
190
- end
@@ -1,22 +0,0 @@
1
- class PermissionsController < ApplicationController
2
- # GET /permissions
3
- # GET /permissions.xml
4
- def index
5
- @permissions = Permission.find(:all)
6
-
7
- respond_to do |format|
8
- format.html # index.html.erb
9
- format.xml { render :xml => @permissions }
10
- end
11
- end
12
-
13
- # GET /permissions/1
14
- # GET /permissions/1.xml
15
- def show
16
- @permission = Permission.find(params[:id])
17
- respond_to do |format|
18
- format.html # show.html.erb
19
- format.xml { render :xml => @permission }
20
- end
21
- end
22
- end