kitsune 0.0.2

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 (40) hide show
  1. data/README.textile +5 -0
  2. data/Rakefile +21 -0
  3. data/app/controllers/admin/kitsune/models_controller.rb +13 -0
  4. data/app/controllers/admin/kitsune/pages_controller.rb +27 -0
  5. data/app/controllers/admin/kitsune/records_controller.rb +55 -0
  6. data/app/controllers/kitsune_controller.rb +5 -0
  7. data/app/helpers/admin/kitsune/records_helper.rb +19 -0
  8. data/app/views/admin/kitsune/models/_form.html.erb +16 -0
  9. data/app/views/admin/kitsune/models/index.html.erb +3 -0
  10. data/app/views/admin/kitsune/pages/_form.html.erb +13 -0
  11. data/app/views/admin/kitsune/pages/edit.html.erb +7 -0
  12. data/app/views/admin/kitsune/pages/index.html.erb +5 -0
  13. data/app/views/admin/kitsune/pages/new.html.erb +7 -0
  14. data/app/views/admin/kitsune/records/_form.html.erb +14 -0
  15. data/app/views/admin/kitsune/records/edit.html.erb +7 -0
  16. data/app/views/admin/kitsune/records/index.html.erb +36 -0
  17. data/app/views/admin/kitsune/records/new.html.erb +7 -0
  18. data/app/views/kitsune/show.html.erb +1 -0
  19. data/app/views/layouts/admin/kitsune.html.erb +15 -0
  20. data/config/kitsune_routes.rb +11 -0
  21. data/generators/kitsune/kitsune_generator.rb +26 -0
  22. data/generators/kitsune/lib/insert_commands.rb +31 -0
  23. data/generators/kitsune/templates/images/bg.jpg +0 -0
  24. data/generators/kitsune/templates/images/form-bg.gif +0 -0
  25. data/generators/kitsune/templates/images/grey-btn.png +0 -0
  26. data/generators/kitsune/templates/images/nicEditorIcons.gif +0 -0
  27. data/generators/kitsune/templates/javascripts/nicEdit.js +102 -0
  28. data/generators/kitsune/templates/migrations/create_pages.rb +14 -0
  29. data/generators/kitsune/templates/page.rb +3 -0
  30. data/generators/kitsune/templates/stylesheets/global.css +381 -0
  31. data/lib/kitsune.rb +37 -0
  32. data/lib/kitsune/active_record.rb +29 -0
  33. data/lib/kitsune/builder.rb +92 -0
  34. data/lib/kitsune/extensions/routes.rb +14 -0
  35. data/lib/kitsune/faux_column.rb +11 -0
  36. data/lib/kitsune/form_helper_ext.rb +12 -0
  37. data/lib/kitsune/inspector.rb +137 -0
  38. data/lib/kitsune/page.rb +18 -0
  39. data/rails/init.rb +3 -0
  40. metadata +102 -0
