headstart 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.
Files changed (105) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +117 -0
  3. data/Rakefile +95 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/headstart/confirmations_controller.rb +76 -0
  6. data/app/controllers/headstart/impersonations_controller.rb +44 -0
  7. data/app/controllers/headstart/passwords_controller.rb +93 -0
  8. data/app/controllers/headstart/sessions_controller.rb +76 -0
  9. data/app/controllers/headstart/users_controller.rb +85 -0
  10. data/app/models/deliver_change_password_job.rb +19 -0
  11. data/app/models/deliver_welcome_job.rb +17 -0
  12. data/app/models/generic_mailer.rb +31 -0
  13. data/app/models/headstart_mailer.rb +28 -0
  14. data/app/models/impersonation.rb +26 -0
  15. data/app/models/mimi_mailer.rb +30 -0
  16. data/app/views/generic_mailer/change_password.html.erb +9 -0
  17. data/app/views/generic_mailer/confirmation.html.erb +5 -0
  18. data/app/views/generic_mailer/welcome.html.erb +1 -0
  19. data/app/views/impersonations/index.html.erb +5 -0
  20. data/app/views/passwords/edit.html.erb +23 -0
  21. data/app/views/passwords/new.html.erb +15 -0
  22. data/app/views/sessions/new.html.erb +48 -0
  23. data/app/views/users/_form.html.erb +21 -0
  24. data/app/views/users/edit.html.erb +6 -0
  25. data/app/views/users/new.html.erb +6 -0
  26. data/app/views/users/show.html.erb +8 -0
  27. data/generators/headstart/USAGE +1 -0
  28. data/generators/headstart/headstart_generator.rb +86 -0
  29. data/generators/headstart/lib/insert_commands.rb +33 -0
  30. data/generators/headstart/lib/rake_commands.rb +22 -0
  31. data/generators/headstart/templates/README +20 -0
  32. data/generators/headstart/templates/app/controllers/sessions_controller.rb +6 -0
  33. data/generators/headstart/templates/app/views/sessions/index.html.erb +1 -0
  34. data/generators/headstart/templates/application.html.erb +75 -0
  35. data/generators/headstart/templates/factories.rb +23 -0
  36. data/generators/headstart/templates/headstart.rb +25 -0
  37. data/generators/headstart/templates/headstart.yml +45 -0
  38. data/generators/headstart/templates/layout.css +353 -0
  39. data/generators/headstart/templates/migrations/create_users.rb +26 -0
  40. data/generators/headstart/templates/migrations/update_users.rb +44 -0
  41. data/generators/headstart/templates/report.css +69 -0
  42. data/generators/headstart/templates/reset.css +1 -0
  43. data/generators/headstart/templates/style.css +31 -0
  44. data/generators/headstart/templates/text.css +1 -0
  45. data/generators/headstart/templates/user.rb +3 -0
  46. data/generators/headstart/templates/xd_receiver.html +10 -0
  47. data/generators/headstart/templates/xd_receiver_ssl.html +10 -0
  48. data/generators/headstart_admin/USAGE +1 -0
  49. data/generators/headstart_admin/headstart_admin_generator.rb +32 -0
  50. data/generators/headstart_admin/lib/insert_commands.rb +33 -0
  51. data/generators/headstart_admin/templates/README +16 -0
  52. data/generators/headstart_admin/templates/app/controllers/admin/admin_controller.rb +17 -0
  53. data/generators/headstart_admin/templates/app/controllers/admin/users_controller.rb +52 -0
  54. data/generators/headstart_admin/templates/app/views/admin/admin/index.html.erb +2 -0
  55. data/generators/headstart_admin/templates/app/views/admin/users/_form.html.erb +25 -0
  56. data/generators/headstart_admin/templates/app/views/admin/users/edit.html.erb +6 -0
  57. data/generators/headstart_admin/templates/app/views/admin/users/index.html.erb +7 -0
  58. data/generators/headstart_admin/templates/app/views/admin/users/new.html.erb +6 -0
  59. data/generators/headstart_admin/templates/app/views/admin/users/show.html.erb +10 -0
  60. data/generators/headstart_admin/templates/test/integration/admin/users_test.rb +201 -0
  61. data/generators/headstart_tests/USAGE +1 -0
  62. data/generators/headstart_tests/headstart_tests_generator.rb +21 -0
  63. data/generators/headstart_tests/templates/README +58 -0
  64. data/generators/headstart_tests/templates/test/integration/edit_profile_test.rb +35 -0
  65. data/generators/headstart_tests/templates/test/integration/facebook_test.rb +61 -0
  66. data/generators/headstart_tests/templates/test/integration/impersonation_test.rb +39 -0
  67. data/generators/headstart_tests/templates/test/integration/password_reset_test.rb +128 -0
  68. data/generators/headstart_tests/templates/test/integration/sign_in_test.rb +66 -0
  69. data/generators/headstart_tests/templates/test/integration/sign_out_test.rb +28 -0
  70. data/generators/headstart_tests/templates/test/integration/sign_up_test.rb +47 -0
  71. data/lib/headstart/authentication.rb +138 -0
  72. data/lib/headstart/configuration.rb +34 -0
  73. data/lib/headstart/extensions/errors.rb +6 -0
  74. data/lib/headstart/extensions/rescue.rb +5 -0
  75. data/lib/headstart/routes.rb +67 -0
  76. data/lib/headstart/user.rb +279 -0
  77. data/lib/headstart.rb +7 -0
  78. data/rails/init.rb +4 -0
  79. data/shoulda_macros/headstart.rb +244 -0
  80. data/test/controllers/passwords_controller_test.rb +184 -0
  81. data/test/controllers/sessions_controller_test.rb +129 -0
  82. data/test/controllers/users_controller_test.rb +57 -0
  83. data/test/models/headstart_mailer_test.rb +52 -0
  84. data/test/models/impersonation_test.rb +25 -0
  85. data/test/models/user_test.rb +213 -0
  86. data/test/rails_root/app/controllers/accounts_controller.rb +10 -0
  87. data/test/rails_root/app/controllers/application_controller.rb +6 -0
  88. data/test/rails_root/app/helpers/application_helper.rb +5 -0
  89. data/test/rails_root/app/helpers/confirmations_helper.rb +2 -0
  90. data/test/rails_root/app/helpers/passwords_helper.rb +2 -0
  91. data/test/rails_root/config/boot.rb +110 -0
  92. data/test/rails_root/config/environment.rb +22 -0
  93. data/test/rails_root/config/environments/development.rb +19 -0
  94. data/test/rails_root/config/environments/production.rb +1 -0
  95. data/test/rails_root/config/environments/test.rb +37 -0
  96. data/test/rails_root/config/initializers/inflections.rb +10 -0
  97. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  98. data/test/rails_root/config/initializers/requires.rb +13 -0
  99. data/test/rails_root/config/initializers/time_formats.rb +4 -0
  100. data/test/rails_root/config/routes.rb +9 -0
  101. data/test/rails_root/public/dispatch.rb +10 -0
  102. data/test/rails_root/script/create_project.rb +52 -0
  103. data/test/rails_root/test/functional/accounts_controller_test.rb +23 -0
  104. data/test/test_helper.rb +21 -0
  105. metadata +232 -0
