drh_admin 0.0.3

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 (87) hide show
  1. data/lib/generators/admin/USAGE +8 -0
  2. data/lib/generators/admin/admin_generator.rb +100 -0
  3. data/lib/generators/admin/templates/app/assets/images/admin/add-icon.gif +0 -0
  4. data/lib/generators/admin/templates/app/assets/images/admin/approve.png +0 -0
  5. data/lib/generators/admin/templates/app/assets/images/admin/arrow.gif +0 -0
  6. data/lib/generators/admin/templates/app/assets/images/admin/bg-center-column.jpg +0 -0
  7. data/lib/generators/admin/templates/app/assets/images/admin/breadcrumb_divider.png +0 -0
  8. data/lib/generators/admin/templates/app/assets/images/admin/btn_submit.png +0 -0
  9. data/lib/generators/admin/templates/app/assets/images/admin/btn_submit_2.png +0 -0
  10. data/lib/generators/admin/templates/app/assets/images/admin/btn_view_site.png +0 -0
  11. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/border.png +0 -0
  12. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/controls.png +0 -0
  13. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/ie6/borderBottomCenter.png +0 -0
  14. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/ie6/borderBottomLeft.png +0 -0
  15. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/ie6/borderBottomRight.png +0 -0
  16. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/ie6/borderMiddleLeft.png +0 -0
  17. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/ie6/borderMiddleRight.png +0 -0
  18. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/ie6/borderTopCenter.png +0 -0
  19. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/ie6/borderTopLeft.png +0 -0
  20. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/ie6/borderTopRight.png +0 -0
  21. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/loading.gif +0 -0
  22. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/loading_background.png +0 -0
  23. data/lib/generators/admin/templates/app/assets/images/admin/colorbox/overlay.png +0 -0
  24. data/lib/generators/admin/templates/app/assets/images/admin/edit-icon.gif +0 -0
  25. data/lib/generators/admin/templates/app/assets/images/admin/header_bg.png +0 -0
  26. data/lib/generators/admin/templates/app/assets/images/admin/header_shadow.png +0 -0
  27. data/lib/generators/admin/templates/app/assets/images/admin/hr.gif +0 -0
  28. data/lib/generators/admin/templates/app/assets/images/admin/icn_add_user.png +0 -0
  29. data/lib/generators/admin/templates/app/assets/images/admin/icn_alert_error.png +0 -0
  30. data/lib/generators/admin/templates/app/assets/images/admin/icn_alert_info.png +0 -0
  31. data/lib/generators/admin/templates/app/assets/images/admin/icn_alert_success.png +0 -0
  32. data/lib/generators/admin/templates/app/assets/images/admin/icn_alert_warning.png +0 -0
  33. data/lib/generators/admin/templates/app/assets/images/admin/icn_audio.png +0 -0
  34. data/lib/generators/admin/templates/app/assets/images/admin/icn_cafe.png +0 -0
  35. data/lib/generators/admin/templates/app/assets/images/admin/icn_categories.png +0 -0
  36. data/lib/generators/admin/templates/app/assets/images/admin/icn_check.png +0 -0
  37. data/lib/generators/admin/templates/app/assets/images/admin/icn_edit.png +0 -0
  38. data/lib/generators/admin/templates/app/assets/images/admin/icn_edit_article.png +0 -0
  39. data/lib/generators/admin/templates/app/assets/images/admin/icn_eye.png +0 -0
  40. data/lib/generators/admin/templates/app/assets/images/admin/icn_folder.png +0 -0
  41. data/lib/generators/admin/templates/app/assets/images/admin/icn_json.png +0 -0
  42. data/lib/generators/admin/templates/app/assets/images/admin/icn_jump_back.png +0 -0
  43. data/lib/generators/admin/templates/app/assets/images/admin/icn_logout.png +0 -0
  44. data/lib/generators/admin/templates/app/assets/images/admin/icn_new_article.png +0 -0
  45. data/lib/generators/admin/templates/app/assets/images/admin/icn_photo.png +0 -0
  46. data/lib/generators/admin/templates/app/assets/images/admin/icn_plus.png +0 -0
  47. data/lib/generators/admin/templates/app/assets/images/admin/icn_profile.png +0 -0
  48. data/lib/generators/admin/templates/app/assets/images/admin/icn_qrcode.png +0 -0
  49. data/lib/generators/admin/templates/app/assets/images/admin/icn_reject.png +0 -0
  50. data/lib/generators/admin/templates/app/assets/images/admin/icn_search.png +0 -0
  51. data/lib/generators/admin/templates/app/assets/images/admin/icn_security.png +0 -0
  52. data/lib/generators/admin/templates/app/assets/images/admin/icn_settings.png +0 -0
  53. data/lib/generators/admin/templates/app/assets/images/admin/icn_tags.png +0 -0
  54. data/lib/generators/admin/templates/app/assets/images/admin/icn_trash.png +0 -0
  55. data/lib/generators/admin/templates/app/assets/images/admin/icn_user.png +0 -0
  56. data/lib/generators/admin/templates/app/assets/images/admin/icn_video.png +0 -0
  57. data/lib/generators/admin/templates/app/assets/images/admin/icn_view_users.png +0 -0
  58. data/lib/generators/admin/templates/app/assets/images/admin/login-icon.gif +0 -0
  59. data/lib/generators/admin/templates/app/assets/images/admin/logo.png +0 -0
  60. data/lib/generators/admin/templates/app/assets/images/admin/module_footer_bg.png +0 -0
  61. data/lib/generators/admin/templates/app/assets/images/admin/post_message.png +0 -0
  62. data/lib/generators/admin/templates/app/assets/images/admin/save-icon.gif +0 -0
  63. data/lib/generators/admin/templates/app/assets/images/admin/secondary_bar.png +0 -0
  64. data/lib/generators/admin/templates/app/assets/images/admin/secondary_bar_shadow.png +0 -0
  65. data/lib/generators/admin/templates/app/assets/images/admin/show.png +0 -0
  66. data/lib/generators/admin/templates/app/assets/images/admin/sidebar.png +0 -0
  67. data/lib/generators/admin/templates/app/assets/images/admin/sidebar_divider.png +0 -0
  68. data/lib/generators/admin/templates/app/assets/images/admin/sidebar_shadow.png +0 -0
  69. data/lib/generators/admin/templates/app/assets/images/admin/table_sorter_header.png +0 -0
  70. data/lib/generators/admin/templates/app/assets/javascripts/admin/admin.js +2 -0
  71. data/lib/generators/admin/templates/app/assets/stylesheets/admin/admin.css +434 -0
  72. data/lib/generators/admin/templates/app/assets/stylesheets/admin/auth.css.scss +3 -0
  73. data/lib/generators/admin/templates/app/controllers/admin/admin_controller.rb +24 -0
  74. data/lib/generators/admin/templates/app/controllers/admin/auth_controller.rb +45 -0
  75. data/lib/generators/admin/templates/app/controllers/admin/model_controller.rb.erb +43 -0
  76. data/lib/generators/admin/templates/app/views/admin/admin/_sidebar.html.erb +12 -0
  77. data/lib/generators/admin/templates/app/views/admin/admin/index.html.erb +22 -0
  78. data/lib/generators/admin/templates/app/views/admin/auth/login.html.erb +22 -0
  79. data/lib/generators/admin/templates/app/views/admin/model/_form.html.erb +21 -0
  80. data/lib/generators/admin/templates/app/views/admin/model/edit.html.erb +8 -0
  81. data/lib/generators/admin/templates/app/views/admin/model/index.html.erb +33 -0
  82. data/lib/generators/admin/templates/app/views/admin/model/new.html.erb +8 -0
  83. data/lib/generators/admin/templates/app/views/admin/model/show.html.erb +28 -0
  84. data/lib/generators/admin/templates/app/views/layouts/admin.html.erb +47 -0
  85. data/lib/generators/admin/templates/config/admin.yml +2 -0
  86. data/lib/generators/admin/templates/script/new_admin +57 -0
  87. metadata +130 -0