@@ -0,0 +1,14 @@
1
+ class KitsuneCreatePages < ActiveRecord::Migration
2
+ def self.up
3
+ create_table(:pages) do |t|
4
+ t.string :title
5
+ t.string :url
6
+ t.text :body
7
+ t.integer :parent_id
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :pages
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ class Page < ActiveRecord::Base
2
+ include Kitsune::Page
3
+ end
@@ -0,0 +1,381 @@
1
+ /* ----- RESET ----- */
2
+ html, body, div, span, applet, object, iframe,
3
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
4
+ a, abbr, acronym, address, big, cite, code,
5
+ del, dfn, em, font, img, ins, kbd, q, s, samp,
6
+ small, strike, strong, sub, sup, tt, var,
7
+ b, u, i, center,
8
+ dl, dt, dd, ol, ul, li,
9
+ fieldset, form, label, legend,
10
+ table, caption, tbody, tfoot, thead, tr, th, td {
11
+ margin: 0;
12
+ padding: 0;
13
+ border: 0;
14
+ outline: 0;
15
+ font-size: 100.01%;
16
+ vertical-align: baseline;
17
+ background: transparent;
18
+ }
19
+ body {
20
+ line-height: 1;
21
+ }
22
+ ol, ul {
23
+ list-style: none;
24
+ }
25
+ blockquote, q {
26
+ quotes: none;
27
+ }
28
+
29
+ /* remember to define focus styles! */
30
+ :focus {
31
+ outline: 0;
32
+ }
33
+
34
+ /* remember to highlight inserts somehow! */
35
+ ins {
36
+ text-decoration: none;
37
+ }
38
+ del {
39
+ text-decoration: line-through;
40
+ }
41
+
42
+ /* tables still need 'cellspacing="0"' in the markup */
43
+ table {
44
+ border-collapse: collapse;
45
+ border-spacing: 0;
46
+ }
47
+
48
+ blockquote, q
49
+ {
50
+ quotes: none;
51
+ }
52
+
53
+ /*
54
+ Safari doesn't support the quotes attribute, so we do this instead.
55
+ */
56
+ blockquote:before, blockquote:after, q:before, q:after
57
+ {
58
+ /*
59
+ CSS 2; used to remove quotes in case "none" fails below.
60
+ */
61
+ content: "";
62
+ /*
63
+ CSS 2.1; will remove quotes if supported, and override the above.
64
+ User-agents that don't understand "none" should ignore it, and
65
+ keep the above value. This is here for future compatibility,
66
+ though I'm not 100% convinced that it's a good idea...
67
+ */
68
+ content: none;
69
+ }
70
+
71
+ textarea { overflow: auto; }
72
+ input { border: 0px solid white; margin: 0; padding: 0; }
73
+
74
+
75
+
76
+ body {
77
+ padding: 0 0;
78
+ width: 100%;
79
+ margin: 0 auto;
80
+ background: #B0DDE2 url(/images/kitsune/bg.jpg) 0 0 repeat-x;
81
+ color: #000;
82
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
83
+ font-size: 14px;
84
+ line-height: 1.3em;
85
+ }
86
+
87
+ /* -------HEADER------- */
88
+
89
+ #header {
90
+ width: 100%;
91
+ height: 25px;
92
+ padding: 8px 0 6px 0;
93
+
94
+ }
95
+
96
+ h1 a {
97
+ text-decoration: none;
98
+ color: #fff;
99
+ margin-left: 10px;
100
+ }
101
+
102
+
103
+
104
+ /* ------BODY---------- */
105
+
106
+ #body {
107
+ width: 84%;
108
+ padding: 30px 3% 50px 3%;
109
+ margin: 40px 5% 10px 5%;
110
+ background-color: #fff;
111
+
112
+ }
113
+
114
+
115
+ /* ----- HEADINGS ----- */
116
+ h1, h2, h3, h4, h5 {
117
+
118
+ }
119
+
120
+ h1 {
121
+ font-size: 1.4em;
122
+ }
123
+ h2 {
124
+ font-size: 2em;
125
+ }
126
+ h3 {
127
+ font-size: 1.5em;
128
+ }
129
+ h4 {
130
+ font-size: 1.25em;
131
+ }
132
+ h5 {
133
+ font-size: 1em;
134
+ }
135
+
136
+ /* ----- PARAGRAPHS ----- */
137
+ p {
138
+ font-size: 1em;
139
+ }
140
+
141
+ /* ----- LISTS ----- */
142
+
143
+ li {
144
+ }
145
+ li p {
146
+ }
147
+ ol {
148
+ }
149
+ ul {
150
+ }
151
+ ol li {
152
+ }
153
+ ul li {
154
+ }
155
+
156
+ /* ----- IMAGES ----- */
157
+
158
+ img {
159
+ }
160
+ img a {
161
+ }
162
+ img a:hover {
163
+ }
164
+
165
+ /* ----- LINKS ----- */
166
+
167
+ a {
168
+ }
169
+ a:hover {
170
+ }
171
+ a:visited, a:active, a:focus {
172
+ }
173
+ a:visited {
174
+ }
175
+ a:active {
176
+ }
177
+ a:focus {
178
+ }
179
+
180
+ /* ----- FORMS ----- */
181
+
182
+ form {
183
+ }
184
+ fieldset {
185
+ background: #F6F6F6 url(/images/kitsune/form-bg.gif) bottom left repeat-x;;
186
+ border: 1px solid #eee;
187
+ padding: 30px 40px 15px 20px;
188
+ }
189
+
190
+ h2.legend {
191
+ width: 100%;
192
+ border-bottom: 1px solid #eee;
193
+ font-size: 1.3em;
194
+ padding: 5px 0;
195
+ margin-bottom: 10px;
196
+ color: #555;
197
+ }
198
+
199
+ label {
200
+ font-weight: bold;
201
+ font-size: 1em;
202
+ margin: 0 0 3px 0;
203
+ text-transform: ;
204
+ color: #aaa;
205
+ }
206
+ input {
207
+
208
+ }
209
+ textarea {
210
+ }
211
+ input, textarea {
212
+ font-family: "Lucida Grande", "Lucida Sans", Arial, sans-serif;
213
+ font-size: .9em;
214
+ border: 1px solid #ccc;
215
+ padding: 5px;
216
+ }
217
+
218
+ input:focus, textarea:focus {
219
+ border: 1px solid #e1cd30;
220
+ background-color: #fbffeb;
221
+ }
222
+
223
+
224
+
225
+ select {
226
+ font-family: "Lucida Grande", "Lucida Sans", Arial, sans-serif;
227
+ font-size: .9em;
228
+
229
+ }
230
+ optgroup {
231
+ }
232
+ option {
233
+ }
234
+
235
+ fieldset {clear: both;}
236
+
237
+ fieldset fieldset legend {padding: 0 0 1.5em; font-size: 1em;}
238
+ * html legend {margin-left: -7px;} /* ie6 */
239
+ *+html legend {margin-left: -7px;} /* ie7 */
240
+
241
+ form .field, form .buttons {clear: both; margin: 0 0 1.5em;}
242
+ form .field label {display: block;}
243
+ form ul.fields {margin: 0 0 1.5em; padding: 0;}
244
+ form ul.fields li {list-style-type: none; margin: 0;}
245
+ form ul.inline li, form ul.inline label {display: inline;}
246
+ form ul.inline li {padding: 0 .75em 0 0;}
247
+
248
+ input.radio, input.checkbox {vertical-align: top;}
249
+ label, button, input.submit, input.image {cursor: pointer;}
250
+ input.submit {
251
+ font-family: "Helvetica Neue", Arial, sans-serif;
252
+ font-weight: bold;
253
+ font-size: 1.3em;
254
+ background-color: #333;
255
+ color: #fff;
256
+ border: none;
257
+ padding: 4px 20px;
258
+ }
259
+ * html input.radio, * html input.checkbox {vertical-align: middle;} /* ie6 */
260
+ *+html input.radio, *+html input.checkbox {vertical-align: middle;} /* ie7 */
261
+
262
+ textarea {overflow: auto;}
263
+ input.text, input.password, textarea, select {margin: 0; vertical-align: baseline;}
264
+ input.text, input.password, textarea {border: 1px solid #444; padding: 2px;}
265
+
266
+ /* horizontal layout */
267
+ form.horizontal .field {padding-left: 150px;}
268
+ form.horizontal .field label {display: inline; float: left; width: 140px; margin-left: -150px;}
269
+
270
+
271
+ /* ----- TABLES ----- */
272
+
273
+ table {
274
+ width: 100%;
275
+ padding: 0;
276
+ background: #fff;
277
+
278
+
279
+ }
280
+
281
+ caption {
282
+ padding: 0 0 5px 0;
283
+ width: 700px;
284
+ text-align: right;
285
+ }
286
+
287
+ th {
288
+ color: #4f6b72;
289
+ border-bottom: 1px solid #ddd;
290
+
291
+ text-align: left;
292
+ padding: 6px 6px 6px 12px;
293
+ background: #fff; /*url(/images/kitsune/bg_header.jpg) no-repeat;*/
294
+ color: #555;
295
+ }
296
+
297
+ th.nobg {
298
+ border-top: 0;
299
+ border-left: 0;
300
+ border-right: 1px solid #ddd;
301
+ background: none;
302
+ }
303
+
304
+ td {
305
+ border-bottom: 1px solid #eee;
306
+ background: #f6f6f6;
307
+ padding: 8px 6px 8px 12px;
308
+ color: #333;
309
+ font-size: .9em;
310
+ }
311
+
312
+
313
+ tr.alt, td.alt {
314
+ background: #F5FAFA;
315
+ color: #797268;
316
+ }
317
+
318
+
319
+
320
+
321
+
322
+ /* BUTTON STYLES */
323
+ button {
324
+ position: relative;
325
+ border: 0;
326
+ padding: 0;
327
+ cursor: pointer;
328
+ overflow: visible; /* removes extra side padding in IE */
329
+ margin: 0 0;
330
+
331
+
332
+ }
333
+
334
+ button::-moz-focus-inner {
335
+ border: none; /* overrides extra padding in Firefox */
336
+ }
337
+
338
+ button span {
339
+ position: relative;
340
+ display: block;
341
+ white-space: nowrap;
342
+ }
343
+
344
+ @media screen and (-webkit-min-device-pixel-ratio:0) {
345
+ /* Safari and Google Chrome only - fix margins */
346
+ button span {
347
+ margin-top: -1px;
348
+ }
349
+ }
350
+
351
+
352
+ /* OPTIONAL BUTTON STYLES */
353
+ button.submitBtn {
354
+ padding: 0 25px 0 0;
355
+ margin-right:5px;
356
+ font-size:1.1em;
357
+ text-align: center;
358
+ background: transparent url(/images/kitsune/grey-btn.png) no-repeat right -108px;
359
+ font-family: "Helvetica Neue";
360
+ font-weight: bold;
361
+ text-shadow:0 1px 0 #FFFFFF;
362
+ color: #000 ;
363
+ font-size: 18px;
364
+ }
365
+
366
+ button.submitBtn span {
367
+ padding: 6px 0 0 25px;
368
+ height:28px;
369
+ background: transparent url(/images/kitsune/grey-btn.png) no-repeat left top;
370
+
371
+ }
372
+
373
+ button.submitBtn:active, button.submitBtnHover { /* the redundant class is used to apply the hover state with a script */
374
+ background-position: right -162px;
375
+ }
376
+
377
+ button.submitBtn:active span, button.submitBtnHover span {
378
+ background-position: 0 -54px;
379
+ }
380
+
381
+
@@ -0,0 +1,37 @@
1
+ require 'kitsune/active_record'
2
+ require 'kitsune/extensions/routes'
3
+ require 'kitsune/form_helper_ext'
4
+
5
+ module Kitsune
6
+ autoload :FauxColumn, 'kitsune/faux_column'
7
+ autoload :Inspector, 'kitsune/inspector'
8
+ autoload :Page, 'kitsune/page'
9
+ class << self
10
+ def version
11
+ '0.0.1'
12
+ end
13
+
14
+ def model_paths # abstract this to something else
15
+ ["#{RAILS_ROOT}/app/models"]
16
+ end
17
+
18
+ def models_with_admin
19
+ models.select{|m| m.respond_to?(:kitsune_admin)} # quacks like a duck
20
+ end
21
+
22
+ def models
23
+ models = []
24
+ model_paths.each do |path|
25
+ Dir.glob(path+'/*').each do |file|
26
+ begin
27
+ klass = File.basename(file).gsub(/^(.+).rb/, '\1').classify.constantize
28
+ models << klass if klass.ancestors.include?(::ActiveRecord::Base)
29
+ rescue Exception => e
30
+ # not valid
31
+ end
32
+ end
33
+ end
34
+ models
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+ require 'kitsune/builder'
2
+
3
+ module Kitsune
4
+ module ActiveRecord
5
+ def setup_admin
6
+ self.class_eval do
7
+ class_inheritable_hash :kitsune_admin
8
+ self.kitsune_admin = {
9
+ :no_admin => false,
10
+ :multipart => false,
11
+ :display => {},
12
+ :edit => {},
13
+ :fields => {},
14
+ :tabs => {}
15
+ }
16
+ end
17
+ end
18
+
19
+ def admin &block
20
+ setup_admin
21
+ Kitsune::Builder.generate(self, &block)
22
+ end
23
+
24
+ def no_admin
25
+ setup_admin
26
+ self.kitsune_admin[:no_admin] = true
27
+ end
28
+ end
29
+ end