aslakjo-comatose 2.0.5.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.
- data/CHANGELOG +195 -0
- data/INSTALL +20 -0
- data/LICENSE +20 -0
- data/MANIFEST +91 -0
- data/README.markdown +159 -0
- data/Rakefile +176 -0
- data/SPECS +61 -0
- data/about.yml +7 -0
- data/bin/comatose +112 -0
- data/comatose.gemspec +113 -0
- data/generators/comatose_migration/USAGE +15 -0
- data/generators/comatose_migration/comatose_migration_generator.rb +74 -0
- data/generators/comatose_migration/templates/migration.rb +35 -0
- data/generators/comatose_migration/templates/v4_upgrade.rb +15 -0
- data/generators/comatose_migration/templates/v6_upgrade.rb +23 -0
- data/generators/comatose_migration/templates/v7_upgrade.rb +22 -0
- data/init.rb +2 -0
- data/install.rb +18 -0
- data/lib/acts_as_versioned.rb +543 -0
- data/lib/comatose/comatose_drop.rb +79 -0
- data/lib/comatose/configuration.rb +69 -0
- data/lib/comatose/page_wrapper.rb +119 -0
- data/lib/comatose/processing_context.rb +69 -0
- data/lib/comatose/tasks/admin.rb +60 -0
- data/lib/comatose/tasks/data.rb +82 -0
- data/lib/comatose/tasks/setup.rb +52 -0
- data/lib/comatose/version.rb +4 -0
- data/lib/comatose.rb +33 -0
- data/lib/comatose_admin_controller.rb +395 -0
- data/lib/comatose_admin_helper.rb +37 -0
- data/lib/comatose_controller.rb +138 -0
- data/lib/comatose_helper.rb +3 -0
- data/lib/comatose_page.rb +141 -0
- data/lib/liquid/block.rb +96 -0
- data/lib/liquid/context.rb +190 -0
- data/lib/liquid/document.rb +17 -0
- data/lib/liquid/drop.rb +48 -0
- data/lib/liquid/errors.rb +7 -0
- data/lib/liquid/extensions.rb +53 -0
- data/lib/liquid/file_system.rb +62 -0
- data/lib/liquid/htmltags.rb +64 -0
- data/lib/liquid/standardfilters.rb +111 -0
- data/lib/liquid/standardtags.rb +399 -0
- data/lib/liquid/strainer.rb +42 -0
- data/lib/liquid/tag.rb +25 -0
- data/lib/liquid/template.rb +88 -0
- data/lib/liquid/variable.rb +39 -0
- data/lib/liquid.rb +52 -0
- data/lib/redcloth.rb +1129 -0
- data/lib/support/class_options.rb +36 -0
- data/lib/support/inline_rendering.rb +48 -0
- data/lib/support/route_mapper.rb +50 -0
- data/lib/text_filters/markdown.rb +14 -0
- data/lib/text_filters/markdown_smartypants.rb +15 -0
- data/lib/text_filters/none.rb +8 -0
- data/lib/text_filters/rdoc.rb +13 -0
- data/lib/text_filters/simple.rb +8 -0
- data/lib/text_filters/textile.rb +15 -0
- data/lib/text_filters.rb +140 -0
- data/rails/init.rb +3 -0
- data/resources/layouts/comatose_admin_template.html.erb +28 -0
- data/resources/public/images/collapsed.gif +0 -0
- data/resources/public/images/expanded.gif +0 -0
- data/resources/public/images/no-children.gif +0 -0
- data/resources/public/images/page.gif +0 -0
- data/resources/public/images/spinner.gif +0 -0
- data/resources/public/images/title-hover-bg.gif +0 -0
- data/resources/public/javascripts/comatose_admin.js +401 -0
- data/resources/public/stylesheets/comatose_admin.css +404 -0
- data/tasks/comatose.rake +9 -0
- data/test/behaviors.rb +106 -0
- data/test/fixtures/comatose_pages.yml +96 -0
- data/test/functional/comatose_admin_controller_test.rb +114 -0
- data/test/functional/comatose_controller_test.rb +44 -0
- data/test/javascripts/test.html +26 -0
- data/test/javascripts/test_runner.js +307 -0
- data/test/test_helper.rb +55 -0
- data/test/unit/class_options_test.rb +52 -0
- data/test/unit/comatose_page_test.rb +136 -0
- data/test/unit/processing_context_test.rb +108 -0
- data/test/unit/text_filters_test.rb +52 -0
- data/views/comatose_admin/_form.html.erb +96 -0
- data/views/comatose_admin/_page_list_item.html.erb +60 -0
- data/views/comatose_admin/delete.html.erb +18 -0
- data/views/comatose_admin/edit.html.erb +5 -0
- data/views/comatose_admin/index.html.erb +29 -0
- data/views/comatose_admin/new.html.erb +5 -0
- data/views/comatose_admin/reorder.html.erb +30 -0
- data/views/comatose_admin/versions.html.erb +40 -0
- data/views/layouts/comatose_admin.html.erb +837 -0
- data/views/layouts/comatose_admin_customize.html.erb +28 -0
- data/views/layouts/comatose_content.html.erb +17 -0
- metadata +148 -0
@@ -0,0 +1,404 @@
|
|
1
|
+
BODY {
|
2
|
+
background: #DDD;
|
3
|
+
margin: 0px 100px;
|
4
|
+
padding: 0px;
|
5
|
+
font-family: "Lucida Grande", Tahoma, Verdana, Arial, Sans-Serif;
|
6
|
+
font-size: 12px;
|
7
|
+
min-width: 450px;
|
8
|
+
}
|
9
|
+
/* General Layout and Header Area */
|
10
|
+
#page-container {
|
11
|
+
margin: 0px;
|
12
|
+
padding: 0px;
|
13
|
+
}
|
14
|
+
#header {
|
15
|
+
background: #0053C2;
|
16
|
+
padding: 5px;
|
17
|
+
border-bottom: 4px solid #00398B;
|
18
|
+
}
|
19
|
+
#header A {
|
20
|
+
text-decoration: none;
|
21
|
+
color: white;
|
22
|
+
}
|
23
|
+
#header A:hover {
|
24
|
+
color: white;
|
25
|
+
}
|
26
|
+
#header h1 {
|
27
|
+
margin: 0px;
|
28
|
+
padding: 0px;
|
29
|
+
padding-left: 10px;
|
30
|
+
}
|
31
|
+
#header h5 {
|
32
|
+
margin: 0px;
|
33
|
+
padding: 0px;
|
34
|
+
padding-left: 15px;
|
35
|
+
color: silver;
|
36
|
+
}
|
37
|
+
#header #flash {
|
38
|
+
float: right;
|
39
|
+
color: #4BA8FF;
|
40
|
+
font-weight: bold;
|
41
|
+
margin-right: 5px;
|
42
|
+
}
|
43
|
+
/* Content Area */
|
44
|
+
#content {
|
45
|
+
padding: 15px;
|
46
|
+
background: white;
|
47
|
+
border-left: 1px solid silver;
|
48
|
+
border-right: 1px solid silver;
|
49
|
+
}
|
50
|
+
#content h1 {
|
51
|
+
margin: 0px;
|
52
|
+
padding: 0px;
|
53
|
+
font-size: 135%;
|
54
|
+
color: gray;
|
55
|
+
}
|
56
|
+
#content .action {
|
57
|
+
float: right;
|
58
|
+
color: gray;
|
59
|
+
}
|
60
|
+
#content .action A {
|
61
|
+
font-weight: bold;
|
62
|
+
text-decoration: none;
|
63
|
+
color: navy;
|
64
|
+
border-bottom: 1px solid blue;
|
65
|
+
margin-left: 15px;
|
66
|
+
}
|
67
|
+
#content .action A:hover {
|
68
|
+
color: red;
|
69
|
+
border-bottom: 1px solid red;
|
70
|
+
}
|
71
|
+
#content .page-header {
|
72
|
+
color: gray;
|
73
|
+
}
|
74
|
+
#import_form {
|
75
|
+
position: fixed;
|
76
|
+
right: 75px;
|
77
|
+
border: 3px solid gray !important;
|
78
|
+
-webkit-border-radius: 10px;
|
79
|
+
-moz-border-radius: 10px;
|
80
|
+
background: #FFF;
|
81
|
+
padding: 15px;
|
82
|
+
}
|
83
|
+
#import_form FORM {
|
84
|
+
display: inline;
|
85
|
+
margin: 0px;
|
86
|
+
padding: 0px;
|
87
|
+
}
|
88
|
+
#import_form A {
|
89
|
+
color: maroon !important;
|
90
|
+
border-bottom: 1px solid gray !important;
|
91
|
+
}
|
92
|
+
#import_form A:hover {
|
93
|
+
color: red !important;
|
94
|
+
border-bottom: 1px solid red !important;
|
95
|
+
}
|
96
|
+
|
97
|
+
/* Page Listing */
|
98
|
+
#content .tree-controller {
|
99
|
+
border: 0px;
|
100
|
+
cursor: pointer;
|
101
|
+
}
|
102
|
+
#content .page-list.root {
|
103
|
+
clear: both;
|
104
|
+
list-style: none;
|
105
|
+
margin: 0px;
|
106
|
+
padding: 0px;
|
107
|
+
margin-top: 10px;
|
108
|
+
}
|
109
|
+
#content .page-list.collapsed {
|
110
|
+
display: none;
|
111
|
+
}
|
112
|
+
#content .page-list {
|
113
|
+
background: white;
|
114
|
+
clear: both;
|
115
|
+
list-style: none;
|
116
|
+
border-left: 0px dotted silver;
|
117
|
+
margin: 0px;
|
118
|
+
padding: 0px;
|
119
|
+
padding-left: 15px;
|
120
|
+
margin-top: 2px;
|
121
|
+
}
|
122
|
+
#content .page-list LI {
|
123
|
+
clear: both;
|
124
|
+
padding: 0px;
|
125
|
+
margin: 5px 0px;
|
126
|
+
padding-top: 2px;
|
127
|
+
padding-right: 0px;
|
128
|
+
padding-left: 2px;
|
129
|
+
}
|
130
|
+
#content .page-list .commands {
|
131
|
+
font-size: 90%;
|
132
|
+
padding-left: 5px;
|
133
|
+
color: silver;
|
134
|
+
}
|
135
|
+
#content .page-list .commands A {
|
136
|
+
color: gray;
|
137
|
+
}
|
138
|
+
#content .page-list .commands A.add-page:hover {
|
139
|
+
color: blue;
|
140
|
+
}
|
141
|
+
#content .page-list .commands A.reorder-children:hover {
|
142
|
+
color: black;
|
143
|
+
}
|
144
|
+
#content .page-list .commands A.delete-page:hover {
|
145
|
+
color: white;
|
146
|
+
}
|
147
|
+
#content .page-list .commands A.reordering {
|
148
|
+
background: navy;
|
149
|
+
color: white;
|
150
|
+
}
|
151
|
+
#content .page-list .commands A.reordering:hover {
|
152
|
+
color: white;
|
153
|
+
}
|
154
|
+
#content .page-list A.page {
|
155
|
+
text-decoration: none;
|
156
|
+
color: black;
|
157
|
+
margin-left: 3px;
|
158
|
+
font-size: 150%;
|
159
|
+
display: block;
|
160
|
+
}
|
161
|
+
#content .page-list A.page:hover {
|
162
|
+
/*color: blue;*/
|
163
|
+
background: white url(../images/comatose/title-hover-bg.gif) top left repeat-y;
|
164
|
+
}
|
165
|
+
#content .handle, #content .do-reorder UL LI .handle {
|
166
|
+
display: none;
|
167
|
+
}
|
168
|
+
|
169
|
+
#content .page-list .hover {
|
170
|
+
background: #F1F0DB;
|
171
|
+
}
|
172
|
+
#content .page-list .hover-delete {
|
173
|
+
background: red;
|
174
|
+
color: #FF8E90;
|
175
|
+
}
|
176
|
+
#content .page-list .hover-delete A,
|
177
|
+
#content .page-list .hover-delete .commands A {
|
178
|
+
color: #FF8E90;
|
179
|
+
}
|
180
|
+
#content .page-list .hover-delete A.page {
|
181
|
+
color: white;
|
182
|
+
border-bottom: 0px;
|
183
|
+
}
|
184
|
+
#content .page-list .hover-delete UL LI A.page {
|
185
|
+
color: red;
|
186
|
+
border-bottom: 0px;
|
187
|
+
}
|
188
|
+
|
189
|
+
#content .do-reorder LI .handle {
|
190
|
+
display: inline;
|
191
|
+
background: gray;
|
192
|
+
color: white;
|
193
|
+
padding: 1px 3px;
|
194
|
+
cursor: move;
|
195
|
+
}
|
196
|
+
|
197
|
+
#content .page-list .do-reorder .commands A {
|
198
|
+
display: none;
|
199
|
+
}
|
200
|
+
|
201
|
+
/* Page Form */
|
202
|
+
#content .page-form {
|
203
|
+
margin-top: 10px;
|
204
|
+
}
|
205
|
+
#content .page-form LABEL {
|
206
|
+
font-weight: bold;
|
207
|
+
color: #555;
|
208
|
+
}
|
209
|
+
#content .page-form .meta-info LABEL {
|
210
|
+
color: #999 !important;
|
211
|
+
}
|
212
|
+
#content .page-form .label {
|
213
|
+
padding-top: 5px;
|
214
|
+
width: 75px;
|
215
|
+
text-align: right;
|
216
|
+
padding-right: 10px;
|
217
|
+
}
|
218
|
+
#content .page-form .label.body {
|
219
|
+
vertical-align: top;
|
220
|
+
padding-top: 10px;
|
221
|
+
}
|
222
|
+
#content .page-form .field {
|
223
|
+
padding-top: 5px;
|
224
|
+
}
|
225
|
+
#content .page-form .field-help {
|
226
|
+
color: gray;
|
227
|
+
}
|
228
|
+
#content .page-form #page_title {
|
229
|
+
font-size: 125%;
|
230
|
+
font-weight: bold;
|
231
|
+
}
|
232
|
+
#content .page-form #page_slug {
|
233
|
+
color: gray;
|
234
|
+
}
|
235
|
+
#content .page-form #page_body {
|
236
|
+
font-family: monospace;
|
237
|
+
font-size: 110%;
|
238
|
+
}
|
239
|
+
#content #button-group {
|
240
|
+
padding: 10px;
|
241
|
+
text-align: right;
|
242
|
+
background-color: #EAEAEA;
|
243
|
+
margin-top: 10px;
|
244
|
+
}
|
245
|
+
#content #button-group .last-update {
|
246
|
+
float: left;
|
247
|
+
color: gray;
|
248
|
+
padding-top: 4px;
|
249
|
+
font-weight: bold;
|
250
|
+
}
|
251
|
+
#content #button-group .last-update LABEL {
|
252
|
+
font-weight: normal;
|
253
|
+
}
|
254
|
+
#content #button-group .last-update A {
|
255
|
+
color: gray;
|
256
|
+
}
|
257
|
+
#content #button-group A {
|
258
|
+
color: maroon;
|
259
|
+
}
|
260
|
+
#content #button-group A:hover {
|
261
|
+
color: red;
|
262
|
+
}
|
263
|
+
#content #preview-area {
|
264
|
+
margin-top: 10px;
|
265
|
+
}
|
266
|
+
#content #preview-area FIELDSET {
|
267
|
+
border: 1px solid silver;
|
268
|
+
}
|
269
|
+
#content #preview-area LEGEND {
|
270
|
+
font-size: 125%;
|
271
|
+
}
|
272
|
+
#content #preview-area .preview-body {
|
273
|
+
padding: 10px;
|
274
|
+
}
|
275
|
+
#content #preview-area .preview-note {
|
276
|
+
background: #FFFFD9;
|
277
|
+
padding: 15px;
|
278
|
+
}
|
279
|
+
#content #preview-area .commands {
|
280
|
+
text-align: right;
|
281
|
+
color: gray;
|
282
|
+
}
|
283
|
+
#content #preview-area .commands A{
|
284
|
+
color: gray;
|
285
|
+
}
|
286
|
+
#content #preview-area .commands A:hover{
|
287
|
+
color: black;
|
288
|
+
}
|
289
|
+
#content .revisions {
|
290
|
+
padding: 10px;
|
291
|
+
width: 49%;
|
292
|
+
}
|
293
|
+
#content .current-content {
|
294
|
+
}
|
295
|
+
#content .older-content {
|
296
|
+
background: #E9E9E9;
|
297
|
+
float: right;
|
298
|
+
}
|
299
|
+
|
300
|
+
#content .revisions label {
|
301
|
+
display: block;
|
302
|
+
color: #000;
|
303
|
+
}
|
304
|
+
#content .revisions label span {
|
305
|
+
color: #999;
|
306
|
+
font-weight: normal !important;
|
307
|
+
}
|
308
|
+
#content .revisions .title {
|
309
|
+
font-weight: bold;
|
310
|
+
margin-top: 5px;
|
311
|
+
}
|
312
|
+
#content .revisions .header {
|
313
|
+
font-size: 110%;
|
314
|
+
vertical-align: middle;
|
315
|
+
font-weight: bold;
|
316
|
+
}
|
317
|
+
#content .revisions .header-actions {
|
318
|
+
float: right;
|
319
|
+
font-size: 90%;
|
320
|
+
font-weight: normal;
|
321
|
+
color: #999;
|
322
|
+
}
|
323
|
+
#content .revisions .meta {
|
324
|
+
margin-bottom: 15px;
|
325
|
+
}
|
326
|
+
#content .revisions .footer {
|
327
|
+
margin-top: 25px !important;
|
328
|
+
text-align: center !important;
|
329
|
+
}
|
330
|
+
#content #go-btn {
|
331
|
+
display: none;
|
332
|
+
}
|
333
|
+
/* Errors */
|
334
|
+
#errorExplanation {
|
335
|
+
border: 1px solid red;
|
336
|
+
background: #FFEAEB;
|
337
|
+
padding: 10px;
|
338
|
+
margin-top: 10px;
|
339
|
+
}
|
340
|
+
#errorExplanation h2 {
|
341
|
+
margin: 0px;
|
342
|
+
padding: 0px;
|
343
|
+
color: maroon;
|
344
|
+
}
|
345
|
+
#errorExplanation p {
|
346
|
+
margin: 0px;
|
347
|
+
padding: 0px;
|
348
|
+
padding-top: 5px;
|
349
|
+
padding-left: 15px;
|
350
|
+
}
|
351
|
+
#errorExplanation ul {
|
352
|
+
margin: 0px;
|
353
|
+
padding: 0px;
|
354
|
+
padding-left: 35px;
|
355
|
+
}
|
356
|
+
#errorExplanation li {
|
357
|
+
margin: 0px;
|
358
|
+
padding: 0px;
|
359
|
+
padding-top: 5px;
|
360
|
+
}
|
361
|
+
/* Footer Area*/
|
362
|
+
#footer {
|
363
|
+
border-top: 4px solid #AAA;
|
364
|
+
text-align: center;
|
365
|
+
font-size: 90%;
|
366
|
+
color: #AAA;
|
367
|
+
padding-top: 5px;
|
368
|
+
padding-bottom: 5px;
|
369
|
+
}
|
370
|
+
#footer A {
|
371
|
+
color: #AAA;
|
372
|
+
text-decoration: none;
|
373
|
+
font-weight: bold;
|
374
|
+
}
|
375
|
+
#footer A:hover {
|
376
|
+
color: #333;
|
377
|
+
text-decoration: underline;
|
378
|
+
}
|
379
|
+
|
380
|
+
/* Modifiers */
|
381
|
+
|
382
|
+
/* When JavaScript is Turned Off... We need to adjust some things... */
|
383
|
+
.noscript #more-options,
|
384
|
+
.noscript #preview-area,
|
385
|
+
.noscript #preview-btn,
|
386
|
+
.noscript .tree-controller {
|
387
|
+
display: none;
|
388
|
+
}
|
389
|
+
.noscript .page-list.collapsed {
|
390
|
+
display: block !important;
|
391
|
+
}
|
392
|
+
.noscript .delete-page:hover {
|
393
|
+
color: red !important;
|
394
|
+
}
|
395
|
+
.noscript #content .page-form #page_title,
|
396
|
+
.noscript #content .page-form #page_slug,
|
397
|
+
.noscript #content .page-form #page_parent,
|
398
|
+
.noscript #content .page-form #page_keywords,
|
399
|
+
.noscript #content .page-form #page_body {
|
400
|
+
width: 100% !important;
|
401
|
+
}
|
402
|
+
.noscript #content .revisions #go-btn {
|
403
|
+
display: inline;
|
404
|
+
}
|
data/tasks/comatose.rake
ADDED
data/test/behaviors.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
module Behaviors
|
5
|
+
include Rake
|
6
|
+
|
7
|
+
class ReportTask < TaskLib
|
8
|
+
attr_accessor :pattern
|
9
|
+
attr_accessor :html_dir
|
10
|
+
|
11
|
+
def initialize(name=:behaviors)
|
12
|
+
@name = name
|
13
|
+
@html_dir = 'doc'
|
14
|
+
yield self if block_given?
|
15
|
+
define
|
16
|
+
end
|
17
|
+
|
18
|
+
def define
|
19
|
+
desc "List behavioral definitions for the classes specified (use for=<regexp> to further limit files included in report)"
|
20
|
+
task @name do
|
21
|
+
specifications.each do |spec|
|
22
|
+
puts "#{spec.name} should:\n"
|
23
|
+
spec.requirements.each do |req|
|
24
|
+
puts " - #{req}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Generate html report of behavioral definitions for the classes specified (use for=<regexp> to further limit files included in report)"
|
30
|
+
task "#{@name}_html" do
|
31
|
+
require 'erb'
|
32
|
+
txt =<<-EOS
|
33
|
+
<html><head>
|
34
|
+
<style>
|
35
|
+
div.title { width: 600px; font: bold 14pt trebuchet ms; }
|
36
|
+
div.specification { font: bold 12pt trebuchet ms; border: solid 1px black; width: 600px; padding: 5px; margin: 5px; }
|
37
|
+
ul.requirements { font: normal 11pt verdana; padding-left: 0; margin-left: 0; border-bottom: 1px solid gray; width: 600px; }
|
38
|
+
ul.requirements li { list-style: none; margin: 0; padding: 0.25em; border-top: 1px solid gray; }
|
39
|
+
</style>
|
40
|
+
</head>
|
41
|
+
<body>
|
42
|
+
<div class="title">Specifications</div>
|
43
|
+
<% specifications.each do |spec| %>
|
44
|
+
<div class="specification">
|
45
|
+
<%= spec.name %> should:
|
46
|
+
<ul class="requirements">
|
47
|
+
<% spec.requirements.each do |req| %>
|
48
|
+
<li><%= req %></li>
|
49
|
+
<% end %>
|
50
|
+
</ul>
|
51
|
+
</div>
|
52
|
+
<% end %>
|
53
|
+
</body>
|
54
|
+
</html>
|
55
|
+
EOS
|
56
|
+
output_dir = File.expand_path(@html_dir)
|
57
|
+
mkdir_p output_dir
|
58
|
+
output_filename = output_dir + "/behaviors.html"
|
59
|
+
File.open(output_filename,"w") do |f|
|
60
|
+
f.write ERB.new(txt).result(binding)
|
61
|
+
end
|
62
|
+
puts "(Wrote #{output_filename})"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
def test_files
|
70
|
+
test_list = FileList[@pattern]
|
71
|
+
if ENV['for']
|
72
|
+
test_list = test_list.grep(/#{ENV['for']}/i)
|
73
|
+
end
|
74
|
+
test_list
|
75
|
+
end
|
76
|
+
|
77
|
+
def specifications
|
78
|
+
test_files.map do |file|
|
79
|
+
spec = OpenStruct.new
|
80
|
+
m = %r".*/([^/].*)_test.rb".match(file)
|
81
|
+
class_name = titleize(m[1]) if m[1]
|
82
|
+
spec.name = class_name
|
83
|
+
spec.requirements = []
|
84
|
+
File::readlines(file).each do |line|
|
85
|
+
if line =~ /^\s*should\s+\(?\s*["'](.*)["']/
|
86
|
+
spec.requirements << $1
|
87
|
+
end
|
88
|
+
end
|
89
|
+
spec
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def titleize(word)
|
94
|
+
humanize(underscore(word)).gsub(/\b([a-z])/) { $1.capitalize }
|
95
|
+
end
|
96
|
+
|
97
|
+
def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/').
|
98
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
|
99
|
+
end
|
100
|
+
|
101
|
+
def humanize(lower_case_and_underscored_word)
|
102
|
+
lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# ComatosePage attributes
|
2
|
+
# - parent_id
|
3
|
+
# - title
|
4
|
+
# - full_path
|
5
|
+
# - slug
|
6
|
+
# - keywords
|
7
|
+
# - body
|
8
|
+
# - author
|
9
|
+
# - filter_type
|
10
|
+
# - position
|
11
|
+
# - version
|
12
|
+
# - updated_on
|
13
|
+
# - created_on
|
14
|
+
|
15
|
+
root:
|
16
|
+
id: 1
|
17
|
+
parent_id:
|
18
|
+
full_path: ""
|
19
|
+
slug: home-page
|
20
|
+
title: Home Page
|
21
|
+
body: |-
|
22
|
+
h1. {{ page.title }}
|
23
|
+
|
24
|
+
This is your *home page*.
|
25
|
+
author: Comatose
|
26
|
+
keywords: "test, cms"
|
27
|
+
filter_type: Textile
|
28
|
+
position: 0
|
29
|
+
created_on: <%= 10.days.ago.to_s :db %>
|
30
|
+
updated_on: <%= 10.days.ago.to_s :db %>
|
31
|
+
|
32
|
+
faq:
|
33
|
+
id: 2
|
34
|
+
parent_id: 1
|
35
|
+
full_path: "faq"
|
36
|
+
slug: faq
|
37
|
+
title: Frequently Asked Questions
|
38
|
+
body: |-
|
39
|
+
h1. {{ page.title }}
|
40
|
+
{% for c in page.children %}
|
41
|
+
h2. {{ c.link }}
|
42
|
+
|
43
|
+
{{ c.to_html }}
|
44
|
+
|
45
|
+
{% endfor %}
|
46
|
+
created_on: <%= 10.days.ago.to_s :db %>
|
47
|
+
updated_on: <%= 10.days.ago.to_s :db %>
|
48
|
+
author: Comatose
|
49
|
+
keywords: faq
|
50
|
+
filter_type: Textile
|
51
|
+
position: 0
|
52
|
+
|
53
|
+
question_one:
|
54
|
+
id: 3
|
55
|
+
parent_id: 2
|
56
|
+
full_path: "faq/question-one"
|
57
|
+
slug: question-one
|
58
|
+
title: Question One?
|
59
|
+
body: |-
|
60
|
+
Content for *question one*.
|
61
|
+
created_on: <%= 10.days.ago.to_s :db %>
|
62
|
+
updated_on: <%= 10.days.ago.to_s :db %>
|
63
|
+
author: Comatose
|
64
|
+
keywords: faq
|
65
|
+
filter_type: Textile
|
66
|
+
position: 0
|
67
|
+
|
68
|
+
question_two:
|
69
|
+
id: 4
|
70
|
+
parent_id: 2
|
71
|
+
full_path: "faq/question-two"
|
72
|
+
slug: question-two
|
73
|
+
title: Question Two?
|
74
|
+
body: |-
|
75
|
+
Content for *question two*.
|
76
|
+
created_on: <%= 10.days.ago.to_s :db %>
|
77
|
+
updated_on: <%= 10.days.ago.to_s :db %>
|
78
|
+
author: Comatose
|
79
|
+
keywords: faq
|
80
|
+
filter_type: Textile
|
81
|
+
position: 1
|
82
|
+
|
83
|
+
param_driven:
|
84
|
+
id: 5
|
85
|
+
parent_id: 1
|
86
|
+
full_path: "params"
|
87
|
+
slug: params
|
88
|
+
title: Params
|
89
|
+
body: |-
|
90
|
+
I'm {{ extra }}
|
91
|
+
created_on: <%= 10.days.ago.to_s :db %>
|
92
|
+
updated_on: <%= 10.days.ago.to_s :db %>
|
93
|
+
author: Comatose
|
94
|
+
keywords:
|
95
|
+
filter_type: Textile
|
96
|
+
position: 0
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
require 'comatose_admin_controller'
|
3
|
+
require 'comatose_admin_helper'
|
4
|
+
require 'text_filters'
|
5
|
+
|
6
|
+
# Re-raise errors caught by the controller.
|
7
|
+
class ComatoseAdminController
|
8
|
+
def rescue_action(e) raise e end
|
9
|
+
end
|
10
|
+
|
11
|
+
class ComatoseAdminControllerTest < Test::Unit::TestCase
|
12
|
+
|
13
|
+
fixtures :comatose_pages
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@controller = ComatoseAdminController.new
|
17
|
+
@request = ActionController::TestRequest.new
|
18
|
+
@response = ActionController::TestResponse.new
|
19
|
+
Comatose.config.admin_get_author = nil
|
20
|
+
Comatose.config.admin_authorization = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
should "show the index action" do
|
24
|
+
get :index
|
25
|
+
assert_response :success
|
26
|
+
assert assigns(:root_pages)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "show the new action" do
|
30
|
+
get :new
|
31
|
+
assert_response :success
|
32
|
+
assert assigns(:page)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "successfully create pages" do
|
36
|
+
post :new, :page=>{:title=>"Test page", :body=>'This is a *test*', :parent_id=>1, :filter_type=>'Textile'}
|
37
|
+
assert_response :redirect
|
38
|
+
assert_redirected_to :controller=>'comatose_admin', :action=>'index'
|
39
|
+
end
|
40
|
+
|
41
|
+
should "create a page with an empty body" do
|
42
|
+
post :new, :page=>{:title=>"Test page", :body=>nil, :parent_id=>1, :filter_type=>'Textile'}
|
43
|
+
assert_response :redirect
|
44
|
+
assert_redirected_to :controller=>'comatose_admin', :action=>'index'
|
45
|
+
end
|
46
|
+
|
47
|
+
should "not create a page with a missing title" do
|
48
|
+
post :new, :page=>{:title=>nil, :body=>'This is a *test*', :parent_id=>1, :filter_type=>'Textile'}
|
49
|
+
assert_response :success
|
50
|
+
assert assigns.has_key?('page'), "Page assignment"
|
51
|
+
assert (assigns['page'].errors.length > 0), "Page errors"
|
52
|
+
assert_equal 'must be present', assigns['page'].errors.on('title')
|
53
|
+
end
|
54
|
+
|
55
|
+
should "not create a page associated to an invalid parent" do
|
56
|
+
post :new, :page=>{:title=>'Test page', :body=>'This is a *test*', :parent_id=>nil, :filter_type=>'Textile'}
|
57
|
+
assert_response :success
|
58
|
+
assert assigns.has_key?('page'), "Page assignment"
|
59
|
+
assert (assigns['page'].errors.length > 0), "Page errors"
|
60
|
+
assert_equal 'must be present', assigns['page'].errors.on('parent_id')
|
61
|
+
end
|
62
|
+
|
63
|
+
should "contain all the correct options for filter_type" do
|
64
|
+
get :new
|
65
|
+
assert_response :success
|
66
|
+
assert_select 'SELECT[id=page_filter_type]>*', :count=>TextFilters.all_titles.length
|
67
|
+
end
|
68
|
+
|
69
|
+
should "show the edit action" do
|
70
|
+
get :edit, :id=>1
|
71
|
+
assert_response :success
|
72
|
+
end
|
73
|
+
|
74
|
+
should "update pages with valid data" do
|
75
|
+
post :edit, :id=>1, :page=>{ :title=>'A new title' }
|
76
|
+
assert_response :redirect
|
77
|
+
assert_redirected_to :action=>"index"
|
78
|
+
end
|
79
|
+
|
80
|
+
should "not update pages with invalid data" do
|
81
|
+
post :edit, :id=>1, :page=>{ :title=>nil }
|
82
|
+
assert_response :success
|
83
|
+
assert_equal 'must be present', assigns['page'].errors.on('title')
|
84
|
+
end
|
85
|
+
|
86
|
+
should "delete a page" do
|
87
|
+
post :delete, :id=>1
|
88
|
+
assert_response :redirect
|
89
|
+
assert_redirected_to :action=>"index"
|
90
|
+
end
|
91
|
+
|
92
|
+
should "reorder pages" do
|
93
|
+
q1 = comatose_page :question_one
|
94
|
+
assert_not_nil q1
|
95
|
+
assert_difference q1, :position do
|
96
|
+
post :reorder, :id=>q1.parent.id, :page=>q1.id, :cmd=>'down'
|
97
|
+
assert_response :redirect
|
98
|
+
assert_redirected_to :action=>"reorder"
|
99
|
+
q1.reload
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
should "set runtime mode" do
|
104
|
+
assert_equal :plugin, ComatoseAdminController.runtime_mode
|
105
|
+
comatose_admin_view_path = File.expand_path(File.join( File.dirname(__FILE__), '..', '..', 'views'))
|
106
|
+
|
107
|
+
if ComatoseAdminController.respond_to?(:template_root)
|
108
|
+
assert_equal comatose_admin_view_path, ComatoseAdminController.template_root
|
109
|
+
else
|
110
|
+
assert ComatoseAdminController.view_paths.include?(comatose_admin_view_path)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|