survey_on_rails 0.3.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 (76) hide show
  1. checksums.yaml +15 -0
  2. data/lib/generators/survey/USAGE +5 -0
  3. data/lib/generators/survey/metamodels/app.rb +88 -0
  4. data/lib/generators/survey/metamodels/base.rb +120 -0
  5. data/lib/generators/survey/metamodels/main.rb +12 -0
  6. data/lib/generators/survey/metamodels/model.rb +140 -0
  7. data/lib/generators/survey/metamodels/style.rb +202 -0
  8. data/lib/generators/survey/metamodels/types.rb +10 -0
  9. data/lib/generators/survey/metamodels/validation.rb +28 -0
  10. data/lib/generators/survey/metamodels/view.rb +384 -0
  11. data/lib/generators/survey/survey_generator.rb +276 -0
  12. data/lib/generators/survey/templates/app/app.tpl +15 -0
  13. data/lib/generators/survey/templates/app/assets/assets.tpl +10 -0
  14. data/lib/generators/survey/templates/app/assets/javascripts/application.tpl +32 -0
  15. data/lib/generators/survey/templates/app/assets/stylesheets/static_stylesheet.tpl +337 -0
  16. data/lib/generators/survey/templates/app/assets/stylesheets/stylesheet.tpl +128 -0
  17. data/lib/generators/survey/templates/app/assets/stylesheets/survey_stylesheet.tpl +102 -0
  18. data/lib/generators/survey/templates/app/controllers/application_controller.tpl +15 -0
  19. data/lib/generators/survey/templates/app/controllers/controllers.tpl +12 -0
  20. data/lib/generators/survey/templates/app/controllers/sessions_controller.tpl +26 -0
  21. data/lib/generators/survey/templates/app/controllers/static_pages_controller.tpl +14 -0
  22. data/lib/generators/survey/templates/app/controllers/survey_controller.tpl +105 -0
  23. data/lib/generators/survey/templates/app/controllers/users_controller.tpl +82 -0
  24. data/lib/generators/survey/templates/app/helpers/application_helper.tpl +26 -0
  25. data/lib/generators/survey/templates/app/helpers/helpers.tpl +9 -0
  26. data/lib/generators/survey/templates/app/helpers/sessions_helper.tpl +60 -0
  27. data/lib/generators/survey/templates/app/helpers/survey_helper.tpl +25 -0
  28. data/lib/generators/survey/templates/app/helpers/users_helper.tpl +14 -0
  29. data/lib/generators/survey/templates/app/models/answer.tpl +20 -0
  30. data/lib/generators/survey/templates/app/models/models.tpl +10 -0
  31. data/lib/generators/survey/templates/app/models/question.tpl +20 -0
  32. data/lib/generators/survey/templates/app/models/survey.tpl +17 -0
  33. data/lib/generators/survey/templates/app/models/user.tpl +28 -0
  34. data/lib/generators/survey/templates/app/models/validator.tpl +47 -0
  35. data/lib/generators/survey/templates/app/views/form/checkbox_group.tpl +13 -0
  36. data/lib/generators/survey/templates/app/views/form/choice_question.tpl +10 -0
  37. data/lib/generators/survey/templates/app/views/form/dropdown.tpl +15 -0
  38. data/lib/generators/survey/templates/app/views/form/element.tpl +43 -0
  39. data/lib/generators/survey/templates/app/views/form/form.tpl +35 -0
  40. data/lib/generators/survey/templates/app/views/form/group.tpl +14 -0
  41. data/lib/generators/survey/templates/app/views/form/horizontal_radio_button_group.tpl +7 -0
  42. data/lib/generators/survey/templates/app/views/form/image.tpl +10 -0
  43. data/lib/generators/survey/templates/app/views/form/pagination.tpl +60 -0
  44. data/lib/generators/survey/templates/app/views/form/radio_button_group.tpl +10 -0
  45. data/lib/generators/survey/templates/app/views/form/table.tpl +54 -0
  46. data/lib/generators/survey/templates/app/views/form/textfield.tpl +47 -0
  47. data/lib/generators/survey/templates/app/views/layouts/application.tpl +25 -0
  48. data/lib/generators/survey/templates/app/views/layouts/footer.tpl +28 -0
  49. data/lib/generators/survey/templates/app/views/layouts/header.tpl +32 -0
  50. data/lib/generators/survey/templates/app/views/layouts/shim.tpl +7 -0
  51. data/lib/generators/survey/templates/app/views/layouts/static_element.tpl +52 -0
  52. data/lib/generators/survey/templates/app/views/questions/question.tpl +8 -0
  53. data/lib/generators/survey/templates/app/views/sessions/new.tpl +28 -0
  54. data/lib/generators/survey/templates/app/views/shared/error_messages.tpl +16 -0
  55. data/lib/generators/survey/templates/app/views/shared/static_page.tpl +5 -0
  56. data/lib/generators/survey/templates/app/views/surveys/index.tpl +25 -0
  57. data/lib/generators/survey/templates/app/views/surveys/survey.tpl +14 -0
  58. data/lib/generators/survey/templates/app/views/users/edit.tpl +19 -0
  59. data/lib/generators/survey/templates/app/views/users/fields.tpl +24 -0
  60. data/lib/generators/survey/templates/app/views/users/index.tpl +17 -0
  61. data/lib/generators/survey/templates/app/views/users/new.tpl +15 -0
  62. data/lib/generators/survey/templates/app/views/users/show.tpl +17 -0
  63. data/lib/generators/survey/templates/app/views/users/user.tpl +11 -0
  64. data/lib/generators/survey/templates/app/views/views.tpl +30 -0
  65. data/lib/generators/survey/templates/config/application.tpl +26 -0
  66. data/lib/generators/survey/templates/config/config.tpl +8 -0
  67. data/lib/generators/survey/templates/config/routes.tpl +57 -0
  68. data/lib/generators/survey/templates/db/db.tpl +9 -0
  69. data/lib/generators/survey/templates/db/migrate/create_answers.tpl +20 -0
  70. data/lib/generators/survey/templates/db/migrate/create_questions.tpl +20 -0
  71. data/lib/generators/survey/templates/db/migrate/create_surveys.tpl +20 -0
  72. data/lib/generators/survey/templates/db/migrate/create_users.tpl +22 -0
  73. data/lib/generators/survey/templates/main.tpl +11 -0
  74. data/lib/survey_on_rails/utils/builder.rb +56 -0
  75. data/lib/survey_on_rails/utils/string.rb +22 -0
  76. metadata +116 -0
