cdamian-admin 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +1 -1
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/app/controllers/admin/base_controller.rb +59 -0
- data/app/controllers/admin/dashboard_controller.rb +4 -0
- data/app/controllers/admin/moderator_sessions_controller.rb +26 -0
- data/app/controllers/admin/moderators_controller.rb +67 -0
- data/app/helpers/admin/base_helper.rb +24 -0
- data/app/helpers/admin/dashboard_helper.rb +2 -0
- data/app/helpers/admin/moderator_sessions_helper.rb +2 -0
- data/app/helpers/admin/moderators_helper.rb +2 -0
- data/app/models/moderator.rb +6 -0
- data/app/models/moderator_session.rb +3 -0
- data/app/views/admin/dashboard/index.html.erb +3 -0
- data/app/views/admin/moderator_sessions/new.html.erb +57 -0
- data/app/views/admin/moderators/_form.erb +42 -0
- data/app/views/admin/moderators/edit.html.erb +25 -0
- data/app/views/admin/moderators/index.html.erb +35 -0
- data/app/views/admin/moderators/new.html.erb +25 -0
- data/app/views/layouts/admin.html.erb +45 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20090810030104_create_moderators.rb +39 -0
- data/lib/admin.rb +29 -0
- data/public/images/admin/background.png +0 -0
- data/public/images/admin/button_back.png +0 -0
- data/public/images/admin/button_backup.png +0 -0
- data/public/images/admin/button_cancel.png +0 -0
- data/public/images/admin/button_delete.png +0 -0
- data/public/images/admin/button_insert.png +0 -0
- data/public/images/admin/button_login.png +0 -0
- data/public/images/admin/button_middle.png +0 -0
- data/public/images/admin/button_print.png +0 -0
- data/public/images/admin/button_restore.png +0 -0
- data/public/images/admin/button_right.png +0 -0
- data/public/images/admin/button_save.png +0 -0
- data/public/images/admin/button_send.png +0 -0
- data/public/images/admin/column_left.png +0 -0
- data/public/images/admin/column_right.png +0 -0
- data/public/images/admin/footer.png +0 -0
- data/public/images/admin/header.png +0 -0
- data/public/images/admin/login.png +0 -0
- data/public/images/admin/login_bottom.png +0 -0
- data/public/images/admin/login_top.png +0 -0
- data/public/images/admin/tab_1.png +0 -0
- data/public/images/admin/tab_2.png +0 -0
- data/public/images/admin/tab_3.png +0 -0
- data/public/images/admin/top_1.png +0 -0
- data/public/stylesheets/admin/application.css +430 -0
- data/tasks/admin_tasks.rake +7 -0
- data/test/fixtures/moderators.yml +7 -0
- data/test/functional/admin/base_controller_test.rb +8 -0
- data/test/functional/admin/dashboard_controller_test.rb +8 -0
- data/test/functional/admin/moderator_sessions_controller_test.rb +8 -0
- data/test/functional/admin/moderators_controller_test.rb +8 -0
- data/test/unit/helpers/admin/base_helper_test.rb +4 -0
- data/test/unit/helpers/admin/dashboard_helper_test.rb +4 -0
- data/test/unit/helpers/admin/moderator_sessions_helper_test.rb +4 -0
- data/test/unit/helpers/admin/moderators_helper_test.rb +4 -0
- data/test/unit/moderator_test.rb +8 -0
- metadata +68 -4
data/config/routes.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
2
|
+
map.admin '/admin', :controller => "/admin/base", :action => "admin_index"
|
3
|
+
map.namespace :admin do |admin|
|
4
|
+
admin.dashboard '/dashboard', :controller => 'dashboard'
|
5
|
+
admin.resource :moderator_session, :as => "session", :only => [:new,:create,:destroy]
|
6
|
+
admin.resource :account, :controller => "moderators", :only => [:edit,:update]
|
7
|
+
admin.resources :moderators, :except => [:show]
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class CreateModerators < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :moderators do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.string :email, :null => false
|
6
|
+
t.string :crypted_password, :null => false
|
7
|
+
t.string :password_salt, :null => false
|
8
|
+
t.string :persistence_token, :null => false
|
9
|
+
t.string :perishable_token, :null => false
|
10
|
+
t.integer :login_count, :default => 0, :null => false
|
11
|
+
t.integer :failed_login_count, :default => 0, :null => false
|
12
|
+
t.datetime :last_request_at
|
13
|
+
t.datetime :last_login_at
|
14
|
+
t.datetime :current_login_at
|
15
|
+
t.string :last_login_ip
|
16
|
+
t.string :current_login_ip
|
17
|
+
t.boolean :admin, :null => false, :default => false
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
|
21
|
+
add_index :moderators, :email
|
22
|
+
add_index :moderators, :persistence_token
|
23
|
+
add_index :moderators, :perishable_token
|
24
|
+
add_index :moderators, :last_request_at
|
25
|
+
|
26
|
+
moderator = Moderator.new do |m|
|
27
|
+
m.name = "Admin Admin"
|
28
|
+
m.email = "admin@example.com"
|
29
|
+
m.password = "adminadmin"
|
30
|
+
m.password_confirmation = "adminadmin"
|
31
|
+
m.admin = true
|
32
|
+
end
|
33
|
+
moderator.save!
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.down
|
37
|
+
drop_table :moderators
|
38
|
+
end
|
39
|
+
end
|
data/lib/admin.rb
CHANGED
@@ -10,5 +10,34 @@ module Admin
|
|
10
10
|
def root
|
11
11
|
File.dirname(__FILE__) + '/..'
|
12
12
|
end
|
13
|
+
|
14
|
+
def tabs
|
15
|
+
@@tabs ||= []
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_tab(options = {})
|
19
|
+
name = options.delete(:name)
|
20
|
+
path = options.delete(:path)
|
21
|
+
req_admin = options.delete(:admin_required)
|
22
|
+
tabs << Admin::Tab.new(name,path,req_admin)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Tab
|
27
|
+
attr_accessor :name, :path, :admin_required
|
28
|
+
|
29
|
+
def initialize(str_name,str_path,bool_admin_required)
|
30
|
+
@name = str_name.to_s
|
31
|
+
@path = str_path.to_s
|
32
|
+
@admin_required = bool_admin_required ? true : false
|
33
|
+
end
|
34
|
+
|
35
|
+
def display_for?(moderator)
|
36
|
+
admin_required ? moderator.admin? : true
|
37
|
+
end
|
38
|
+
|
13
39
|
end
|
14
40
|
end
|
41
|
+
|
42
|
+
Admin.add_tab :name => "Dashboard", :path => "/admin/dashboard"
|
43
|
+
Admin.add_tab :name => "Moderators", :path => "/admin/moderators", :admin_required => true
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,430 @@
|
|
1
|
+
/* Admin UI */
|
2
|
+
html {
|
3
|
+
margin: 0;
|
4
|
+
padding: 0;
|
5
|
+
height: 100%;
|
6
|
+
}
|
7
|
+
|
8
|
+
body {
|
9
|
+
background:transparent url(/images/admin/background.png) repeat-x scroll 0 75px;
|
10
|
+
height:100%;
|
11
|
+
margin:0;
|
12
|
+
padding:0;
|
13
|
+
}
|
14
|
+
|
15
|
+
body, td, th, input, select, textarea, option, optgroup {
|
16
|
+
color:#333333;
|
17
|
+
font-family:Verdana,Arial,Helvetica,sans-serif;
|
18
|
+
font-size:12px;
|
19
|
+
}
|
20
|
+
|
21
|
+
a, a:visited {
|
22
|
+
color:#003366;
|
23
|
+
cursor:pointer;
|
24
|
+
}
|
25
|
+
|
26
|
+
form {
|
27
|
+
margin: 0;
|
28
|
+
padding: 0;
|
29
|
+
}
|
30
|
+
|
31
|
+
#header {
|
32
|
+
height: 30px;
|
33
|
+
background: #000000 url('/images/admin/header.png');
|
34
|
+
border-bottom: 2px solid #DEE57B;
|
35
|
+
}
|
36
|
+
#header .div1 {
|
37
|
+
width: 800px;
|
38
|
+
position: relative;
|
39
|
+
left: 50%;
|
40
|
+
margin-left: -400px;
|
41
|
+
}
|
42
|
+
#header .div2 {
|
43
|
+
font: bold 16px Arial, sans-serif;
|
44
|
+
color: #FFFFFF;
|
45
|
+
margin: 5px 0px 0px 0px;
|
46
|
+
float: left;
|
47
|
+
}
|
48
|
+
#header .div3 {
|
49
|
+
color: #999999;
|
50
|
+
margin: 7px 0px 0px 0px;
|
51
|
+
float: right;
|
52
|
+
}
|
53
|
+
#header .div3 b {
|
54
|
+
color: #FFFFFF;
|
55
|
+
}
|
56
|
+
#header .div3 a, #header .div3 a:visited {
|
57
|
+
color: #FFFFFF;
|
58
|
+
}
|
59
|
+
|
60
|
+
#menu {
|
61
|
+
background: #303F4A;
|
62
|
+
height: 40px;
|
63
|
+
border-top: 2px solid #849721;
|
64
|
+
border-bottom: 1px solid #FFFFFF;
|
65
|
+
position: relative;
|
66
|
+
z-index: 1;
|
67
|
+
}
|
68
|
+
|
69
|
+
#nav {
|
70
|
+
width: 800px;
|
71
|
+
position: relative;
|
72
|
+
left: 50%;
|
73
|
+
margin: 0;
|
74
|
+
padding: 0;
|
75
|
+
margin-left: -400px;
|
76
|
+
clear: both;
|
77
|
+
height: 40px;
|
78
|
+
float: left;
|
79
|
+
}
|
80
|
+
|
81
|
+
#nav ul {
|
82
|
+
float: left;
|
83
|
+
list-style: none;
|
84
|
+
margin: 0;
|
85
|
+
padding: 0;
|
86
|
+
background: #4A6275;
|
87
|
+
}
|
88
|
+
|
89
|
+
#nav a {
|
90
|
+
display: block;
|
91
|
+
color: #FFFFFF;
|
92
|
+
text-decoration: none;
|
93
|
+
padding: 5px;
|
94
|
+
}
|
95
|
+
|
96
|
+
#nav li a {
|
97
|
+
padding: 17px 0px 9px 0px;
|
98
|
+
margin-right: 5px;
|
99
|
+
width: 100px;
|
100
|
+
text-align: center;
|
101
|
+
background: url(/images/admin/tab_1.png) bottom no-repeat;
|
102
|
+
color: #C2D4DD;
|
103
|
+
}
|
104
|
+
|
105
|
+
#nav ul li {
|
106
|
+
color: #FFFFFF;
|
107
|
+
}
|
108
|
+
|
109
|
+
#nav li strong a {
|
110
|
+
background: url(/images/admin/tab_2.png) bottom no-repeat;
|
111
|
+
color: #333333;
|
112
|
+
}
|
113
|
+
|
114
|
+
#nav li {
|
115
|
+
float: left;
|
116
|
+
list-style: none;
|
117
|
+
}
|
118
|
+
|
119
|
+
#container {
|
120
|
+
min-height: 350px;
|
121
|
+
width: 826px;
|
122
|
+
position: relative;
|
123
|
+
left: 50%;
|
124
|
+
margin-left: -413px;
|
125
|
+
}
|
126
|
+
|
127
|
+
#column_left {
|
128
|
+
width: 13px;
|
129
|
+
height: 264px;
|
130
|
+
float: left;
|
131
|
+
background: url(/images/admin/column_left.png) no-repeat;
|
132
|
+
}
|
133
|
+
|
134
|
+
#column_right {
|
135
|
+
width: 13px;
|
136
|
+
height: 264px;
|
137
|
+
float: left;
|
138
|
+
background: url(/images/admin/column_right.png) no-repeat;
|
139
|
+
}
|
140
|
+
|
141
|
+
#content {
|
142
|
+
width: 770px;
|
143
|
+
float: left;
|
144
|
+
padding: 10px 15px 15px 15px;
|
145
|
+
background: #FFFFFF;
|
146
|
+
}
|
147
|
+
|
148
|
+
#footer {
|
149
|
+
clear: both;
|
150
|
+
width: 800px;
|
151
|
+
height: 50px;
|
152
|
+
padding-top: 10px;
|
153
|
+
position: relative;
|
154
|
+
left: 50%;
|
155
|
+
margin-left: -400px;
|
156
|
+
text-align: center;
|
157
|
+
background: #303F4A url(/images/admin/footer.png) bottom no-repeat;
|
158
|
+
}
|
159
|
+
|
160
|
+
#footer a {
|
161
|
+
color: #FFFFFF;
|
162
|
+
text-decoration: underline;
|
163
|
+
}
|
164
|
+
|
165
|
+
#loginbox {
|
166
|
+
left:50%;
|
167
|
+
margin-left:-172px;
|
168
|
+
margin-top:50px;
|
169
|
+
position:relative;
|
170
|
+
width:344px;
|
171
|
+
}
|
172
|
+
|
173
|
+
#loginbox .div1 {
|
174
|
+
background:#303F4A url(/images/admin/login_top.png) no-repeat scroll center top;
|
175
|
+
color:#FFFFFF;
|
176
|
+
padding:10px;
|
177
|
+
}
|
178
|
+
|
179
|
+
#loginbox .div2 {
|
180
|
+
background:#F7F7F7 none repeat scroll 0 0;
|
181
|
+
border-left:1px solid #CCCCCC;
|
182
|
+
border-right:1px solid #CCCCCC;
|
183
|
+
}
|
184
|
+
|
185
|
+
#loginbox .div3 {
|
186
|
+
background:#F7F7F7 url(/images/admin/login_bottom.png) no-repeat scroll center bottom;
|
187
|
+
height:5px;
|
188
|
+
}
|
189
|
+
|
190
|
+
#loginbox table {
|
191
|
+
width:100%;
|
192
|
+
}
|
193
|
+
|
194
|
+
#loginbox table td {
|
195
|
+
padding:10px;
|
196
|
+
}
|
197
|
+
|
198
|
+
#loginbox table td input {
|
199
|
+
margin-top:4px
|
200
|
+
}
|
201
|
+
|
202
|
+
#loginbox .flash_error, #loginbox .flash_notice {
|
203
|
+
border-left:0 none;
|
204
|
+
border-right:0 none;
|
205
|
+
border-top:0 none;
|
206
|
+
margin-bottom:0;
|
207
|
+
margin-top:0;
|
208
|
+
}
|
209
|
+
|
210
|
+
.heading {
|
211
|
+
clear:both;
|
212
|
+
height:30px;
|
213
|
+
margin-bottom:15px;
|
214
|
+
}
|
215
|
+
|
216
|
+
.heading h1 {
|
217
|
+
color:#333333;
|
218
|
+
float:left;
|
219
|
+
font-size:24px;
|
220
|
+
font-weight:normal;
|
221
|
+
margin:0;
|
222
|
+
}
|
223
|
+
|
224
|
+
.button {
|
225
|
+
display:inline-block;
|
226
|
+
text-decoration:none;
|
227
|
+
}
|
228
|
+
|
229
|
+
.button .button_login {
|
230
|
+
background:transparent url(/images/admin/button_login.png) no-repeat scroll 0 0;
|
231
|
+
}
|
232
|
+
|
233
|
+
.button .button_insert {
|
234
|
+
background: url(/images/admin/button_insert.png) no-repeat;
|
235
|
+
}
|
236
|
+
|
237
|
+
.button .button_delete {
|
238
|
+
background: url(/images/admin/button_delete.png) no-repeat;
|
239
|
+
}
|
240
|
+
|
241
|
+
.button .button_save {
|
242
|
+
background: url(/images/admin/button_save.png) no-repeat;
|
243
|
+
}
|
244
|
+
|
245
|
+
.button .button_cancel {
|
246
|
+
background: url(/images/admin/button_cancel.png) no-repeat;
|
247
|
+
}
|
248
|
+
|
249
|
+
.button .button_send {
|
250
|
+
background: url(/images/admin/button_send.png) no-repeat;
|
251
|
+
}
|
252
|
+
|
253
|
+
.button .button_back {
|
254
|
+
background: url(/images/admin/button_back.png) no-repeat;
|
255
|
+
}
|
256
|
+
|
257
|
+
.button .button_restore {
|
258
|
+
background: url(/images/admin/button_restore.png) no-repeat;
|
259
|
+
}
|
260
|
+
|
261
|
+
.button .button_backup {
|
262
|
+
background: url(/images/admin/button_backup.png) no-repeat;
|
263
|
+
}
|
264
|
+
|
265
|
+
.button .button_print {
|
266
|
+
background: url(/images/admin/button_print.png) no-repeat;
|
267
|
+
}
|
268
|
+
|
269
|
+
.button .button_left {
|
270
|
+
display:block;
|
271
|
+
float:left;
|
272
|
+
height:30px;
|
273
|
+
width:30px;
|
274
|
+
}
|
275
|
+
|
276
|
+
.button .button_middle {
|
277
|
+
background:transparent url(/images/admin/button_middle.png) repeat-x scroll 0 0;
|
278
|
+
color:#333333;
|
279
|
+
display:block;
|
280
|
+
float:left;
|
281
|
+
padding-bottom:8px;
|
282
|
+
padding-top:8px;
|
283
|
+
}
|
284
|
+
|
285
|
+
.button .button_right {
|
286
|
+
background:transparent url(/images/admin/button_right.png) no-repeat scroll 0 0;
|
287
|
+
display:block;
|
288
|
+
float:left;
|
289
|
+
height:30px;
|
290
|
+
width:15px;
|
291
|
+
}
|
292
|
+
|
293
|
+
.buttons {
|
294
|
+
float:right;
|
295
|
+
}
|
296
|
+
|
297
|
+
.list {
|
298
|
+
border-collapse: collapse;
|
299
|
+
width: 100%;
|
300
|
+
background: #303F4A url(/images/admin/top_1.png) no-repeat;
|
301
|
+
}
|
302
|
+
|
303
|
+
.page .list {
|
304
|
+
background: #303F4A url(/images/admin/top_2.png) no-repeat;
|
305
|
+
}
|
306
|
+
|
307
|
+
.list input, .list select {
|
308
|
+
padding: 0;
|
309
|
+
margin: 5px 0px;
|
310
|
+
}
|
311
|
+
|
312
|
+
.list thead td {
|
313
|
+
color: #FFFFFF;
|
314
|
+
padding: 0px 5px;
|
315
|
+
}
|
316
|
+
|
317
|
+
.list thead td a {
|
318
|
+
text-decoration: none;
|
319
|
+
color: #FFFFFF;
|
320
|
+
}
|
321
|
+
|
322
|
+
.list tbody a {
|
323
|
+
text-decoration: underline;
|
324
|
+
}
|
325
|
+
|
326
|
+
.list tbody td {
|
327
|
+
vertical-align: middle;
|
328
|
+
padding: 0px 5px;
|
329
|
+
}
|
330
|
+
|
331
|
+
.list tbody tr.even {
|
332
|
+
background: #FFFFFF;
|
333
|
+
}
|
334
|
+
|
335
|
+
.list tbody tr.odd {
|
336
|
+
background: #E4EEF7;
|
337
|
+
}
|
338
|
+
|
339
|
+
.list .left {
|
340
|
+
text-align: left;
|
341
|
+
padding: 9px;
|
342
|
+
}
|
343
|
+
|
344
|
+
.list .right {
|
345
|
+
text-align: right;
|
346
|
+
padding: 9px;
|
347
|
+
}
|
348
|
+
|
349
|
+
.list .center {
|
350
|
+
text-align: center;
|
351
|
+
padding: 9px;
|
352
|
+
}
|
353
|
+
|
354
|
+
.list .asc {
|
355
|
+
padding-right: 15px;
|
356
|
+
background: url(/images/admin/asc.png) right center no-repeat;
|
357
|
+
}
|
358
|
+
|
359
|
+
.list .desc {
|
360
|
+
padding-right: 15px;
|
361
|
+
background: url(/images/admin/desc.png) right center no-repeat;
|
362
|
+
}
|
363
|
+
|
364
|
+
.tabs {
|
365
|
+
background: #303F4A url(/images/admin/top_1.png) top no-repeat;
|
366
|
+
height: 40px;
|
367
|
+
padding-left: 10px;
|
368
|
+
}
|
369
|
+
|
370
|
+
.tabs a {
|
371
|
+
padding: 17px 0px 9px 0px;
|
372
|
+
margin-right: 5px;
|
373
|
+
width: 100px;
|
374
|
+
text-align: center;
|
375
|
+
text-decoration: none;
|
376
|
+
background: url(/images/admin/tab_1.png) bottom no-repeat;
|
377
|
+
color: #C2D4DD;
|
378
|
+
display: block;
|
379
|
+
float: left;
|
380
|
+
}
|
381
|
+
|
382
|
+
.tabs a.selected {
|
383
|
+
color: #333333;
|
384
|
+
background: url(/images/admin/tab_3.png) bottom no-repeat;
|
385
|
+
}
|
386
|
+
|
387
|
+
.page {
|
388
|
+
min-height: 300px;
|
389
|
+
padding: 15px;
|
390
|
+
background: #F8F8F8;
|
391
|
+
border-bottom: 1px solid #EEEEEE;
|
392
|
+
}
|
393
|
+
|
394
|
+
.form {
|
395
|
+
width: 100%;
|
396
|
+
border-collapse: collapse;
|
397
|
+
margin-bottom: 15px;
|
398
|
+
}
|
399
|
+
|
400
|
+
.form td {
|
401
|
+
padding: 5px;
|
402
|
+
vertical-align: top;
|
403
|
+
}
|
404
|
+
|
405
|
+
.required {
|
406
|
+
color: #FF0000;
|
407
|
+
font-weight: bold;
|
408
|
+
}
|
409
|
+
|
410
|
+
.nodisp {
|
411
|
+
display:none;
|
412
|
+
}
|
413
|
+
|
414
|
+
.flash_error {
|
415
|
+
background:#FFDFE0;
|
416
|
+
border:1px solid #FF9999;
|
417
|
+
font-size:11px;
|
418
|
+
margin-bottom:15px;
|
419
|
+
padding:5px 0;
|
420
|
+
text-align:center;
|
421
|
+
}
|
422
|
+
|
423
|
+
.flash_notice {
|
424
|
+
padding: 5px 0px;
|
425
|
+
margin-bottom: 15px;
|
426
|
+
background: #E4F1C9;
|
427
|
+
border: 1px solid #A5BD71;
|
428
|
+
font-size: 11px;
|
429
|
+
text-align: center;
|
430
|
+
}
|