@@ -0,0 +1,353 @@
1
+
2
+ /* Containers
3
+ ----------------------------------------------------------------------------------------------------*/
4
+ .container_12 {
5
+ margin-left: auto;
6
+ margin-right: auto;
7
+ width: 960px;
8
+
9
+
10
+ }
11
+
12
+ /* Grid >> Children (Alpha ~ First, Omega ~ Last)
13
+ ----------------------------------------------------------------------------------------------------*/
14
+
15
+ .alpha {
16
+ margin-left: 0 !important;
17
+ }
18
+
19
+ .omega {
20
+ margin-right: 0 !important;
21
+ }
22
+
23
+
24
+
25
+ /* Grid >> Global
26
+ ----------------------------------------------------------------------------------------------------*/
27
+
28
+ .grid_1,
29
+ .grid_2,
30
+ .grid_3,
31
+ .grid_4,
32
+ .grid_5,
33
+ .grid_6,
34
+ .grid_7,
35
+ .grid_8,
36
+ .grid_9,
37
+ .grid_10,
38
+ .grid_11,
39
+ .grid_12,.grid_12{
40
+ display:inline;
41
+ float: left;
42
+ position: relative;
43
+ margin-left: 10.0px;
44
+ margin-right: 10.0px;
45
+ }
46
+
47
+
48
+ /* Grid >> 2 Columns
49
+ ----------------------------------------------------------------------------------------------------*/
50
+
51
+ .container_12 .grid_1{
52
+ width:60px;
53
+ }
54
+
55
+ .container_12 .grid_2{
56
+ width:140px;
57
+ }
58
+
59
+ .container_12 .grid_3{
60
+ width:220px;
61
+ }
62
+
63
+ .container_12 .grid_4{
64
+ width:300px;
65
+ }
66
+
67
+ .container_12 .grid_5{
68
+ width:380px;
69
+ }
70
+
71
+ .container_12 .grid_6{
72
+ width:460px;
73
+ }
74
+
75
+ .container_12 .grid_7{
76
+ width:540px;
77
+ }
78
+
79
+ .container_12 .grid_8{
80
+ width:620px;
81
+ }
82
+
83
+ .container_12 .grid_9{
84
+ width:700px;
85
+ }
86
+
87
+ .container_12 .grid_10{
88
+ width:780px;
89
+ }
90
+
91
+ .container_12 .grid_11{
92
+ width:860px;
93
+ }
94
+
95
+ .container_12 .grid_12{
96
+ width:940px;
97
+ }
98
+
99
+
100
+
101
+
102
+
103
+ /* Prefix Extra Space >> 2 Columns
104
+ ----------------------------------------------------------------------------------------------------*/
105
+
106
+ .container_12 .prefix_1 {
107
+ padding-left:80px;
108
+ }
109
+
110
+ .container_12 .prefix_2 {
111
+ padding-left:160px;
112
+ }
113
+
114
+ .container_12 .prefix_3 {
115
+ padding-left:240px;
116
+ }
117
+
118
+ .container_12 .prefix_4 {
119
+ padding-left:320px;
120
+ }
121
+
122
+ .container_12 .prefix_5 {
123
+ padding-left:400px;
124
+ }
125
+
126
+ .container_12 .prefix_6 {
127
+ padding-left:480px;
128
+ }
129
+
130
+ .container_12 .prefix_7 {
131
+ padding-left:560px;
132
+ }
133
+
134
+ .container_12 .prefix_8 {
135
+ padding-left:640px;
136
+ }
137
+
138
+ .container_12 .prefix_9 {
139
+ padding-left:720px;
140
+ }
141
+
142
+ .container_12 .prefix_10 {
143
+ padding-left:800px;
144
+ }
145
+
146
+ .container_12 .prefix_11 {
147
+ padding-left:880px;
148
+ }
149
+
150
+ .container_12 .prefix_12 {
151
+ padding-left:960px;
152
+ }
153
+
154
+
155
+
156
+ /* Suffix Extra Space >> 2 Columns
157
+ ----------------------------------------------------------------------------------------------------*/
158
+
159
+ .container_12 .suffix_1 {
160
+ padding-right:80px;
161
+ }
162
+
163
+ .container_12 .suffix_2 {
164
+ padding-right:160px;
165
+ }
166
+
167
+ .container_12 .suffix_3 {
168
+ padding-right:240px;
169
+ }
170
+
171
+ .container_12 .suffix_4 {
172
+ padding-right:320px;
173
+ }
174
+
175
+ .container_12 .suffix_5 {
176
+ padding-right:400px;
177
+ }
178
+
179
+ .container_12 .suffix_6 {
180
+ padding-right:480px;
181
+ }
182
+
183
+ .container_12 .suffix_7 {
184
+ padding-right:560px;
185
+ }
186
+
187
+ .container_12 .suffix_8 {
188
+ padding-right:640px;
189
+ }
190
+
191
+ .container_12 .suffix_9 {
192
+ padding-right:720px;
193
+ }
194
+
195
+ .container_12 .suffix_10 {
196
+ padding-right:800px;
197
+ }
198
+
199
+ .container_12 .suffix_11 {
200
+ padding-right:880px;
201
+ }
202
+
203
+ .container_12 .suffix_12 {
204
+ padding-right:960px;
205
+ }
206
+
207
+
208
+
209
+ /* Push Space >> 2 Columns
210
+ ----------------------------------------------------------------------------------------------------*/
211
+
212
+ .container_12 .push_1 {
213
+ left:80px;
214
+ }
215
+
216
+ .container_12 .push_2 {
217
+ left:160px;
218
+ }
219
+
220
+ .container_12 .push_3 {
221
+ left:240px;
222
+ }
223
+
224
+ .container_12 .push_4 {
225
+ left:320px;
226
+ }
227
+
228
+ .container_12 .push_5 {
229
+ left:400px;
230
+ }
231
+
232
+ .container_12 .push_6 {
233
+ left:480px;
234
+ }
235
+
236
+ .container_12 .push_7 {
237
+ left:560px;
238
+ }
239
+
240
+ .container_12 .push_8 {
241
+ left:640px;
242
+ }
243
+
244
+ .container_12 .push_9 {
245
+ left:720px;
246
+ }
247
+
248
+ .container_12 .push_10 {
249
+ left:800px;
250
+ }
251
+
252
+ .container_12 .push_11 {
253
+ left:880px;
254
+ }
255
+
256
+ .container_12 .push_12 {
257
+ left:960px;
258
+ }
259
+
260
+
261
+
262
+
263
+
264
+ /* Pull Space >> 2 Columns
265
+ ----------------------------------------------------------------------------------------------------*/
266
+
267
+ .container_12 .pull_1 {
268
+ right:80px;
269
+ }
270
+
271
+ .container_12 .pull_2 {
272
+ right:160px;
273
+ }
274
+
275
+ .container_12 .pull_3 {
276
+ right:240px;
277
+ }
278
+
279
+ .container_12 .pull_4 {
280
+ right:320px;
281
+ }
282
+
283
+ .container_12 .pull_5 {
284
+ right:400px;
285
+ }
286
+
287
+ .container_12 .pull_6 {
288
+ right:480px;
289
+ }
290
+
291
+ .container_12 .pull_7 {
292
+ right:560px;
293
+ }
294
+
295
+ .container_12 .pull_8 {
296
+ right:640px;
297
+ }
298
+
299
+ .container_12 .pull_9 {
300
+ right:720px;
301
+ }
302
+
303
+ .container_12 .pull_10 {
304
+ right:800px;
305
+ }
306
+
307
+ .container_12 .pull_11 {
308
+ right:880px;
309
+ }
310
+
311
+ .container_12 .pull_12 {
312
+ right:960px;
313
+ }
314
+
315
+
316
+
317
+
318
+ /* Clear Floated Elements
319
+ ----------------------------------------------------------------------------------------------------*/
320
+
321
+
322
+ .clear {
323
+ clear: both;
324
+ display: block;
325
+ overflow: hidden;
326
+ visibility: hidden;
327
+ width: 0;
328
+ height: 0;
329
+ }
330
+
331
+
332
+ .clearfix:after {
333
+ clear: both;
334
+ content: ' ';
335
+ display: block;
336
+ font-size: 0;
337
+ line-height: 0;
338
+ visibility: hidden;
339
+ width: 0;
340
+ height: 0;
341
+ }
342
+
343
+ .clearfix {
344
+ display: inline-block;
345
+ }
346
+
347
+ * html .clearfix {
348
+ height: 1%;
349
+ }
350
+
351
+ .clearfix {
352
+ display: block;
353
+ }
@@ -0,0 +1,26 @@
1
+ class HeadstartCreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table(:users) do |t|
4
+ t.string :email, :limit => 100
5
+ t.string :first_name, :limit => 50
6
+ t.string :last_name, :limit => 50
7
+ t.string :role, :limit => 50
8
+ t.string :encrypted_password, :limit => 128
9
+ t.string :salt, :limit => 128
10
+ t.string :remember_token, :limit => 128
11
+ t.string :facebook_uid, :limit => 50
12
+ t.string :password_reset_token, :limit => 128
13
+ t.string :confirmation_token, :limit => 128
14
+ t.boolean :email_confirmed, :default => false, :null => false
15
+ t.timestamps
16
+ end
17
+
18
+ add_index :users, :email
19
+ add_index :users, :remember_token
20
+ add_index :users, :facebook_uid
21
+ end
22
+
23
+ def self.down
24
+ drop_table :users
25
+ end
26
+ end
@@ -0,0 +1,44 @@
1
+ class HeadstartUpdateUsers<%= schema_version_constant %> < ActiveRecord::Migration
2
+ def self.up
3
+ <%
4
+ existing_columns = ActiveRecord::Base.connection.columns(:users).collect { |each| each.name }
5
+ columns = [
6
+ [:email, 't.string :email, :limit => 100'],
7
+ [:first_name, 't.string :first_name, :limit => 50'],
8
+ [:last_name, 't.string :last_name, :limit => 50'],
9
+ [:role, 't.string :role, :limit => 50'],
10
+ [:encrypted_password, 't.string :encrypted_password, :limit => 128'],
11
+ [:salt, 't.string :salt, :limit => 128'],
12
+ [:remember_token, 't.string :remember_token, :limit => 128'],
13
+ [:facebook_uid, 't.string :facebook_uid, :limit => 50'],
14
+ [:password_reset_token, 't.string :password_reset_token, :limit => 128']
15
+ ].delete_if {|c| existing_columns.include?(c.first.to_s)}
16
+ -%>
17
+ change_table(:users) do |t|
18
+ <% columns.each do |c| -%>
19
+ <%= c.last %>
20
+ <% end -%>
21
+ end
22
+
23
+ <%
24
+ existing_indexes = ActiveRecord::Base.connection.indexes(:users)
25
+ index_names = existing_indexes.collect { |each| each.name }
26
+ new_indexes = [
27
+ [:index_users_on_email, 'add_index :users, :email'],
28
+ [:index_users_on_remember_token, 'add_index :users, :remember_token'],
29
+ [:index_users_on_facebook_uid, 'add_index :users, :facebook_uid']
30
+ ].delete_if { |each| index_names.include?(each.first.to_s) }
31
+ -%>
32
+ <% new_indexes.each do |each| -%>
33
+ <%= each.last %>
34
+ <% end -%>
35
+ end
36
+
37
+ def self.down
38
+ change_table(:users) do |t|
39
+ <% unless columns.empty? -%>
40
+ t.remove <%= columns.collect { |each| ":#{each.first}" }.join(',') %>
41
+ <% end -%>
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,69 @@
1
+ .report table {
2
+ font-family: "Junction";
3
+ width: 700px;
4
+ height: 160px;
5
+ border: 2px solid black;
6
+ }
7
+ .report table th {
8
+ text-align: center;
9
+ font-weight: bold;
10
+ }
11
+ .report table td,
12
+ .report table th {
13
+ padding: 2px;
14
+ }
15
+ .report table td.numeric,
16
+ .report table th.numeric {
17
+ text-align: right;
18
+ }
19
+ .report table th, .report table td {
20
+ border-right: 1px solid #233551;
21
+ border-bottom: 1px solid #233551;
22
+ border-left-width: 0px;
23
+ border-top-width: 0px;
24
+ }
25
+ .report table th:last-child, .report table th.last, .report table td:last-child, .report table td.last {
26
+ border-right-width: 0px;
27
+ }
28
+ .report table tbody tr:last-child th, .report table tbody tr:last-child td,
29
+ .report table tbody tr.last th,
30
+ .report table tbody tr.last td, .report table tfoot tr:last-child th, .report table tfoot tr:last-child td, .report table tfoot tr.last th, .report table tfoot tr.last td {
31
+ border-bottom-width: 0px;
32
+ }
33
+ .report table thead th {
34
+ border-bottom: 2px solid black;
35
+ }
36
+ .report table tfoot th, .report table tfoot td {
37
+ border-top: 2px solid black;
38
+ }
39
+ .report table th:first-child {
40
+ border-right: 2px solid black;
41
+ }
42
+ .report table th {
43
+ background-color: #eeeeee;
44
+ }
45
+ .report table th.even, .report table th:nth-child(2n) {
46
+ background-color: #eeeeee;
47
+ }
48
+ .report table tr.odd td {
49
+ background-color: #98c67a;
50
+ }
51
+ .report table tr.odd td.even, .report table tr.odd td:nth-child(2n) {
52
+ background-color: #98c67a;
53
+ }
54
+ .report table tr.even td {
55
+ background-color: #7a98c6;
56
+ }
57
+ .report table tr.even td.even, .report table tr.even td:nth-child(2n) {
58
+ background-color: #7a98c6;
59
+ }
60
+ .report table tfoot th, .report table tfoot td {
61
+ background-color: white;
62
+ }
63
+ .report table tfoot th.even, .report table tfoot th:nth-child(2n), .report table tfoot td.even, .report table tfoot td:nth-child(2n) {
64
+ background-color: white;
65
+ }
66
+ .report table th {
67
+ text-align: left;
68
+ margin-top: 0px;
69
+ }
@@ -0,0 +1 @@
1
+ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outline:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}
@@ -0,0 +1,31 @@
1
+ /* Flash messages */
2
+
3
+ .notice_flash,
4
+ .failure_flash,
5
+ .success_flash {
6
+ border: 1px solid;
7
+ padding: 3px;
8
+ padding:15px 10px;
9
+ background-repeat: no-repeat;
10
+ background-position: 10px center;
11
+ margin-bottom: 10px;
12
+ font-weight: bold;
13
+ width: 60%;
14
+ margin-left: auto;
15
+ margin-right: auto;
16
+ }
17
+
18
+ .notice_flash {
19
+ color: #00529B;
20
+ background-color: #BDE5F8;
21
+ }
22
+
23
+ .failure_flash {
24
+ color: #D8000C;
25
+ background-color: #FFBABA;
26
+ }
27
+
28
+ .success_flash {
29
+ color: #4F8A10;
30
+ background-color: #DFF2BF;
31
+ }
@@ -0,0 +1 @@
1
+ body{font:13px/1.5 'Helvetica Neue',Arial,'Liberation Sans',FreeSans,sans-serif}a:focus{outline:1px dotted}hr{border:0 #ccc solid;border-top-width:1px;clear:both;height:0}h1{font-size:25px}h2{font-size:23px}h3{font-size:21px}h4{font-size:19px}h5{font-size:17px}h6{font-size:15px}ol{list-style:decimal}ul{list-style:disc}li{margin-left:30px}p,dl,hr,h1,h2,h3,h4,h5,h6,ol,ul,pre,table,address,fieldset{margin-bottom:20px}
@@ -0,0 +1,3 @@
1
+ class User < ActiveRecord::Base
2
+ include Headstart::User
3
+ end
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" >
4
+ <head>
5
+ <title>Cross-Domain Receiver Page</title>
6
+ </head>
7
+ <body>
8
+ <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.debug.js" type="text/javascript"></script>
9
+ </body>
10
+ </html>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" >
4
+ <head>
5
+ <title>Cross-Domain Receiver Page</title>
6
+ </head>
7
+ <body>
8
+ <script src="https://ssl.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script>
9
+ </body>
10
+ </html>
@@ -0,0 +1 @@
1
+ script/generate headstart_admin
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
2
+
3
+ class HeadstartAdminGenerator < Rails::Generator::Base
4
+
5
+ def manifest
6
+ record do |m|
7
+ m.directory File.join("app", "controllers", "admin")
8
+ m.file "app/controllers/admin/admin_controller.rb", "app/controllers/admin/admin_controller.rb"
9
+ m.file "app/controllers/admin/users_controller.rb", "app/controllers/admin/users_controller.rb"
10
+
11
+ m.directory File.join("app", "views", "admin", "users")
12
+ m.directory File.join("app", "views", "admin", "admin")
13
+ ["app/views/admin/users/_form.html.erb",
14
+ "app/views/admin/users/edit.html.erb",
15
+ "app/views/admin/users/index.html.erb",
16
+ "app/views/admin/users/new.html.erb",
17
+ "app/views/admin/admin/index.html.erb",
18
+ "app/views/admin/users/show.html.erb"].each do |file|
19
+ m.file file, file
20
+ end
21
+
22
+ m.directory File.join("test", "integration", "admin")
23
+ m.file "test/integration/admin/users_test.rb", "test/integration/admin/users_test.rb"
24
+
25
+ m.insert_into "config/routes.rb",
26
+ "map.namespace :admin do |admin|\n admin.resources :users\n end"
27
+
28
+ m.readme "README"
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,33 @@
1
+ # Mostly pinched from http://github.com/ryanb/nifty-generators/tree/master
2
+
3
+ Rails::Generator::Commands::Base.class_eval do
4
+ def file_contains?(relative_destination, line)
5
+ File.read(destination_path(relative_destination)).include?(line)
6
+ end
7
+ end
8
+
9
+ Rails::Generator::Commands::Create.class_eval do
10
+ def insert_into(file, line)
11
+ logger.insert "#{line} into #{file}"
12
+ unless options[:pretend] || file_contains?(file, line)
13
+ gsub_file file, /^(class|module|.*Routing).*$/ do |match|
14
+ "#{match}\n #{line}"
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ Rails::Generator::Commands::Destroy.class_eval do
21
+ def insert_into(file, line)
22
+ logger.remove "#{line} from #{file}"
23
+ unless options[:pretend]
24
+ gsub_file file, "\n #{line}", ''
25
+ end
26
+ end
27
+ end
28
+
29
+ Rails::Generator::Commands::List.class_eval do
30
+ def insert_into(file, line)
31
+ logger.insert "#{line} into #{file}"
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+
2
+ *******************************************************************************
3
+
4
+ Next:
5
+
6
+ 1. Add a link somewhere in your app to /admin/users for admins to access the
7
+ list of users.
8
+
9
+ 2. Any other admin controllers should inherit from Admin::AdminController.
10
+ This will ensure that only users who have the 'admin' role are allowed
11
+ to access the admin controllers.
12
+
13
+ 3. Manually set an 'admin' role on at least one user, or you won't be able
14
+ to access the admin area.
15
+
16
+ *******************************************************************************
@@ -0,0 +1,17 @@
1
+ class Admin::AdminController < ApplicationController
2
+
3
+ before_filter :authenticate
4
+ before_filter :check_role
5
+
6
+ def index
7
+
8
+ end
9
+
10
+ private
11
+
12
+
13
+ def check_role
14
+ redirect_to root_url unless current_user.admin?
15
+ end
16
+
17
+ end