@@ -0,0 +1,434 @@
1
+ /* main styles */
2
+ body {
3
+ margin:0;
4
+ padding:0;
5
+ background:#BBD9EE;
6
+ color:#000;
7
+ font-family:tahoma,arial,sans-serif;
8
+ font-size:11px;
9
+ }
10
+ form {
11
+ margin:0;
12
+ padding:0
13
+ }
14
+ img {border:none;}
15
+ a {color:#060606;text-decoration: none}
16
+ a:hover {text-decoration: underline}
17
+ input {vertical-align:middle}
18
+ .floatleft {float:left !important}
19
+ .floatright {float:right !important}
20
+ .clear {clear:both !important}
21
+ .bold {font-weight:bold !important}
22
+ .normal {font-weight:normal !important}
23
+ .block {display:block !important}
24
+ input.text,
25
+ select,
26
+ textarea {
27
+ font-family:arial,sans-serif;
28
+ color:#333;
29
+ font-size:12px;
30
+ vertical-align:middle;
31
+ }
32
+ input.text {
33
+ padding:1px 0 0 4px;
34
+ height:14px;
35
+ font-weight:normal;
36
+ }
37
+ /* main container */
38
+ #main {
39
+ width:992px;
40
+ margin:0 auto;
41
+ }
42
+ /* header */
43
+ #header {
44
+ position:relative;
45
+ width:992px;
46
+ height:106px;
47
+ }
48
+ /* site logo */
49
+ a.logo {
50
+ position:absolute;
51
+ top:5px;
52
+ left:20px;
53
+ }
54
+
55
+ /* header tabs */
56
+ #top-navigation {
57
+ position:absolute;
58
+ top:73px;
59
+ left:20px;
60
+ margin:0;
61
+ padding:0;
62
+ list-style:none;
63
+ }
64
+ #top-navigation li {
65
+ float:left;
66
+ margin:0 4px 0 0;
67
+ height:34px;
68
+ }
69
+ #top-navigation li a {
70
+ float:left;
71
+ display:block;
72
+ height:20px;
73
+ line-height:19px;
74
+ margin-top:9px;
75
+ color:#606060;
76
+ padding:4px 10px 0 10px;
77
+ border-top-left-radius: 4px;
78
+ border-top-right-radius: 4px;
79
+ -moz-border-radius-topleft: 4px;
80
+ -moz-border-radius-topright: 4px;
81
+ -webkit-border-top-left-radius: 4px;
82
+ -webkit-border-top-right-radius: 4px;
83
+ background:#e7f1f8;
84
+ }
85
+ #top-navigation li a:hover {
86
+ border:1px #ff7300 solid;
87
+ border-bottom: none;
88
+ background:#fff;
89
+ margin: 8px -1px;
90
+ }
91
+ #top-navigation li a.active {
92
+ padding:6px 10px 0 10px;
93
+ height:27px;
94
+ border:1px #ff7300 solid;
95
+ border-bottom:none;
96
+ margin:0;
97
+ background:white;
98
+ }
99
+
100
+ /* middle */
101
+ #middle {
102
+ float:left;
103
+ width:973px;
104
+ background:#fff;
105
+ border: 1px solid #ff6f00;
106
+ border-radius: 7px;
107
+ -moz-border-radius: 7px;
108
+ -webkit-border-radius: 7px;
109
+ -moz-box-shadow: 3px 3px 9px #666;
110
+ -webkit-box-shadow: 3px 3px 9px #666;
111
+ box-shadow: 3px 3px 9px #666;
112
+ padding:10px 0 0 0;
113
+ }
114
+ /* left column */
115
+ #left-column {
116
+ float:left;
117
+ padding:1px 14px 0 12px;
118
+ width:151px;
119
+ }
120
+ /* right column */
121
+ #right-column {
122
+ float:right;
123
+ padding:0 9px 0 0;
124
+ width:133px;
125
+ }
126
+ /* center column */
127
+ #center-column {
128
+ float:left;
129
+ width:614px;
130
+ background:url(../img/bg-center-column.jpg) top left no-repeat;
131
+ background:-webkit-gradient(
132
+ linear,
133
+ left top,
134
+ right bottom,
135
+ color-stop(0, rgb(221,221,221)),
136
+ color-stop(0.5, rgb(255,255,255))
137
+ );
138
+ background:-moz-linear-gradient(
139
+ left top,
140
+ rgb(221,221,221) 0%,
141
+ rgb(255,255,255) 50%
142
+ );
143
+ border-radius: 15px;
144
+ -moz-border-radius: 15px;
145
+ -webkit-border-radius: 15px;
146
+ min-height:584px;
147
+ padding:12px 16px 0 13px;
148
+ }
149
+ * html #center-column {height:584px;}
150
+
151
+ /* footer */
152
+ #footer {
153
+ float:left;
154
+ width:100%;
155
+ height:15px;
156
+ }
157
+ #footer p {
158
+ margin: 10px;
159
+ }
160
+
161
+ /* left column styles */
162
+ #left-column a {color:#3E3E3E;}
163
+ #left-column h3 {
164
+ font-size:11px;
165
+ margin:0;
166
+ color:#fff;
167
+ background:#ff9500;
168
+ background:-webkit-gradient(
169
+ linear,
170
+ left top,
171
+ left bottom,
172
+ color-stop(0, rgb(255,149,0)),
173
+ color-stop(1, rgb(255,111,0))
174
+ );
175
+ background:-moz-linear-gradient(
176
+ center top,
177
+ rgb(255,149,0) 0%,
178
+ rgb(255,111,0) 100%
179
+ );
180
+ border-radius: 7px;
181
+ -moz-border-radius: 7px;
182
+ -webkit-border-radius: 7px;
183
+ height:25px;
184
+ line-height:23px;
185
+ padding:0 0 0 9px;
186
+ }
187
+ ul.nav {
188
+ margin:0 0 11px 0;
189
+ border-bottom:2px solid #FF9600;
190
+ background:#ECEFE7;
191
+ list-style:none;
192
+ padding:0 2px;
193
+ }
194
+ ul.nav li {
195
+ padding:4px 4px 6px 5px;
196
+ border-bottom: 1px #666 dashed;
197
+ }
198
+ ul.nav a {
199
+ padding:0 0 0 12px;
200
+ background:url(/assets/admin/arrow.gif) no-repeat 0 4px;
201
+ }
202
+ ul.nav a:hover {
203
+ font-weight:bold;
204
+ }
205
+ ul.nav li:last-child {border:none;}
206
+
207
+ #left-column a.link {
208
+ display:block;
209
+ width:142px;
210
+ height:25px;
211
+ background:#c7cdbe;
212
+ background:-webkit-gradient(
213
+ linear,
214
+ left top,
215
+ left bottom,
216
+ color-stop(0, rgb(235,239,227)),
217
+ color-stop(1, rgb(199,205,190))
218
+ );
219
+ background:-moz-linear-gradient(
220
+ center top,
221
+ rgb(235,239,227) 0%,
222
+ rgb(199,205,190) 100%
223
+ );
224
+ border-radius: 7px;
225
+ -moz-border-radius: 7px;
226
+ -webkit-border-radius: 7px;
227
+ margin:0 0 4px 0;
228
+ font-weight:bold;
229
+ padding:0 0 0 9px;
230
+ line-height:25px;
231
+ color:#60635A;
232
+ }
233
+
234
+ /* center column styles */
235
+ .top-bar {
236
+ float:left;
237
+ width:603px;
238
+ border-left:2px solid #f70;
239
+ padding:0 0 0 9px;
240
+ margin:0 0 4px 0;
241
+ }
242
+ /* text page header */
243
+ .top-bar h1 {
244
+ font:20px/21px verdana,sans-serif;
245
+ color:#43729F;
246
+ margin:0 0 4px 0;
247
+ }
248
+ /* orange button */
249
+ .top-bar a.button {
250
+ float:right;
251
+ display:block;
252
+ height:15px;
253
+ text-align:center;
254
+ color:#fff;
255
+ text-transform:uppercase;
256
+ font-weight:bold;
257
+ padding:10px;
258
+ background: #ff6f00;
259
+ background: -webkit-gradient(
260
+ linear,
261
+ left top,
262
+ left bottom,
263
+ color-stop(0.2, rgb(255,154,76)),
264
+ color-stop(0.8, rgb(240,96,0))
265
+ );
266
+ background: -moz-linear-gradient(
267
+ center top,
268
+ rgb(255,154,76) 20%,
269
+ rgb(240,96,0) 80%
270
+ );
271
+ border-radius: 7px;
272
+ -moz-border-radius: 7px;
273
+ -webkit-border-radius: 7px;
274
+ }
275
+
276
+ /* bar with select */
277
+ .select-bar {
278
+ clear:both;
279
+ border-top:2px solid #f70;
280
+ border-bottom:2px solid #f70;
281
+ padding:5px 0 3px 0;
282
+ margin:0 0 17px 0;
283
+ }
284
+ .select-bar select {width:145px;margin:0 2px;}
285
+
286
+ /* table container */
287
+ div.table {
288
+ float:left;
289
+ position:relative;
290
+ width:614px;
291
+ margin:0 0 37px 0;
292
+ }
293
+ table.listing {
294
+ border-bottom:1px solid #9097A9;
295
+ background:#9097A9;
296
+ width:613px;
297
+ padding:0;
298
+ margin:0;
299
+ border:1px solid #9097A9;
300
+ border-top-left-radius: 10px;
301
+ border-top-right-radius: 10px;
302
+ -moz-border-radius-topleft: 10px;
303
+ -moz-border-radius-topright: 10px;
304
+ -webkit-border-top-left-radius: 10px;
305
+ -webkit-border-top-right-radius: 10px;
306
+ }
307
+ table.listing th {
308
+ border-top:0 !important;
309
+ }
310
+
311
+ table.listing th.full {border-left:0;border-right:0 !important;text-align:left;text-transform:uppercase;}
312
+ /* table styles */
313
+ table.listing td,
314
+ table.listing th {
315
+ border:1px solid #fff;
316
+ text-align:center;
317
+ }
318
+ table.listing th {
319
+ /*background:#9097A9;*/
320
+ color:#fff;
321
+ padding:5px;
322
+ }
323
+ table.listing td {
324
+ background:#D8D8D8;
325
+ color:#000;
326
+ padding:3px 5px;
327
+ }
328
+ table.listing tr:nth-child(odd) td {
329
+ background:#ECECEC;
330
+ }
331
+ table.listing .white td {
332
+ background:#fff;
333
+ }
334
+ table.listing th:first-child, table.listing td:first-child {border-left:0px solid #9097A9;text-align:left;}
335
+ table.listing th:last-child, table.listing td:last-child {border-right:0px solid #9097A9;}
336
+
337
+ table.listing th:first-child {
338
+ width: 177px;
339
+ border-left:0;
340
+ }
341
+
342
+ table.listing .style1 {font-weight:bold;color:#FF7A00;}
343
+ table.listing .style2 {font-weight:bold;padding-left:16px;}
344
+ table.listing .style3 {padding-left:25px;}
345
+ table.listing .style4 {padding-left:35px;}
346
+ table.form td:last-child {padding:1px 0 1px 5px;text-align:left;}
347
+ table.form th,
348
+ table.form td {padding-left:10px;}
349
+ table.form input.text {width:262px}
350
+
351
+ /* table select */
352
+ div.table .select {
353
+ float:right;
354
+ margin:2px 1px 0 0;
355
+ width:176px;
356
+ height:25px;
357
+ background:#9097A9;
358
+ color:#fff;
359
+ border-bottom-left-radius: 8px;
360
+ border-bottom-right-radius: 8px;
361
+ -moz-border-radius-bottomleft: 8px;
362
+ -moz-border-radius-bottomright: 8px;
363
+ -webkit-border-bottom-left-radius: 8px;
364
+ -webkit-border-bottom-right-radius: 8px;
365
+ }
366
+ div.table .select strong {
367
+ float:left;
368
+ padding:5px 0 0 5px;
369
+ }
370
+ div.table .select select {
371
+ float:right;
372
+ width:78px;
373
+ margin:2px 3px 0 0;
374
+ text-align:right;
375
+ }
376
+
377
+ /* right column header */
378
+ #right-column .h {
379
+ float:left;
380
+ background:#7E878A;
381
+ border:1px solid #B8B8B8;
382
+ border-bottom:0;
383
+ padding:3px 10px;
384
+ color:#fff;
385
+ text-transform:uppercase;
386
+ }
387
+ /* right column box */
388
+ #right-column .box {
389
+ float:left;
390
+ width:121px;
391
+ padding:5px;
392
+ border:1px solid #B8B8B8;
393
+ background:#EBEBEB;
394
+ margin:0 0 15px 0;
395
+ }
396
+
397
+ /* right column buttons */
398
+ .buttons {
399
+ clear:both;
400
+ text-align:center;
401
+ padding:30px 0 15px 0;
402
+ }
403
+ .buttons input {margin:0 0 6px 0;}
404
+
405
+ div.actions {
406
+ padding:15px 5px;
407
+ text-align:right;
408
+ }
409
+
410
+ a.action {
411
+ padding:3px 0;
412
+ padding-left:18px;
413
+ margin:5px 5px;
414
+ }
415
+
416
+ a.action.edit {
417
+ background:url(/assets/admin/icn_edit.png) no-repeat 0 2px;
418
+ }
419
+
420
+ a.action.destroy {
421
+ background:url(/assets/admin/icn_trash.png) no-repeat 0 2px;
422
+ }
423
+
424
+ a.action.list {
425
+ background:url(/assets/admin/icn_categories.png) no-repeat 0 2px;
426
+ }
427
+
428
+ a.action.add {
429
+ background:url(/assets/admin/icn_plus.png) no-repeat 0 2px;
430
+ }
431
+
432
+ a.action.suspend {
433
+ background:url(/assets/admin/icn_suspend.png) no-repeat 0 2px;
434
+ }
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the admin/auth controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,24 @@
1
+ class Admin::AdminController < ApplicationController
2
+ before_filter :is_admin?
3
+
4
+ layout 'admin'
5
+
6
+ def index #dashboard
7
+ 'Dashboard here'
8
+ end
9
+
10
+ protected
11
+ def init_session(admin_id)
12
+ session[:admin] = admin_id
13
+ end
14
+
15
+ def is_admin?
16
+ if session[:admin].nil?
17
+ flash[:warning] = "Login first"
18
+ redirect_to admin_login_path
19
+ false
20
+ else
21
+ true
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,45 @@
1
+ require 'digest/sha2'
2
+ class Admin::AuthController < Admin::AdminController
3
+ skip_before_filter :is_admin?, :only => [:login, :authorize]
4
+
5
+ def login
6
+ unless session[:admin].nil?
7
+ redirect_to admin_path
8
+ end
9
+ end
10
+
11
+ def authorize
12
+ login = params[:login]
13
+ password = params[:password]
14
+ #open file
15
+ f = File.open(Rails.root + "config/admin.yml", "r")
16
+ admins = YAML::load f.read
17
+ f.close
18
+
19
+ #find
20
+ admin = admins.find {|admin| admin[:id] == login}
21
+
22
+ unless admin.nil?
23
+ #match password
24
+ if admin[:password_hash] == Digest::SHA512.hexdigest(password + admin[:password_salt])
25
+ # login succeeded
26
+ flash[:success] = "Login Succeeded."
27
+ init_session(login)
28
+ redirect_to admin_path
29
+ else
30
+ flash[:error] = "Password incorrect."
31
+ redirect_to admin_login_path
32
+ end
33
+ else
34
+ flash[:error] = "Admin \"#{login}\" doesn't exist"
35
+ redirect_to admin_login_path
36
+ end
37
+ end
38
+
39
+ def logout
40
+ flash[:success] = "Logout Succeeded."
41
+ session[:user_id] = nil
42
+ reset_session
43
+ redirect_to admin_path
44
+ end
45
+ end
@@ -0,0 +1,43 @@
1
+ <% model_name = @model.name.underscore -%>
2
+ <% modelName = @model.name -%>
3
+ class Admin::<%=@model.name.pluralize %>Controller < Admin::AdminController
4
+ def index
5
+ @<%=model_name.pluralize %> = <%= modelName%>.all
6
+ end
7
+
8
+ def show
9
+ @<%=model_name %> = <%= modelName%>.find(params[:id])
10
+ end
11
+
12
+ def new
13
+ @<%=model_name %> = <%= modelName%>.new
14
+ end
15
+
16
+ def edit
17
+ @<%=model_name %> = <%= modelName%>.find(params[:id])
18
+ end
19
+
20
+ def create
21
+ @<%=model_name %> = <%= modelName%>.new(params[:<%= model_name %>])
22
+ if @<%= model_name%>.save
23
+ redirect_to admin_<%=model_name.pluralize%>_path
24
+ else
25
+ render new_admin_<%=model_name%>_path
26
+ end
27
+ end
28
+
29
+ def update
30
+ @<%=model_name %> = <%= modelName%>.find(params[:id])
31
+ if @<%=model_name %>.update_attributes(params[:<%=model_name%>])
32
+ redirect_to admin_<%=model_name%>_path(@<%=model_name %>)
33
+ else
34
+ render edit_admin_<%=model_name %>_path
35
+ end
36
+ end
37
+
38
+ def destroy
39
+ @<%=model_name %> = <%= modelName%>.find(params[:id])
40
+ @<%=model_name %>.destroy
41
+ redirect_to admin_<%= model_name.pluralize %>_path
42
+ end
43
+ end
@@ -0,0 +1,12 @@
1
+ <% @models.keys.each do |k|
2
+ @models[k].each do |model| -%>
3
+ <h3><%= model.name %></h3>
4
+ <ul class="nav">
5
+ <li><%%= link_to '<%= model.name%>', admin_<%=model.name.underscore.pluralize %>_path %></li>
6
+ </ul>
7
+ <%- end
8
+ end -%>
9
+
10
+ <%% unless session[:admin].nil? -%>
11
+ <%%= link_to 'Logout', admin_logout_path, :class => 'link' %>
12
+ <%% end -%>
@@ -0,0 +1,22 @@
1
+ <div class="top-bar">
2
+ <h1>Dashboard</h1>
3
+ </div>
4
+ <div class="table">
5
+ <table class="listing" cellpadding="0" cellspacing="0">
6
+ <tr>
7
+ <th style="width:40px;">Name</th>
8
+ <th>URL</th>
9
+ <th>Email</th>
10
+ <th>Created At</th>
11
+ </tr>
12
+
13
+ <tr>
14
+ <td>
15
+ <%= link_to 'John Doe', '#' %>
16
+ </td>
17
+ <td></td>
18
+ <td></td>
19
+ <td></td>
20
+ </tr>
21
+ </table>
22
+ </div>
@@ -0,0 +1,22 @@
1
+ <div class="table">
2
+ <%= form_tag admin_authorize_path do %>
3
+ <table class="listing form" cellspacing="0" cellpadding="0">
4
+ <tr>
5
+ <th class="full" colspan="2">Sign in</th>
6
+ </tr>
7
+
8
+ <tr>
9
+ <td><strong>ID</strong></td>
10
+ <td><%= text_field_tag :login, nil, :class => 'text' %></td>
11
+ </tr>
12
+
13
+ <tr>
14
+ <td><strong>Password</strong></td>
15
+ <td><%= password_field_tag :password, nil, :class => 'text' %></td>
16
+ </tr>
17
+ </table>
18
+ <div class="select" style="text-align:center;">
19
+ <%= submit_tag 'submit' %>
20
+ </div>
21
+ <% end -%>
22
+ </div>
@@ -0,0 +1,21 @@
1
+ <% model_name = @model.name.underscore -%>
2
+ <% modelName = @model.name -%>
3
+
4
+ <%%= form_for [:admin, @<%=model_name%>] do |f| %>
5
+ <div class="table">
6
+ <table class="listing form" cellpadding="0" cellspacing="0">
7
+ <th class="full" colspan="2">Adding a new <%= modelName %></th>
8
+ <%@fields.each do |field_name| -%>
9
+ <tr>
10
+ <td><strong><%=field_name %></strong></td>
11
+ <td>
12
+ <%%= f.text_field :<%=field_name %>%>
13
+ </td>
14
+ </tr>
15
+ <%end -%>
16
+ </table>
17
+ </div>
18
+ <div class="actions">
19
+ <%%= f.submit %>
20
+ </div>
21
+ <%% end -%>
@@ -0,0 +1,8 @@
1
+ <% model_name = @model.name.underscore -%>
2
+ <% modelName = @model.name -%>
3
+ <div class="top-bar">
4
+ <h1>Edit <%= modelName %></h1>
5
+ </div>
6
+
7
+ <%%= render 'form' %>
8
+
@@ -0,0 +1,33 @@
1
+ <% model_name = @model.name.underscore -%>
2
+ <% modelName = @model.name -%>
3
+ <div class="table">
4
+ <table class="listing" cellpadding="0" cellspacing="0">
5
+ <tr>
6
+ <% @fields.each do |field_name| -%>
7
+ <th><%= field_name %></th>
8
+ <% end -%>
9
+ </tr>
10
+ <%% @<%=model_name.pluralize %>.each do |<%=model_name %>| -%>
11
+ <tr>
12
+ <% @fields.each do |field_name| -%>
13
+ <td>
14
+ <% if @@reserved_title_names.include? field_name -%>
15
+ <%%= link_to "#{<%=model_name%>.<%=field_name %>}", admin_<%=model_name%>_path(<%=model_name %>) %>
16
+ <% else -%>
17
+ <%%= <%=model_name%>.<%=field_name %> %>
18
+ <% end -%>
19
+ </td>
20
+ <% end -%>
21
+ </tr>
22
+ <%% end %>
23
+ <%% if @<%=model_name.pluralize %>.empty? %>
24
+ <tr>
25
+ <td colspan="<%=@fields.count %>">No records</td>
26
+ </tr>
27
+ <%% end %>
28
+ </table>
29
+ </div>
30
+
31
+ <div class="actions">
32
+ <a href="<%%= new_admin_<%=model_name.underscore%>_path %>" class="action add">New <%=modelName %></a>
33
+ </div>
@@ -0,0 +1,8 @@
1
+ <% model_name = @model.name.underscore -%>
2
+ <% modelName = @model.name -%>
3
+ <div class="top-bar">
4
+ <h1>Add a new <%= modelName %></h1>
5
+ </div>
6
+
7
+ <%%= render 'form' %>
8
+