andy_admin 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/andy_admin/andy_admin_generator.rb +65 -0
- data/lib/generators/andy_admin/templates/admin.css +382 -0
- data/lib/generators/andy_admin/templates/admin.html.erb +46 -0
- data/lib/generators/andy_admin/templates/admin.js +5 -0
- data/lib/generators/andy_admin/templates/alert-overlay.png +0 -0
- data/lib/generators/andy_admin/templates/andy_admin_helper.rb +10 -0
- data/lib/generators/andy_admin/templates/andy_admin_menu.rb +10 -0
- data/lib/generators/andy_admin/templates/form_builder.rb +44 -0
- data/lib/generators/andy_admin/templates/login.css +158 -0
- data/lib/generators/andy_admin/templates/login.html.erb +44 -0
- data/lib/generators/andy_admin/templates/login.js +0 -0
- data/lib/generators/andy_admin/templates/menu.rb +38 -0
- metadata +89 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class AndyAdminGenerator < Rails::Generators::Base
|
4
|
+
argument :name, :type => :string, :banner => "name of your site", :default => "Your Site"
|
5
|
+
argument :hue, :type => :numeric, :banner => "colour hue, 0-255", :default => 92
|
6
|
+
|
7
|
+
source_root File.expand_path("templates", File.dirname(__FILE__))
|
8
|
+
|
9
|
+
def copy_files
|
10
|
+
template 'admin.html.erb', "app/views/layouts/admin.html.erb"
|
11
|
+
template "admin.css", "public/stylesheets/admin.css"
|
12
|
+
copy_file "alert-overlay.png", "public/images/admin-alert-overlay.png"
|
13
|
+
copy_file "admin.js", "public/javascripts/admin.js"
|
14
|
+
template "login.html.erb", "app/views/layouts/login.html.erb"
|
15
|
+
template "login.css", "public/stylesheets/login.css"
|
16
|
+
copy_file "login.js", "public/javascripts/login.js"
|
17
|
+
copy_file "andy_admin_menu.rb", "config/initializers/andy_admin_menu.rb"
|
18
|
+
copy_file "andy_admin_helper.rb", "app/helpers/andy_admin_helper.rb"
|
19
|
+
# copy_file "lib/andy_admin"
|
20
|
+
copy_file "menu.rb", "lib/andy_admin/menu.rb"
|
21
|
+
copy_file "form_builder.rb", "lib/andy_admin/form_builder.rb"
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def dark_colour
|
27
|
+
hsvToRGB(hue, 0.83, 0.35)
|
28
|
+
end
|
29
|
+
|
30
|
+
def light_colour
|
31
|
+
hsvToRGB(hue, 0.79, 0.50)
|
32
|
+
end
|
33
|
+
|
34
|
+
def highlight_colour
|
35
|
+
hsvToRGB(hue, 0.06, 0.99)
|
36
|
+
end
|
37
|
+
|
38
|
+
def rgbToHex(rgb)
|
39
|
+
"#%02x%02x%02x" % [(rgb[0] * 255), (rgb[1] * 255), (rgb[2] * 255)]
|
40
|
+
end
|
41
|
+
|
42
|
+
def hsvToRGB(h, s, v)
|
43
|
+
hi = (h/60.0).floor % 6
|
44
|
+
f = h/60.0 - (h/60.0).floor
|
45
|
+
p = v * (1 - s)
|
46
|
+
q = v * (1 - f * s)
|
47
|
+
t = v * (1 - (1 - f) * s)
|
48
|
+
@rgb = []
|
49
|
+
case hi
|
50
|
+
when 0
|
51
|
+
rgb = [v, t, p]
|
52
|
+
when 1
|
53
|
+
rgb = [q, v, p]
|
54
|
+
when 2
|
55
|
+
rgb = [p, v, t]
|
56
|
+
when 3
|
57
|
+
rgb = [p, q, v]
|
58
|
+
when 4
|
59
|
+
rgb = [t, p, v]
|
60
|
+
when 5
|
61
|
+
rgb = [v, p, t]
|
62
|
+
end
|
63
|
+
return rgbToHex(rgb)
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,382 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Colours used are:
|
4
|
+
|
5
|
+
Hue : <%= hue %>
|
6
|
+
Dark/Header : <%= dark_colour %>
|
7
|
+
Light/Tabs/links : <%= light_colour %>
|
8
|
+
Highlight/Headings : <%= highlight_colour %>
|
9
|
+
|
10
|
+
Search and replace these values to change them after installation
|
11
|
+
|
12
|
+
*/
|
13
|
+
|
14
|
+
/* ***************** GENERAL DEFINITIONS ***************** */
|
15
|
+
|
16
|
+
html, body {
|
17
|
+
background-color: #e5e5e5;
|
18
|
+
}
|
19
|
+
|
20
|
+
* {
|
21
|
+
font-size: 10pt;
|
22
|
+
text-align: left;
|
23
|
+
line-height: 1.2em;
|
24
|
+
}
|
25
|
+
|
26
|
+
a {
|
27
|
+
color: <%= light_colour %>;
|
28
|
+
text-decoration: none;
|
29
|
+
}
|
30
|
+
|
31
|
+
a:hover {
|
32
|
+
text-decoration: underline;
|
33
|
+
}
|
34
|
+
|
35
|
+
strong {
|
36
|
+
font-weight: bold;
|
37
|
+
}
|
38
|
+
|
39
|
+
em {
|
40
|
+
font-style: italic;
|
41
|
+
}
|
42
|
+
|
43
|
+
/* ***************** FLASH DEFINITIONS ***************** */
|
44
|
+
|
45
|
+
div.flash_error, div.flash_notice, div.flash_warning {
|
46
|
+
margin: 20px;
|
47
|
+
padding: 10px;
|
48
|
+
color: white;
|
49
|
+
font-weight: bold;
|
50
|
+
}
|
51
|
+
|
52
|
+
div.flash_error {
|
53
|
+
background: #b72c23;
|
54
|
+
}
|
55
|
+
|
56
|
+
div.flash_notice {
|
57
|
+
background: #2bb723;
|
58
|
+
}
|
59
|
+
|
60
|
+
div.flash_warning {
|
61
|
+
color: black;
|
62
|
+
background: #e8ed2d;
|
63
|
+
}
|
64
|
+
|
65
|
+
div.flash_error span, div.flash_notice span, div.flash_warning span {
|
66
|
+
float: right;
|
67
|
+
font-size: 80%;
|
68
|
+
cursor: pointer;
|
69
|
+
}
|
70
|
+
|
71
|
+
/* ***************** AWESOME BUTTONS ***************** */
|
72
|
+
|
73
|
+
/* From: http://www.zurb.com/ */
|
74
|
+
.awesome, .awesome:visited {
|
75
|
+
background: #222 url(/images/admin-alert-overlay.png) repeat-x;
|
76
|
+
display: inline-block;
|
77
|
+
padding: 5px 10px 6px;
|
78
|
+
color: #fff;
|
79
|
+
text-decoration: none;
|
80
|
+
-moz-border-radius: 18px;
|
81
|
+
-webkit-border-radius: 18px;
|
82
|
+
-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
|
83
|
+
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
|
84
|
+
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
|
85
|
+
border: 0px;
|
86
|
+
border-bottom: 1px solid rgba(0,0,0,0.25);
|
87
|
+
position: relative;
|
88
|
+
cursor: pointer;
|
89
|
+
}
|
90
|
+
|
91
|
+
.awesome:hover { background-color: #111; color: #fff; }
|
92
|
+
.awesome:active { top: 1px; }
|
93
|
+
.small.awesome, .small.awesome:visited { font-size: 11px; padding: ; }
|
94
|
+
.awesome, .awesome:visited,
|
95
|
+
.medium.awesome, .medium.awesome:visited { font-size: 13px; font-weight: bold; line-height: 1; text-shadow: 0 -1px 1px rgba(0,0,0,0.25); }
|
96
|
+
.large.awesome, .large.awesome:visited { font-size: 14px; padding: 8px 14px 9px; }
|
97
|
+
|
98
|
+
.green.awesome, .green.awesome:visited { background-color: #91bd09; }
|
99
|
+
.green.awesome:hover { background-color: #749a02; }
|
100
|
+
.blue.awesome, .blue.awesome:visited { background-color: #2daebf; }
|
101
|
+
.blue.awesome:hover { background-color: #007d9a; }
|
102
|
+
.red.awesome, .red.awesome:visited { background-color: #e33100; }
|
103
|
+
.red.awesome:hover { background-color: #872300; }
|
104
|
+
.magenta.awesome, .magenta.awesome:visited { background-color: #a9014b; }
|
105
|
+
.magenta.awesome:hover { background-color: #630030; }
|
106
|
+
.orange.awesome, .orange.awesome:visited { background-color: #ff5c00; }
|
107
|
+
.orange.awesome:hover { background-color: #d45500; }
|
108
|
+
.yellow.awesome, .yellow.awesome:visited { background-color: #ffb515; }
|
109
|
+
.yellow.awesome:hover { background-color: #fc9200; }
|
110
|
+
|
111
|
+
a.awesome:hover {
|
112
|
+
text-decoration: none;
|
113
|
+
}
|
114
|
+
|
115
|
+
/* ***************** HEADER ***************** */
|
116
|
+
|
117
|
+
div#header {
|
118
|
+
background-color: <%= dark_colour %>;
|
119
|
+
height: 92px;
|
120
|
+
padding: 2px 2px 0px 2px;
|
121
|
+
position: relative;
|
122
|
+
text-align: left;
|
123
|
+
}
|
124
|
+
|
125
|
+
div#header div#logged_in_summary {
|
126
|
+
position: absolute;
|
127
|
+
right: 20px;
|
128
|
+
top: 10px;
|
129
|
+
color: white;
|
130
|
+
font-size: 80%;
|
131
|
+
}
|
132
|
+
|
133
|
+
div#header div#logged_in_summary strong {
|
134
|
+
font-weight: bold;
|
135
|
+
font-size: 100%;
|
136
|
+
}
|
137
|
+
|
138
|
+
div#header h1 {
|
139
|
+
font-size: 18pt;
|
140
|
+
color: white;
|
141
|
+
font-weight: bold;
|
142
|
+
padding-top: 18px;
|
143
|
+
margin-left: 20px;
|
144
|
+
}
|
145
|
+
|
146
|
+
div#header h1 span {
|
147
|
+
color: <%= highlight_colour %>;
|
148
|
+
font-size: 80%;
|
149
|
+
}
|
150
|
+
|
151
|
+
/* ***************** MAIN NAVIGATION ***************** */
|
152
|
+
|
153
|
+
div#header ul#navigation {
|
154
|
+
margin: 0px;
|
155
|
+
padding: 0px;
|
156
|
+
position: absolute;
|
157
|
+
bottom: 0px;
|
158
|
+
left: 20px;
|
159
|
+
}
|
160
|
+
|
161
|
+
div#header ul#navigation li {
|
162
|
+
display: inline-block;
|
163
|
+
background-color: <%= light_colour %>;
|
164
|
+
}
|
165
|
+
|
166
|
+
div#header ul#navigation li a {
|
167
|
+
text-decoration: none;
|
168
|
+
display: inline-block;
|
169
|
+
padding: 4px;
|
170
|
+
color: <%= highlight_colour %>;
|
171
|
+
font-weight: bold;
|
172
|
+
}
|
173
|
+
|
174
|
+
div#header ul#navigation li.active a, div#header ul#navigation li a:hover {
|
175
|
+
background: #e5e5e5;
|
176
|
+
background: -webkit-gradient(linear, top left, bottom right, from(#fdfdfd), to(#e5e5e5));
|
177
|
+
background: -moz-linear-gradient(top left, #fdfdfd, #e5e5e5);
|
178
|
+
color: black;
|
179
|
+
}
|
180
|
+
|
181
|
+
/* ***************** SUB NAVIGATION ***************** */
|
182
|
+
|
183
|
+
div#header ul#subnavigation {
|
184
|
+
margin: 0px;
|
185
|
+
padding: 0px;
|
186
|
+
position: absolute;
|
187
|
+
bottom: 0px;
|
188
|
+
right: 20px;
|
189
|
+
}
|
190
|
+
|
191
|
+
div#header ul#subnavigation li {
|
192
|
+
display: inline-block;
|
193
|
+
background-color: <%= light_colour %>;
|
194
|
+
}
|
195
|
+
|
196
|
+
div#header ul#subnavigation li a {
|
197
|
+
text-decoration: none;
|
198
|
+
display: inline-block;
|
199
|
+
padding: 3px;
|
200
|
+
color: <%= highlight_colour %>;
|
201
|
+
font-weight: bold;
|
202
|
+
font-size: 90%;
|
203
|
+
}
|
204
|
+
|
205
|
+
div#header ul#subnavigation li.active a, div#header ul#subnavigation li a:hover {
|
206
|
+
background: #e5e5e5;
|
207
|
+
background: -webkit-gradient(linear, top left, bottom right, from(#fdfdfd), to(#e5e5e5));
|
208
|
+
background: -moz-linear-gradient(top left, #fdfdfd, #e5e5e5);
|
209
|
+
color: black;
|
210
|
+
}
|
211
|
+
|
212
|
+
/* ***************** SIDEBAR ***************** */
|
213
|
+
|
214
|
+
div#sidebar {
|
215
|
+
float: right;
|
216
|
+
width: 360px;
|
217
|
+
margin: 0px 20px 20px 20px;
|
218
|
+
}
|
219
|
+
|
220
|
+
div#sidebar div.card {
|
221
|
+
background: white;
|
222
|
+
box-shadow: 2px 2px 2px #888;
|
223
|
+
-moz-box-shadow:2px 2px 2px #888;
|
224
|
+
-webkit-box-shadow: 2px 2px 2px #888;
|
225
|
+
margin-top: 20px;
|
226
|
+
padding-bottom: 8px;
|
227
|
+
}
|
228
|
+
|
229
|
+
div#sidebar h2 {
|
230
|
+
background-color: <%= highlight_colour %>;
|
231
|
+
padding: 8px;
|
232
|
+
color: black;
|
233
|
+
font-weight: bold;
|
234
|
+
margin-top: 20px;
|
235
|
+
}
|
236
|
+
|
237
|
+
div#sidebar p {
|
238
|
+
padding: 8px 8px 0px 8px;
|
239
|
+
color: #333;
|
240
|
+
}
|
241
|
+
|
242
|
+
/* ***************** CONTENT ***************** */
|
243
|
+
|
244
|
+
div#content {
|
245
|
+
margin: 20px;
|
246
|
+
margin-right: 400px;
|
247
|
+
background: white;
|
248
|
+
padding: 20px;
|
249
|
+
box-shadow: 5px 5px 5px #888;
|
250
|
+
-moz-box-shadow:5px 5px 5px #888;
|
251
|
+
-webkit-box-shadow: 5px 5px 5px #888;
|
252
|
+
border-radius: 5px;
|
253
|
+
-moz-border-radius: 5px;
|
254
|
+
-webkit-border-radius: 5px;
|
255
|
+
}
|
256
|
+
|
257
|
+
div#content h1 {
|
258
|
+
margin: -20px -20px 20px -20px;
|
259
|
+
background: <%= highlight_colour %>;
|
260
|
+
padding: 10px 20px;
|
261
|
+
font-size: 15pt;
|
262
|
+
font-weight: bold;
|
263
|
+
color: black;
|
264
|
+
position: relative;
|
265
|
+
border-radius-topleft: 5px;
|
266
|
+
border-radius-topright: 5px;
|
267
|
+
-moz-border-radius-topleft: 5px;
|
268
|
+
-moz-border-radius-topright: 5px;
|
269
|
+
-webkit-border-top-left-radius: 5px;
|
270
|
+
-webkit-border-top-right-radius: 5px;
|
271
|
+
}
|
272
|
+
|
273
|
+
div#content h1 span {
|
274
|
+
position: absolute;
|
275
|
+
right: 20px;
|
276
|
+
top: 13px;
|
277
|
+
font-size: 80%;
|
278
|
+
font-weight: normal;
|
279
|
+
color: #d0d8eb;
|
280
|
+
}
|
281
|
+
|
282
|
+
div#content h2 {
|
283
|
+
font-weight: bold;
|
284
|
+
font-size: 120%;
|
285
|
+
color: black;
|
286
|
+
display: inline;
|
287
|
+
}
|
288
|
+
|
289
|
+
div#content p {
|
290
|
+
margin-bottom: 8px;
|
291
|
+
}
|
292
|
+
|
293
|
+
div.date_breakout {
|
294
|
+
margin-left: -20px;
|
295
|
+
padding-left: 20px;
|
296
|
+
color: #666666;
|
297
|
+
border-bottom: 1px solid #cccccc;
|
298
|
+
width: 150px;
|
299
|
+
text-transform: uppercase;
|
300
|
+
font-size: 8px;
|
301
|
+
font-weight: bold;
|
302
|
+
margin-bottom: 4px;
|
303
|
+
margin-top: 20px;
|
304
|
+
}
|
305
|
+
|
306
|
+
div.item {
|
307
|
+
border-bottom: 1px solid #efefef;
|
308
|
+
padding: 6px 0px;
|
309
|
+
}
|
310
|
+
|
311
|
+
div.summary {
|
312
|
+
float: right;
|
313
|
+
color: #999;
|
314
|
+
font-size: 80%;
|
315
|
+
}
|
316
|
+
|
317
|
+
div.summary strong {
|
318
|
+
color: #000;
|
319
|
+
font-size: 100%;
|
320
|
+
}
|
321
|
+
|
322
|
+
|
323
|
+
/* ***************** FORM ELEMENTS ***************** */
|
324
|
+
|
325
|
+
a.link_to_site {
|
326
|
+
border: 1px solid #ccc;
|
327
|
+
background-color: #f0f0f0;
|
328
|
+
color: #555;
|
329
|
+
padding: 5px;
|
330
|
+
color: #555;
|
331
|
+
display: block;
|
332
|
+
margin-bottom: 20px;
|
333
|
+
font-weight: bold;
|
334
|
+
}
|
335
|
+
|
336
|
+
a.link_to_site:hover {
|
337
|
+
background-color: #ccc;
|
338
|
+
color: white;
|
339
|
+
text-decoration: none;
|
340
|
+
}
|
341
|
+
|
342
|
+
form span.error {
|
343
|
+
color: #b72c23;
|
344
|
+
}
|
345
|
+
|
346
|
+
form div.formError {
|
347
|
+
color: #b72c23;
|
348
|
+
display: inline;
|
349
|
+
margin-left: 0.5em;
|
350
|
+
font-size: 110%;
|
351
|
+
}
|
352
|
+
|
353
|
+
form div.description {
|
354
|
+
color: #666666;
|
355
|
+
}
|
356
|
+
|
357
|
+
form div.input {
|
358
|
+
background-color: #f0f0f0;
|
359
|
+
padding: 6px;
|
360
|
+
margin-bottom: 20px;
|
361
|
+
}
|
362
|
+
|
363
|
+
form div.fieldWithErrors {
|
364
|
+
background-color: #b72c23;
|
365
|
+
margin: -6px;
|
366
|
+
padding: 6px;
|
367
|
+
}
|
368
|
+
|
369
|
+
form textarea {
|
370
|
+
width: 100%;
|
371
|
+
}
|
372
|
+
|
373
|
+
form input[type='text'] {
|
374
|
+
width: 99%;
|
375
|
+
}
|
376
|
+
|
377
|
+
/* ***************** FOOTER ***************** */
|
378
|
+
|
379
|
+
div#footer {
|
380
|
+
margin: 20px;
|
381
|
+
color: #aaa;
|
382
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title><%%= @page_title || "Untitled" %> : <%= name %></title>
|
6
|
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
|
7
|
+
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css">
|
8
|
+
<%%= javascript_include_tag 'admin' %>
|
9
|
+
<%%= stylesheet_link_tag 'admin' %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<div id="header">
|
13
|
+
<%% if @current_user_name %>
|
14
|
+
<div id='logged_in_summary'>
|
15
|
+
Logged in as <strong><%%= @current_user_name %></strong>
|
16
|
+
<%% if @last_login_time %>
|
17
|
+
<br />Last login at <strong><%%= @last_login_time %></strong>
|
18
|
+
<%% end %>
|
19
|
+
</div>
|
20
|
+
<%% end %>
|
21
|
+
<h1><%= name %> <span><%%= @page_title %></h1>
|
22
|
+
<ul id='navigation'>
|
23
|
+
<%% ANDY_ADMIN_MENU.main_items_each(@current_section_id) do |name, link, section_id, css_class| %>
|
24
|
+
<li class='<%%= css_class %>'><a href='<%%= link %>' id='<%%= section_id %>'><%%= name %></a></li>
|
25
|
+
<%% end %>
|
26
|
+
</ul>
|
27
|
+
<ul id='subnavigation'>
|
28
|
+
<%% ANDY_ADMIN_MENU.sub_items_each(@current_section_id) do |name, link, section_id, css_class| %>
|
29
|
+
<li class='<%%= css_class %>'><a href='<%%= link %>' id='<%%= section_id %>'><%%= name %></a></li>
|
30
|
+
<%% end %>
|
31
|
+
</ul>
|
32
|
+
</div>
|
33
|
+
<%%= content_tag(:div, "<span>close</span>" + flash[:notice], :class => "flash_notice") if flash[:notice] %>
|
34
|
+
<%%= content_tag(:div, "<span>close</span>" + flash[:error], :class => "flash_error") if flash[:error] %>
|
35
|
+
<%%= content_tag(:div, "<span>close</span>" + flash[:warning], :class => "flash_warning") if flash[:warning] %>
|
36
|
+
<div id='sidebar'>
|
37
|
+
<%%= yield(:sidebar) %>
|
38
|
+
</div>
|
39
|
+
<div id='content'>
|
40
|
+
<%%= yield %>
|
41
|
+
</div>
|
42
|
+
<div id='footer'>
|
43
|
+
Designed and developed by Your Name. Copyright © <%%= Time.now.year %>, all rights reserved.
|
44
|
+
</div>
|
45
|
+
</body>
|
46
|
+
</html>
|
Binary file
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class AndyAdmin::FormBuilder < ActionView::Helpers::FormBuilder
|
2
|
+
helpers = field_helpers +
|
3
|
+
%w{date_select datetime_select time_select check_box} +
|
4
|
+
%w{collection_select select country_select time_zone_select} -
|
5
|
+
%w{hidden_field label fields_for} # Don't decorate these
|
6
|
+
|
7
|
+
helpers.each do |name|
|
8
|
+
define_method(name) do |field_name, *args|
|
9
|
+
options = args.extract_options!
|
10
|
+
options[:title] ||= field_name.to_s.humanize
|
11
|
+
heading = "<h2>" + options[:title] + "</h2>"
|
12
|
+
heading += error_message_on(field_name, args)
|
13
|
+
description = if options[:description]
|
14
|
+
@template.content_tag(:div, options[:description], :class => "description")
|
15
|
+
else
|
16
|
+
""
|
17
|
+
end
|
18
|
+
options.merge!({:class => name})
|
19
|
+
if name == "check_box"
|
20
|
+
label = label(field_name, options[:label])
|
21
|
+
input = @template.content_tag(:div, super(field_name, options) + " " + label, :class => 'input')
|
22
|
+
elsif name == "select"
|
23
|
+
input = @template.content_tag(:div, super(field_name, args[0], options), :class => 'input')
|
24
|
+
else
|
25
|
+
input = @template.content_tag(:div, super(field_name, options), :class => 'input')
|
26
|
+
end
|
27
|
+
@template.content_tag(:div, heading + description + input)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def actions
|
32
|
+
@template.concat @template.content_tag(:div, yield, :class => "actions")
|
33
|
+
end
|
34
|
+
|
35
|
+
def submit(label, *args)
|
36
|
+
options = args.extract_options!
|
37
|
+
options[:colour] ||= "green"
|
38
|
+
@template.content_tag(:button, label, :class => "awesome #{options[:colour]}", :type => "submit")
|
39
|
+
end
|
40
|
+
|
41
|
+
def cancel(label, link)
|
42
|
+
@template.content_tag(:a, label, :href => link)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
/* ***************** GENERAL DEFINITIONS ***************** */
|
2
|
+
|
3
|
+
html, body {
|
4
|
+
background-color: #e5e5e5;
|
5
|
+
}
|
6
|
+
|
7
|
+
* {
|
8
|
+
font-size: 10pt;
|
9
|
+
text-align: left;
|
10
|
+
line-height: 1.2em;
|
11
|
+
}
|
12
|
+
|
13
|
+
a {
|
14
|
+
color: <%= light_colour %>;
|
15
|
+
text-decoration: none;
|
16
|
+
}
|
17
|
+
|
18
|
+
a:hover {
|
19
|
+
text-decoration: underline;
|
20
|
+
}
|
21
|
+
|
22
|
+
/* ***************** FLASH DEFINITIONS ***************** */
|
23
|
+
|
24
|
+
div.flash_error, div.flash_notice, div.flash_warning {
|
25
|
+
margin: -20px -20px 20px -20px;
|
26
|
+
padding: 10px;
|
27
|
+
color: white;
|
28
|
+
font-weight: bold;
|
29
|
+
}
|
30
|
+
|
31
|
+
div.flash_error {
|
32
|
+
background: #b72c23;
|
33
|
+
}
|
34
|
+
|
35
|
+
div.flash_notice {
|
36
|
+
background: #2bb723;
|
37
|
+
}
|
38
|
+
|
39
|
+
div.flash_warning {
|
40
|
+
color: black;
|
41
|
+
background: #e8ed2d;
|
42
|
+
}
|
43
|
+
|
44
|
+
/* ***************** AWESOME BUTTONS ***************** */
|
45
|
+
|
46
|
+
/* From: http://www.zurb.com/ */
|
47
|
+
.awesome, .awesome:visited {
|
48
|
+
background: #222 url(/images/admin-alert-overlay.png) repeat-x;
|
49
|
+
display: inline-block;
|
50
|
+
padding: 5px 10px 6px;
|
51
|
+
color: #fff;
|
52
|
+
text-decoration: none;
|
53
|
+
-moz-border-radius: 18px;
|
54
|
+
-webkit-border-radius: 18px;
|
55
|
+
-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
|
56
|
+
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
|
57
|
+
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
|
58
|
+
border: 0px;
|
59
|
+
border-bottom: 1px solid rgba(0,0,0,0.25);
|
60
|
+
position: relative;
|
61
|
+
cursor: pointer;
|
62
|
+
}
|
63
|
+
|
64
|
+
.awesome:hover { background-color: #111; color: #fff; }
|
65
|
+
.awesome:active { top: 1px; }
|
66
|
+
.small.awesome, .small.awesome:visited { font-size: 11px; padding: ; }
|
67
|
+
.awesome, .awesome:visited,
|
68
|
+
.medium.awesome, .medium.awesome:visited { font-size: 13px; font-weight: bold; line-height: 1; text-shadow: 0 -1px 1px rgba(0,0,0,0.25); }
|
69
|
+
.large.awesome, .large.awesome:visited { font-size: 14px; padding: 8px 14px 9px; }
|
70
|
+
|
71
|
+
.green.awesome, .green.awesome:visited { background-color: #91bd09; }
|
72
|
+
.green.awesome:hover { background-color: #749a02; }
|
73
|
+
.blue.awesome, .blue.awesome:visited { background-color: #2daebf; }
|
74
|
+
.blue.awesome:hover { background-color: #007d9a; }
|
75
|
+
.red.awesome, .red.awesome:visited { background-color: #e33100; }
|
76
|
+
.red.awesome:hover { background-color: #872300; }
|
77
|
+
.magenta.awesome, .magenta.awesome:visited { background-color: #a9014b; }
|
78
|
+
.magenta.awesome:hover { background-color: #630030; }
|
79
|
+
.orange.awesome, .orange.awesome:visited { background-color: #ff5c00; }
|
80
|
+
.orange.awesome:hover { background-color: #d45500; }
|
81
|
+
.yellow.awesome, .yellow.awesome:visited { background-color: #ffb515; }
|
82
|
+
.yellow.awesome:hover { background-color: #fc9200; }
|
83
|
+
|
84
|
+
a.awesome:hover {
|
85
|
+
text-decoration: none;
|
86
|
+
}
|
87
|
+
|
88
|
+
/* ***************** LOGIN FORM ***************** */
|
89
|
+
|
90
|
+
div#login {
|
91
|
+
width: 250px;
|
92
|
+
margin: 100px auto 50px auto;
|
93
|
+
background: white;
|
94
|
+
padding: 20px;
|
95
|
+
box-shadow: 5px 5px 5px #888;
|
96
|
+
-moz-box-shadow:5px 5px 5px #888;
|
97
|
+
-webkit-box-shadow: 5px 5px 5px #888;
|
98
|
+
border-radius: 5px;
|
99
|
+
-moz-border-radius: 5px;
|
100
|
+
-webkit-border-radius: 5px;
|
101
|
+
}
|
102
|
+
|
103
|
+
div#login h1 {
|
104
|
+
margin: -20px -20px 20px -20px;
|
105
|
+
background: <%= highlight_colour %>;
|
106
|
+
padding: 10px 20px;
|
107
|
+
font-size: 15pt;
|
108
|
+
font-weight: bold;
|
109
|
+
color: black;
|
110
|
+
position: relative;
|
111
|
+
border-radius-topleft: 5px;
|
112
|
+
border-radius-topright: 5px;
|
113
|
+
-moz-border-radius-topleft: 5px;
|
114
|
+
-moz-border-radius-topright: 5px;
|
115
|
+
-webkit-border-top-left-radius: 5px;
|
116
|
+
-webkit-border-top-right-radius: 5px;
|
117
|
+
}
|
118
|
+
|
119
|
+
/* ***************** FORM ELEMENTS ***************** */
|
120
|
+
|
121
|
+
form h2 {
|
122
|
+
font-weight: bold;
|
123
|
+
font-size: 120%;
|
124
|
+
color: black;
|
125
|
+
display: inline;
|
126
|
+
}
|
127
|
+
|
128
|
+
form span.error {
|
129
|
+
color: red;
|
130
|
+
}
|
131
|
+
|
132
|
+
form div.description {
|
133
|
+
color: #666666;
|
134
|
+
}
|
135
|
+
|
136
|
+
form div.input {
|
137
|
+
margin-bottom: 10px;
|
138
|
+
}
|
139
|
+
|
140
|
+
form textarea {
|
141
|
+
width: 100%;
|
142
|
+
}
|
143
|
+
|
144
|
+
form input[type='text'] {
|
145
|
+
width: 99%;
|
146
|
+
}
|
147
|
+
|
148
|
+
form div.actions {
|
149
|
+
margin-top: 20px;
|
150
|
+
}
|
151
|
+
|
152
|
+
/* ***************** FOOTER ***************** */
|
153
|
+
|
154
|
+
div#footer {
|
155
|
+
margin: 20px;
|
156
|
+
color: #aaa;
|
157
|
+
text-align: center;
|
158
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Login : <%= name %></title>
|
6
|
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
|
7
|
+
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css">
|
8
|
+
<%%= javascript_include_tag 'login' %>
|
9
|
+
<%%= stylesheet_link_tag 'login' %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<div id="login">
|
13
|
+
<h1><%= name %></h1>
|
14
|
+
<%%= content_tag(:div, flash[:notice], :class => "flash_notice") if flash[:notice] %>
|
15
|
+
<%%= content_tag(:div, flash[:error], :class => "flash_error") if flash[:error] %>
|
16
|
+
<%%= content_tag(:div, flash[:warning], :class => "flash_warning") if flash[:warning] %>
|
17
|
+
<div id='content'>
|
18
|
+
<!-- Extract from here to the yield to a view -->
|
19
|
+
<form action='/login' method='post'>
|
20
|
+
<input type='hidden' name='authenticity_token' value='<%%= form_authenticity_token %>' />
|
21
|
+
<h2>User name</h2>
|
22
|
+
<div class='input'>
|
23
|
+
<input type='text' name='user_name' />
|
24
|
+
</div>
|
25
|
+
<h2>Password</h2>
|
26
|
+
<div class='input'>
|
27
|
+
<input type='password' name='password' />
|
28
|
+
</div>
|
29
|
+
<div class='input'>
|
30
|
+
<input type='checkbox' name='remember_me' id='remember_me' /> <label for="remember_me">Remember me on this computer</label>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class='actions'>
|
34
|
+
<button class='awesome green' type='login'>Login</button>
|
35
|
+
</div>
|
36
|
+
</form>
|
37
|
+
<%%#= yield %>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
<div id='footer'>
|
41
|
+
Designed and developed by Your Name. Copyright © <%%= Time.now.year %>, all rights reserved.
|
42
|
+
</div>
|
43
|
+
</body>
|
44
|
+
</html>
|
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module AndyAdmin
|
2
|
+
class Menu
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
def self.build(&block)
|
6
|
+
instance.instance_eval(&block)
|
7
|
+
instance
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@main_items = []
|
12
|
+
@sub_items = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def main(id, name, link=nil)
|
16
|
+
@main_items << {:name => name, :link => link, :id => id}
|
17
|
+
end
|
18
|
+
|
19
|
+
def sub(id, name, link=nil)
|
20
|
+
@sub_items << {:name => name, :link => link, :id => id}
|
21
|
+
end
|
22
|
+
|
23
|
+
def main_items_each(current)
|
24
|
+
@main_items.each do |item|
|
25
|
+
css_class = (item[:id] == current ? "active" : "")
|
26
|
+
yield(item[:name], item[:link], item[:id], css_class)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def sub_items_each(current)
|
31
|
+
@sub_items.each do |item|
|
32
|
+
css_class = (item[:id] == current ? "active" : "")
|
33
|
+
yield(item[:name], item[:link], item[:id], css_class)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: andy_admin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Andy Jeffries
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-11 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rails
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 0
|
31
|
+
- rc
|
32
|
+
version: 3.0.rc
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: A generator for a nice admin style, like many other popular Rails-based sites
|
36
|
+
email: andy@andyjeffries.co.uk
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- lib/generators/andy_admin/andy_admin_generator.rb
|
45
|
+
- lib/generators/andy_admin/templates/admin.css
|
46
|
+
- lib/generators/andy_admin/templates/admin.html.erb
|
47
|
+
- lib/generators/andy_admin/templates/admin.js
|
48
|
+
- lib/generators/andy_admin/templates/alert-overlay.png
|
49
|
+
- lib/generators/andy_admin/templates/andy_admin_helper.rb
|
50
|
+
- lib/generators/andy_admin/templates/andy_admin_menu.rb
|
51
|
+
- lib/generators/andy_admin/templates/form_builder.rb
|
52
|
+
- lib/generators/andy_admin/templates/login.css
|
53
|
+
- lib/generators/andy_admin/templates/login.html.erb
|
54
|
+
- lib/generators/andy_admin/templates/login.js
|
55
|
+
- lib/generators/andy_admin/templates/menu.rb
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://andyjeffries.co.uk
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.3.7
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: A generator for a nice admin style
|
88
|
+
test_files: []
|
89
|
+
|