@@ -0,0 +1,32 @@
1
+ <% define 'static' do %>
2
+ <% file "app/assets/javascripts/application.js" do %>
3
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
4
+ // listed below.
5
+ //
6
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
7
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
8
+ //
9
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
10
+ // the compiled file.
11
+ //
12
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
13
+ // GO AFTER THE REQUIRES BELOW.
14
+ //
15
+ //= require jquery
16
+ //= require jquery_ujs
17
+ //= require bootstrap
18
+ //= require_tree .
19
+
20
+ <% expand 'info_script' %>
21
+ <% end %>
22
+ <% end %>
23
+
24
+ <% define 'dynamic', :for => Form do %>
25
+ <% end %>
26
+
27
+ <% define 'info_script' do %>
28
+ <% nl %>
29
+ jQuery(function($) {<% iinc %>
30
+ $(".info").popover({ placement: 'right', html: true, trigger: 'hover' }).popover('');
31
+ <% idec %>});
32
+ <% end %>
@@ -0,0 +1,337 @@
1
+ <% define 'application_stylesheet' do %>
2
+ <% file "app/assets/stylesheets/application.css" do %>
3
+ /*
4
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
5
+ * listed below.
6
+ *
7
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
8
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
9
+ *
10
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
11
+ * compiled file, but it's generally better to create a new file per style scope.
12
+ *
13
+ *= require_self
14
+ *= require_tree .
15
+ */
16
+ <% end %>
17
+ <% end %>
18
+
19
+ <% define 'static_stylesheet' do %>
20
+ <% file "app/assets/stylesheets/static.css.scss" do %>
21
+ @import "bootstrap";
22
+
23
+ <% nl %>
24
+ /* mixins, variables, etc. */
25
+
26
+ <% nl %>
27
+ $lightgray: #999;
28
+ $grayMediumLight: #eaeaea;
29
+ $gray: #555;
30
+ $grayDarker: #222;
31
+ $grayLighter: #999;
32
+
33
+ <% nl %>
34
+ @mixin box_sizing {<% iinc %>
35
+ -moz-box-sizing: border-box;
36
+ -webkit-box-sizing: border-box;
37
+ box-sizing: border-box;
38
+ <% idec %>}
39
+
40
+ <% nl %>
41
+ /* universal */
42
+
43
+ <% nl %>
44
+ html {<% iinc %>
45
+ overflow-y: scroll;
46
+ <% idec %>}
47
+
48
+ <% nl %>
49
+ body {<% iinc %>
50
+ padding-top: 60px;
51
+ <% idec %>}
52
+
53
+ <% nl %>
54
+ section {<% iinc %>
55
+ overflow: auto;
56
+ <% idec %>}
57
+
58
+ <% nl %>
59
+ textarea {<% iinc %>
60
+ resize: vertical;
61
+ <% idec %>}
62
+
63
+ <% nl %>
64
+ .center {<% iinc %>
65
+ text-align: center;
66
+ <% idec %>}
67
+
68
+ <% nl %>
69
+ .center h1 {<% iinc %>
70
+ margin-bottom: 10px;
71
+ <% idec %>}
72
+
73
+ <% nl %>
74
+ /* typography */
75
+
76
+ <% nl %>
77
+ h1, h2, h3, h4, h5, h6 {<% iinc %>
78
+ line-height: 1;
79
+ <% idec %>}
80
+
81
+ <% nl %>
82
+ h1 {<% iinc %>
83
+ font-size: 3em;
84
+ letter-spacing: -2px;
85
+ margin-bottom: 30px;
86
+ text-align: center;
87
+ <% idec %>}
88
+
89
+ <% nl %>
90
+ h2 {<% iinc %>
91
+ font-size: 1.7em;
92
+ letter-spacing: -1px;
93
+ margin-bottom: 30px;
94
+ text-align: center;
95
+ font-weight: normal;
96
+ color: $lightgray;
97
+ <% idec %>}
98
+
99
+ <% nl %>
100
+ /* header */
101
+
102
+ <% nl %>
103
+ #logo {<% iinc %>
104
+ float: left;
105
+ margin-right: 10px;
106
+ font-size: 1,7em;
107
+ color: #fff;
108
+ text-transform: uppercase;
109
+ letter-spacing: -1px;
110
+ padding-top: 9px;
111
+ font-weight: bold;
112
+ line-height: 1;
113
+ <% idec %>}
114
+
115
+ <% nl %>
116
+ #logo:hover {<% iinc %>
117
+ color: #fff;
118
+ text-decoration: none;
119
+ <% idec %>}
120
+
121
+ <% nl %>
122
+ /* footer */
123
+
124
+ <% nl %>
125
+ footer {<% iinc %>
126
+ margin-top: 48px;
127
+ padding-top: 5px;
128
+ border-top: 1px solid $grayMediumLight;
129
+ color: $lightgray;
130
+ <% idec %>}
131
+
132
+ <% nl %>
133
+ footer a {<% iinc %>
134
+ color: $gray;
135
+ <% idec %>}
136
+
137
+ <% nl %>
138
+ footer a:hover {<% iinc %>
139
+ color: $grayDarker;
140
+ <% idec %>}
141
+
142
+ <% nl %>
143
+ footer small {<% iinc %>
144
+ float: left;
145
+ <% idec %>}
146
+
147
+ <% nl %>
148
+ footer ul {<% iinc %>
149
+ float: right;
150
+ list-style: none;
151
+ <% idec %>}
152
+
153
+ <% nl %>
154
+ footer ul li {<% iinc %>
155
+ float: left;
156
+ margin-left: 10px;
157
+ <% idec %>}
158
+
159
+ <% nl %>
160
+ /* miscellaneous */
161
+
162
+ <% nl %>
163
+ .debug_dump {<% iinc %>
164
+ clear: both;
165
+ float: left;
166
+ width: 100%;
167
+ margin-top: 45px;
168
+ @include box-sizing;
169
+ <% idec %>}
170
+
171
+ <% nl %>
172
+ /* sidebar */
173
+
174
+ <% nl %>
175
+ aside {<% iinc %>
176
+ section {<% iinc %>
177
+ padding: 10px 0;
178
+ border-top: 1px solid $grayLighter;
179
+ &:first-child {<% iinc %>
180
+ border: 0;
181
+ padding-top: 0;
182
+ <% idec %>}
183
+ span {<% iinc %>
184
+ display: block;
185
+ margin-bottom: 3px;
186
+ line-height: 1;
187
+ <% idec %>}
188
+ h1 {<% iinc %>
189
+ font-size: 1.4em;
190
+ text-align: left;
191
+ letter-spacing: -1px;
192
+ margin-bottom: 3px;
193
+ margin-top: 0px;
194
+ <% idec %>}
195
+ <% idec %>}
196
+ <% idec %>}
197
+
198
+ <% nl %>
199
+ .gravatar {<% iinc %>
200
+ float: left;
201
+ margin-right: 10px;
202
+ <% idec %>}
203
+
204
+ <% nl %>
205
+ .stats {<% iinc %>
206
+ overflow: auto;
207
+ a {<% iinc %>
208
+ float: left;
209
+ padding: 0 10px;
210
+ border-left: 1px solid $grayLighter;
211
+ color: gray;
212
+ &:first-child {<% iinc %>
213
+ padding-left: 0;
214
+ border: 0;
215
+ <% idec %>}
216
+ &:hover {<% iinc %>
217
+ text-decoration: none;
218
+ color: $blue;
219
+ <% idec %>}
220
+ <% idec %>}
221
+ strong {<% iinc %>
222
+ display: block;
223
+ <% idec %>}
224
+ <% idec %>}
225
+
226
+ <% nl %>
227
+ .user_avatars {<% iinc %>
228
+ overflow: auto;
229
+ margin-top: 10px;
230
+ .gravatar {<% iinc %>
231
+ margin: 1px 1px;
232
+ <% idec %>}
233
+ <% idec %>}
234
+
235
+ <% nl %>
236
+ /* forms */
237
+
238
+ <% nl %>
239
+ input, textarea, select, .uneditable-input {<% iinc %>
240
+ border: 1px solid #bbb;
241
+ width: 100%;
242
+ padding: 10px;
243
+ margin-bottom: 15px;
244
+ @include box_sizing;
245
+ <% idec %>}
246
+
247
+ <% nl %>
248
+ input {<% iinc %>
249
+ height: auto !important;
250
+ <% idec %>}
251
+
252
+ <% nl %>
253
+ #error_explanation {<% iinc %>
254
+ color: #f00;
255
+ ul {<% iinc %>
256
+ list-style: none;
257
+ margin: 0 0 18px 0;
258
+ <% idec %>}
259
+ <% idec %>}
260
+
261
+ <% nl %>
262
+ .field_with_errors {<% iinc %>
263
+ @extend .control-group;
264
+ @extend .error;
265
+ <% idec %>}
266
+
267
+ <% nl %>
268
+ /* users index */
269
+
270
+ <% nl %>
271
+ .users {<% iinc %>
272
+ list-style: none;
273
+ margin: 0;
274
+ li {<% iinc %>
275
+ overflow: auto;
276
+ padding: 10px 0;
277
+ border-top: 1px solid $grayLighter;
278
+ &:last-child {<% iinc %>
279
+ border-bottom: 1px solid $grayLighter;
280
+ <% idec %>}
281
+ <% idec %>}
282
+ <% idec %>}
283
+
284
+ <% nl %>
285
+ /* microposts */
286
+
287
+ <% nl %>
288
+ .surveys {<% iinc %>
289
+ list-style: none;
290
+ margin: 10px 0 0 0;
291
+ li {<% iinc %>
292
+ padding: 10px 0;
293
+ border-top: 1px solid #e8e8e8;
294
+ ol {<% iinc %>
295
+ list-style: decimal;
296
+ font-weight: bold;
297
+ li {<% iinc %>
298
+ padding: 10px 0;
299
+ border-top: 0px;
300
+ <% idec %>}
301
+ <% idec %>}
302
+ <% idec %>}
303
+ <% idec %>}
304
+
305
+ <% nl %>
306
+ .question_content {<% iinc %>
307
+ font-weight: normal;
308
+ <% idec %>}
309
+
310
+ <% nl %>
311
+ .content {<% iinc %>
312
+ display: block;
313
+ <% idec %>}
314
+
315
+ <% nl %>
316
+ .timestamp {<% iinc %>
317
+ color: $grayLight;
318
+ <% idec %>}
319
+
320
+ <% nl %>
321
+ .gravatar {<% iinc %>
322
+ float: left;
323
+ margin-right: 10px;
324
+ <% idec %>}
325
+
326
+ <% nl %>
327
+ aside {<% iinc %>
328
+ textarea {<% iinc %>
329
+ height: 100px;
330
+ margin-bottom: 5px;
331
+ <% idec %>}
332
+ <% idec %>}
333
+
334
+ <% nl %>
335
+ <% expand 'survey_stylesheet::survey_stylesheet' %>
336
+ <% end %>
337
+ <% end %>
@@ -0,0 +1,128 @@
1
+ <% define 'stylesheet', :for => View do %>
2
+ <% forms.each do |form| %>
3
+ <% expand 'form', :for => form %>
4
+ <% end %>
5
+
6
+ <% file "app/assets/stylesheets/custom.css.scss" do %>
7
+ /* custom styles */
8
+ <% styles.each do |style| %>
9
+ <% expand 'element_style', :for => style %>
10
+ <% end %>
11
+
12
+ <% header.elements.each do |element| %>
13
+ <% if !element.style.nil? %><% expand 'static_element', :for => element %><% end %>
14
+ <% end %>
15
+
16
+ <% footer.elements.each do |element| %>
17
+ <% if !element.style.nil? %><% expand 'static_element', :for => element %><% end %>
18
+ <% end %>
19
+ <% end %>
20
+ <% end %>
21
+
22
+ <% define 'form', :for => Form do %>
23
+ <% file "app/assets/stylesheets/#{file_name}.css.scss" do %>
24
+ /* custom styles on element basis */
25
+ <% elements.each do |element| %>
26
+ <% expand 'question', :for => element %>
27
+
28
+ <% if element.is_a?(Group) %>
29
+ <% element.elements.each do |elem| %>
30
+ <% expand 'view_element', :for => elem %>
31
+ <% end %>
32
+ <% end %>
33
+ <% end %>
34
+ <% end %>
35
+ <% end %>
36
+
37
+ <% define 'question', :for => StyleElement do %>
38
+ <% if name? and style? %>
39
+ <% nl %>
40
+ .<%= name %> {<% iinc %>
41
+ <% if self.is_a?(Textfield) %>
42
+ width: 100%;
43
+ <% end %>
44
+ padding: 5px 5px 5px 5px;
45
+
46
+ <% expand 'style', :for => style %>
47
+ <% idec %>}
48
+ <% end %>
49
+ <% end %>
50
+
51
+ <% define 'model_element', :for => ModelElement do %>
52
+ <% if name? and style? %>
53
+ <% nl %>
54
+ .<%= name %> {<% iinc %>
55
+ <% expand 'style', :for => style %>
56
+ <% idec %>}
57
+ <% end %>
58
+ <% end %>
59
+
60
+ <% define 'view_element', :for => ViewElement do %>
61
+ <% if name? and style? %>
62
+ <% nl %>
63
+ .<%= name %> {<% iinc %>
64
+ vertical-align: middle;
65
+ padding: 3px 3px 3px 3px;
66
+
67
+ <% expand 'style', :for => style %>
68
+ <% idec %>}
69
+ <% end %>
70
+ <% end %>
71
+
72
+ <% define 'static_element', :for => StaticElement do %>
73
+ <% if name? and style? %>
74
+ <% nl %>
75
+ .<%= name %> {<% iinc %>
76
+ <% expand 'style', :for => style %>
77
+ <% idec %>}
78
+ <% end %>
79
+ <% end %>
80
+
81
+ <% define 'element_style', :for => Style do %>
82
+ <% names.each do |name| %>
83
+ <% nl %>
84
+ .<%= name %> {<% iinc %>
85
+ <% expand 'style' %>
86
+ <% idec %>}
87
+ <% end %>
88
+ <% end %>
89
+
90
+ <% define 'style', :for => Style do %>
91
+ <% if margin? %>
92
+ margin:<% 4.times do %> <%= margin %>px<% end %>;
93
+ <% end %>
94
+ <% if padding? %>
95
+ padding:<% 4.times do %> <%= padding %>px<% end %>;
96
+ <% end %>
97
+ <% if foreground? %>
98
+ color: <%= color(foreground) %>;
99
+ <% end %>
100
+ <% if background? %>
101
+ background-color: <%= color(background) %>;
102
+ <% end %>
103
+ <% if font_size? %>
104
+ font-size: <%= font_size %> px;
105
+ <% end %>
106
+ <% if font_style? %>
107
+ font-style: <%= style %>;
108
+ <% end %>
109
+ <% if font_weight? %>
110
+ font-size: <%= weight %>;
111
+ <% end %>
112
+ <% if horizontal_align? %>
113
+ text-align: <%= horizontal_align %>;
114
+ <% end %>
115
+ <% if vertical_align? %>
116
+ vertical-align: <%= vertical_align %>;
117
+ <% end %>
118
+
119
+ <% styles.each do |style| %>
120
+ <% expand 'custom_style', :for => style %>
121
+ <% end %>
122
+ <% end %>
123
+
124
+ <% define 'custom_style', :for => CustomStyle do %>
125
+ <% if property? and value? %>
126
+ <%= property %>: <%= value %>;
127
+ <% end %>
128
+ <% end %>
@@ -0,0 +1,102 @@
1
+ <% define 'survey_stylesheet' do %>
2
+ /* survey */
3
+
4
+ <% nl %>
5
+ @mixin question_style {<% iinc %>
6
+ font-size: 1.2em;
7
+ font-weight: bold;
8
+ color: $gray;
9
+ margin-top: 10px;
10
+ margin-bottom: 5px;
11
+ <% idec %>}
12
+
13
+ <% nl %>
14
+ .author {<% iinc %>
15
+ color: $lightgray;
16
+ text-align: center;
17
+ margin-bottom: 20px;
18
+ <% idec %>}
19
+
20
+ <% nl %>
21
+ .question {<% iinc %>
22
+ @include question_style;
23
+ <% idec %>}
24
+
25
+ <% nl %>
26
+ .input {<% iinc %>
27
+ padding: 5px;
28
+ <% idec %>}
29
+
30
+ <% nl %>
31
+ .info {<% iinc %>
32
+ margin-bottom: 10px;
33
+ <% idec %>}
34
+
35
+ <% nl %>
36
+ fieldset {<% iinc %>
37
+ position: relative
38
+ <% idec %>}
39
+
40
+ <% nl %>
41
+ #group legend {<% iinc %>
42
+ @include question_style;
43
+ border: 0px;
44
+ padding: 10px;
45
+ margin: 0px 0px 0px 0px;
46
+ <% idec %>}
47
+
48
+ <% nl %>
49
+ .group-border {<% iinc %>
50
+ -moz-border-radius: 10px;
51
+ -webkit-border-radius: 10px;
52
+ border: 1px solid #C0C0C0;
53
+ border-radius: 10px;
54
+ margin: 10px 10px 10px 10px;
55
+ padding: 20px 20px 20px 20px;
56
+ @include box-sizing;
57
+ <% idec %>}
58
+
59
+ <% nl %>
60
+ .inline {<% iinc %>
61
+ display: inline-block;
62
+ <% idec %>}
63
+
64
+ <% nl %>
65
+ .no_padding {<% iinc %>
66
+ padding-left: 5px;
67
+ <% idec %>}
68
+
69
+ <% nl %>
70
+ .default_choice {<% iinc %>
71
+ vertical-align: middle;
72
+ padding: 3px 3px 3px 3px;
73
+ <% idec %>}
74
+
75
+ <% nl %>
76
+ .on {<% iinc %>
77
+ background-position: 0 16px;
78
+ <% idec %>}
79
+
80
+ <% nl %>
81
+ .submit_button {<% iinc %>
82
+ margin-left: auto;
83
+ margin-right: auto;
84
+ width: 50%;
85
+ <% idec %>}
86
+
87
+ <% nl %>
88
+ .select {<% iinc %>
89
+ padding: 5px;
90
+ <% idec %>}
91
+
92
+ <% nl %>
93
+ .inline_choice {<% iinc %>
94
+ padding-right: 15px;
95
+ <% idec %>}
96
+
97
+ <% nl %>
98
+ #data {<% iinc %>
99
+ text-align: center;
100
+ vertical-align: middle;
101
+ <% idec %>}
102
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <% define 'application_controller' do %>
2
+ <% file "app/controllers/application_controller.rb" do %>
3
+ class ApplicationController < ActionController::Base<% iinc %>
4
+ protect_from_forgery
5
+ include SessionsHelper
6
+
7
+ <% nl %>
8
+ # Force signout to prevent CSRF attacks
9
+ def handle_unverified request<% iinc %>
10
+ sign_out
11
+ super
12
+ <% idec %>end
13
+ <% idec %>end
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <% define 'static' do %>
2
+ <% expand 'application_controller::application_controller' %>
3
+ <% expand 'sessions_controller::sessions_controller' %>
4
+ <% expand 'survey_controller::static' %>
5
+ <% expand 'static_pages_controller::static' %>
6
+ <% expand 'users_controller::users_controller' %>
7
+ <% end %>
8
+
9
+ <% define 'dynamic' do %>
10
+ <% expand 'survey_controller::dynamic', :foreach => view.forms %>
11
+ <% expand 'static_pages_controller::dynamic', :for => view %>
12
+ <% end %>
@@ -0,0 +1,26 @@
1
+ <% define 'sessions_controller' do %>
2
+ <% file "app/controllers/sessions_controller.rb" do %>
3
+ class SessionsController < ApplicationController<% iinc %>
4
+ def new
5
+ end
6
+
7
+ <% nl %>
8
+ def create<% iinc %>
9
+ user = User.find_by_email(params[:email].downcase)
10
+ if user and user.authenticate(params[:password])<% iinc %>
11
+ sign_in user
12
+ redirect_to user
13
+ <% idec %>else<% iinc %>
14
+ flash.now[:error] = 'Invalid email/password combination'
15
+ render 'new'
16
+ <% idec %>end
17
+ <% idec %>end
18
+
19
+ <% nl %>
20
+ def destroy<% iinc %>
21
+ sign_out
22
+ redirect_to root_url
23
+ <% idec %>end
24
+ <% idec %>end
25
+ <% end %>
26
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <% define 'static' do %>
2
+ <% end %>
3
+
4
+ <% define 'dynamic', :for => View do %>
5
+ <% file "app/controllers/static_pages_controller.rb" do %>
6
+ class StaticPagesController < ApplicationController<% iinc %>
7
+ <% static_pages.each do |static_page| %>
8
+ <% nl %>
9
+ def <%= static_page.name %><% iinc %>
10
+ <% idec %>end
11
+ <% end %>
12
+ <% idec %>end
13
+ <% end %>
14
+ <% end %>