survey_generator 0.0.16 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/survey/USAGE +10 -10
- data/lib/generators/survey/metamodels/survey_metamodel.rb +68 -6
- data/lib/generators/survey/metamodels/survey_metamodel_ext.rb +23 -0
- data/lib/generators/survey/survey_generator.rb +15 -15
- data/lib/generators/survey/templates/app/app.tpl +9 -0
- data/lib/generators/survey/templates/app/assets/javascripts/application.tpl +20 -0
- data/lib/generators/survey/templates/app/assets/stylesheets/stylesheet.tpl +395 -0
- data/lib/generators/survey/templates/app/controllers/survey_controller.tpl +27 -0
- data/lib/generators/survey/templates/app/helpers/application_helper.tpl +14 -0
- data/lib/generators/survey/templates/app/models/survey_model.tpl +45 -0
- data/lib/generators/survey/templates/app/views/layouts/application.tpl +25 -0
- data/lib/generators/survey/templates/app/views/layouts/footer.tpl +17 -0
- data/lib/generators/survey/templates/app/views/layouts/header.tpl +41 -0
- data/lib/generators/survey/templates/app/views/layouts/shim.tpl +7 -0
- data/lib/generators/survey/templates/app/views/shared/error_messages.tpl +16 -0
- data/lib/generators/survey/templates/app/views/static_pages/about.tpl +12 -0
- data/lib/generators/survey/templates/app/views/static_pages/contact.tpl +10 -0
- data/lib/generators/survey/templates/app/views/static_pages/help.tpl +12 -0
- data/lib/generators/survey/templates/app/views/static_pages/home.tpl +18 -0
- data/lib/generators/survey/templates/{views → app/views/survey}/survey_form_view.tpl +0 -0
- data/lib/generators/survey/templates/app/views/survey/survey_index_view.tpl +38 -0
- data/lib/generators/survey/templates/app/views/views.tpl +16 -0
- data/lib/generators/survey/templates/config/config.tpl +3 -0
- data/lib/generators/survey/templates/config/routes.tpl +76 -0
- data/lib/generators/survey/templates/db/db.tpl +6 -0
- data/lib/generators/survey/templates/db/migrate/create_pages.tpl +18 -0
- data/lib/generators/survey/templates/db/migrate/create_questions.tpl +16 -0
- data/lib/generators/survey/templates/db/migrate/create_surveys.tpl +17 -0
- data/lib/generators/survey/templates/db/migrate/create_users.tpl +22 -0
- data/lib/generators/survey/templates/main.tpl +3 -3
- metadata +33 -10
- checksums.yaml +0 -15
- data/lib/generators/survey/templates/controllers/survey_controller.tpl +0 -8
- data/lib/generators/survey/templates/models/survey_model.tpl +0 -17
- data/lib/generators/survey/templates/views/survey_index_view.tpl +0 -30
- data/lib/generators/survey/templates/views/survey_view.tpl +0 -4
data/lib/generators/survey/USAGE
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
Description:
|
2
|
-
This generator will generate classes for a rails application to display a survey.
|
3
|
-
|
4
|
-
Example:
|
5
|
-
rails generate survey
|
6
|
-
|
7
|
-
This will create:
|
8
|
-
app/controllers/[NAME]_controller.rb
|
9
|
-
app/models/[NAME].rb
|
10
|
-
app/views/[NAME]/_form.html.erb
|
1
|
+
Description:
|
2
|
+
This generator will generate classes for a rails application to display a survey.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate survey
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
app/controllers/[NAME]_controller.rb
|
9
|
+
app/models/[NAME].rb
|
10
|
+
app/views/[NAME]/_form.html.erb
|
11
11
|
app/views/[NAME]/index.html.erb
|
@@ -1,21 +1,83 @@
|
|
1
1
|
require 'rgen/metamodel_builder'
|
2
2
|
|
3
3
|
module SurveyMetamodel extend RGen::MetamodelBuilder::ModuleExtension
|
4
|
-
class
|
4
|
+
class AnswerOption < RGen::MetamodelBuilder::MMBase
|
5
5
|
has_attr 'name', String
|
6
|
+
has_attr 'foreground', String #Color
|
7
|
+
has_attr 'background', String #Color
|
8
|
+
#has_attr 'stylingOptions', Array
|
9
|
+
end
|
10
|
+
|
11
|
+
class Checkbox < AnswerOption
|
12
|
+
end
|
13
|
+
|
14
|
+
class RadioButton < AnswerOption
|
15
|
+
end
|
16
|
+
|
17
|
+
class Textfield < AnswerOption
|
18
|
+
has_attr 'isSmall', Boolean
|
19
|
+
has_attr 'isMultiLine', Boolean
|
20
|
+
has_attr 'suffix', String
|
21
|
+
has_attr 'prefix', String
|
22
|
+
end
|
23
|
+
|
24
|
+
class RatingScale < AnswerOption
|
25
|
+
end
|
26
|
+
|
27
|
+
class CompositeOption < AnswerOption
|
28
|
+
has_attr 'condition', Boolean
|
29
|
+
end
|
30
|
+
|
31
|
+
class Image < AnswerOption
|
32
|
+
has_attr 'source', String
|
33
|
+
has_attr 'width', Integer
|
34
|
+
has_attr 'height', Integer
|
35
|
+
end
|
36
|
+
|
37
|
+
class ValidationRule < RGen::MetamodelBuilder::MMBase
|
38
|
+
has_attr 'regex', String
|
39
|
+
end
|
40
|
+
|
41
|
+
class Answer < RGen::MetamodelBuilder::MMBase
|
6
42
|
has_attr 'title', String
|
7
|
-
has_attr '
|
43
|
+
has_attr 'isMandatory', Boolean
|
44
|
+
contains_many 'options', AnswerOption, 'answer'
|
45
|
+
contains_many 'rules', ValidationRule, 'answer'
|
46
|
+
end
|
47
|
+
|
48
|
+
class Row < RGen::MetamodelBuilder::MMBase
|
49
|
+
end
|
50
|
+
|
51
|
+
class Column < RGen::MetamodelBuilder::MMBase
|
52
|
+
end
|
53
|
+
|
54
|
+
class Table < Answer
|
55
|
+
contains_many 'rows', Row, 'table'
|
56
|
+
contains_many 'columns', Column, 'table'
|
57
|
+
end
|
58
|
+
|
59
|
+
class MultipleChoiceAnswer < Answer
|
60
|
+
end
|
61
|
+
|
62
|
+
class SingleChoiceAnswer < Answer
|
63
|
+
end
|
64
|
+
|
65
|
+
class Question < RGen::MetamodelBuilder::MMBase
|
66
|
+
has_attr 'name', String
|
67
|
+
has_attr 'title', String
|
68
|
+
contains_many 'answers', Answer, 'question'
|
8
69
|
end
|
9
70
|
|
10
71
|
class Page < RGen::MetamodelBuilder::MMBase
|
11
72
|
has_attr 'name', String
|
12
73
|
has_attr 'number', Integer
|
74
|
+
contains_many 'questions', Question, 'page'
|
13
75
|
end
|
14
|
-
Survey.contains_many 'page', Page, 'page'
|
15
76
|
|
16
|
-
class
|
77
|
+
class Survey < RGen::MetamodelBuilder::MMBase
|
17
78
|
has_attr 'name', String
|
18
|
-
has_attr '
|
79
|
+
has_attr 'title', String
|
80
|
+
has_attr 'author', String
|
81
|
+
contains_many 'pages', Page, 'survey'
|
19
82
|
end
|
20
|
-
Page.contains_many 'field', Field, 'field'
|
21
83
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SurveyMetamodel
|
2
|
+
module Answer::ClassModule
|
3
|
+
def method1
|
4
|
+
end
|
5
|
+
|
6
|
+
def method2
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Color
|
11
|
+
BLUE = 1
|
12
|
+
RED = 2
|
13
|
+
YELLOW = 3
|
14
|
+
WHITE = 4
|
15
|
+
BLACK = 5
|
16
|
+
end
|
17
|
+
|
18
|
+
class StylingOption
|
19
|
+
BOLD = 1
|
20
|
+
ITALIC = 2
|
21
|
+
UNDERLINE = 3
|
22
|
+
end
|
23
|
+
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
2
|
-
|
3
|
-
require 'metamodels/survey_metamodel'
|
4
|
-
require 'rgen/template_language'
|
5
|
-
require 'rgen/array_extensions'
|
6
|
-
|
7
|
-
class SurveyGenerator < Rails::Generators::Base
|
8
|
-
source_root File.expand_path('/templates', __FILE__)
|
9
|
-
|
10
|
-
def generate_survey
|
11
|
-
require Rails.root.to_s + '/gen/models/survey_model'
|
12
|
-
tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new(SurveyMetamodel, Rails.root.to_s)
|
13
|
-
tc.load(File.dirname(__FILE__) + '/templates')
|
14
|
-
tc.expand('main::root', for: MODEL.first)
|
15
|
-
end
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
|
3
|
+
require 'metamodels/survey_metamodel'
|
4
|
+
require 'rgen/template_language'
|
5
|
+
require 'rgen/array_extensions'
|
6
|
+
|
7
|
+
class SurveyGenerator < Rails::Generators::Base
|
8
|
+
source_root File.expand_path('/templates', __FILE__)
|
9
|
+
|
10
|
+
def generate_survey
|
11
|
+
require Rails.root.to_s + '/gen/models/survey_model'
|
12
|
+
tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new(SurveyMetamodel, Rails.root.to_s)
|
13
|
+
tc.load(File.dirname(__FILE__) + '/templates')
|
14
|
+
tc.expand('main::root', for: MODEL.first)
|
15
|
+
end
|
16
16
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% define 'root' do %>
|
2
|
+
<% expand 'models/survey_model::survey_model' %>
|
3
|
+
<% expand 'controllers/survey_controller::survey_controller' %>
|
4
|
+
<% expand 'helpers/application_helper::application_helper' %>
|
5
|
+
<% expand 'views/views::root' %>
|
6
|
+
|
7
|
+
<% expand 'assets/stylesheets/stylesheet::stylesheet' %>
|
8
|
+
<% expand 'assets/javascripts/application::application' %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% define 'application' 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
|
+
<% end %>
|
20
|
+
<% end %>
|
@@ -0,0 +1,395 @@
|
|
1
|
+
<% define 'stylesheet', for: Survey do %>
|
2
|
+
<% file "app/assets/stylesheets/custom.css.scss" do %>
|
3
|
+
@import "bootstrap";
|
4
|
+
|
5
|
+
<%nl%>
|
6
|
+
/* mixins, variables, etc. */
|
7
|
+
|
8
|
+
<%nl%>
|
9
|
+
$lightgray: #999;
|
10
|
+
$grayMediumLight: #eaeaea;
|
11
|
+
$gray: #555;
|
12
|
+
$grayDarker: #222;
|
13
|
+
$grayLighter: #999;
|
14
|
+
|
15
|
+
<%nl%>
|
16
|
+
@mixin box_sizing {<%iinc%>
|
17
|
+
-moz-box-sizing: border-box;
|
18
|
+
-webkit-box-sizing: border-box;
|
19
|
+
box-sizing: border-box;
|
20
|
+
<%idec%>}
|
21
|
+
|
22
|
+
<%nl%>
|
23
|
+
/* universal */
|
24
|
+
|
25
|
+
<%nl%>
|
26
|
+
html {<%iinc%>
|
27
|
+
overflow-y: scroll;
|
28
|
+
<%idec%>}
|
29
|
+
|
30
|
+
<%nl%>
|
31
|
+
body {<%iinc%>
|
32
|
+
padding-top: 60px;
|
33
|
+
<%idec%>}
|
34
|
+
|
35
|
+
<%nl%>
|
36
|
+
section {<%iinc%>
|
37
|
+
overflow: auto;
|
38
|
+
<%idec%>}
|
39
|
+
|
40
|
+
<%nl%>
|
41
|
+
textarea {<%iinc%>
|
42
|
+
resize: vertical;
|
43
|
+
<%idec%>}
|
44
|
+
|
45
|
+
<%nl%>
|
46
|
+
.center {<%iinc%>
|
47
|
+
text-align: center;
|
48
|
+
<%idec%>}
|
49
|
+
|
50
|
+
<%nl%>
|
51
|
+
.center h1 {<%iinc%>
|
52
|
+
margin-bottom: 10px;
|
53
|
+
<%idec%>}
|
54
|
+
|
55
|
+
<%nl%>
|
56
|
+
/* (original CSS) */
|
57
|
+
/*
|
58
|
+
.center {<%iinc%>
|
59
|
+
text-align: center;
|
60
|
+
h1 {<%iinc%>
|
61
|
+
margin-bottom: 10px;
|
62
|
+
<%idec%>}
|
63
|
+
<%idec%>}
|
64
|
+
*/
|
65
|
+
|
66
|
+
<%nl%>
|
67
|
+
/* typography */
|
68
|
+
|
69
|
+
<%nl%>
|
70
|
+
h1, h2, h3, h4, h5, h6 {<%iinc%>
|
71
|
+
line-height: 1;
|
72
|
+
<%idec%>}
|
73
|
+
|
74
|
+
<%nl%>
|
75
|
+
h1 {<%iinc%>
|
76
|
+
font-size: 3em;
|
77
|
+
letter-spacing: -2px;
|
78
|
+
margin-bottom: 30px;
|
79
|
+
text-align: center;
|
80
|
+
<%idec%>}
|
81
|
+
|
82
|
+
<%nl%>
|
83
|
+
h2 {<%iinc%>
|
84
|
+
font-size: 1.7em;
|
85
|
+
letter-spacing: -1px;
|
86
|
+
margin-bottom: 30px;
|
87
|
+
text-align: center;
|
88
|
+
font-weight: normal;
|
89
|
+
color: $lightgray;
|
90
|
+
<%idec%>}
|
91
|
+
|
92
|
+
<%nl%>
|
93
|
+
/* header */
|
94
|
+
|
95
|
+
<%nl%>
|
96
|
+
#logo {<%iinc%>
|
97
|
+
float: left;
|
98
|
+
margin-right: 10px;
|
99
|
+
font-size: 1,7em;
|
100
|
+
color: #fff;
|
101
|
+
text-transform: uppercase;
|
102
|
+
letter-spacing: -1px;
|
103
|
+
padding-top: 9px;
|
104
|
+
font-weight: bold;
|
105
|
+
line-height: 1;
|
106
|
+
<%idec%>}
|
107
|
+
|
108
|
+
<%nl%>
|
109
|
+
#logo:hover {<%iinc%>
|
110
|
+
color: #fff;
|
111
|
+
text-decoration: none;
|
112
|
+
<%idec%>}
|
113
|
+
|
114
|
+
<%nl%>
|
115
|
+
/* (original CSS) */
|
116
|
+
/*
|
117
|
+
#logo {<%iinc%>
|
118
|
+
float: left;
|
119
|
+
margin-right: 10px;
|
120
|
+
font-size: 1.7em;
|
121
|
+
color: #fff;
|
122
|
+
text-transform: uppercase;
|
123
|
+
letter-spacing: -1px;
|
124
|
+
padding-top: 9px;
|
125
|
+
font-weight: bold;
|
126
|
+
line-height: 1;
|
127
|
+
&:hover {<%iinc%>
|
128
|
+
color: #fff;
|
129
|
+
text-decoration: none;
|
130
|
+
<%idec%>}
|
131
|
+
<%idec%>}
|
132
|
+
*/
|
133
|
+
|
134
|
+
<%nl%>
|
135
|
+
/* footer */
|
136
|
+
|
137
|
+
<%nl%>
|
138
|
+
footer {<%iinc%>
|
139
|
+
margin-top: 48px;
|
140
|
+
padding-top: 5px;
|
141
|
+
border-top: 1px solid $grayMediumLight;
|
142
|
+
color: $lightgray;
|
143
|
+
<%idec%>}
|
144
|
+
|
145
|
+
<%nl%>
|
146
|
+
footer a {<%iinc%>
|
147
|
+
color: $gray;
|
148
|
+
<%idec%>}
|
149
|
+
|
150
|
+
<%nl%>
|
151
|
+
footer a:hover {<%iinc%>
|
152
|
+
color: $grayDarker;
|
153
|
+
<%idec%>}
|
154
|
+
|
155
|
+
<%nl%>
|
156
|
+
footer small {<%iinc%>
|
157
|
+
float: left;
|
158
|
+
<%idec%>}
|
159
|
+
|
160
|
+
<%nl%>
|
161
|
+
footer ul {<%iinc%>
|
162
|
+
float: right;
|
163
|
+
list-style: none;
|
164
|
+
<%idec%>}
|
165
|
+
|
166
|
+
<%nl%>
|
167
|
+
footer ul li {<%iinc%>
|
168
|
+
float: left;
|
169
|
+
margin-left: 10px;
|
170
|
+
<%idec%>}
|
171
|
+
|
172
|
+
<%nl%>
|
173
|
+
/* (original CSS) */
|
174
|
+
/*
|
175
|
+
footer {<%iinc%>
|
176
|
+
margin-top: 48px;
|
177
|
+
padding-top: 5px;
|
178
|
+
border-top: 1px solid #eaeaea;
|
179
|
+
color: #999;
|
180
|
+
a {<%iinc%>
|
181
|
+
color: #555;
|
182
|
+
&:hover {<%iinc%>
|
183
|
+
color: #222;
|
184
|
+
<%idec%>}
|
185
|
+
<%idec%>}
|
186
|
+
|
187
|
+
<%nl%>
|
188
|
+
small {<%iinc%>
|
189
|
+
float: left;
|
190
|
+
<%idec%>}
|
191
|
+
|
192
|
+
<%nl%>
|
193
|
+
ul {<%iinc%>
|
194
|
+
float: right;
|
195
|
+
list-style: none;
|
196
|
+
|
197
|
+
<%nl%>
|
198
|
+
li {<%iinc%>
|
199
|
+
float: left;
|
200
|
+
margin-left: 10px;
|
201
|
+
<%idec%>}
|
202
|
+
<%idec%>}
|
203
|
+
<%idec%>}
|
204
|
+
*/
|
205
|
+
|
206
|
+
<%nl%>
|
207
|
+
/* miscellaneous */
|
208
|
+
|
209
|
+
<%nl%>
|
210
|
+
.debug_dump {<%iinc%>
|
211
|
+
clear: both;
|
212
|
+
float: left;
|
213
|
+
width: 100%;
|
214
|
+
margin-top: 45px;
|
215
|
+
@include box-sizing;
|
216
|
+
<%idec%>}
|
217
|
+
|
218
|
+
<%nl%>
|
219
|
+
/* sidebar */
|
220
|
+
|
221
|
+
<%nl%>
|
222
|
+
aside {<%iinc%>
|
223
|
+
section {<%iinc%>
|
224
|
+
padding: 10px 0;
|
225
|
+
border-top: 1px solid $grayLighter;
|
226
|
+
&:first-child {<%iinc%>
|
227
|
+
border: 0;
|
228
|
+
padding-top: 0;
|
229
|
+
<%idec%>}
|
230
|
+
span {<%iinc%>
|
231
|
+
display: block;
|
232
|
+
margin-bottom: 3px;
|
233
|
+
line-height: 1;
|
234
|
+
<%idec%>}
|
235
|
+
h1 {<%iinc%>
|
236
|
+
font-size: 1.4em;
|
237
|
+
text-align: left;
|
238
|
+
letter-spacing: -1px;
|
239
|
+
margin-bottom: 3px;
|
240
|
+
margin-top: 0px;
|
241
|
+
<%idec%>}
|
242
|
+
<%idec%>}
|
243
|
+
<%idec%>}
|
244
|
+
|
245
|
+
<%nl%>
|
246
|
+
.gravatar {<%iinc%>
|
247
|
+
float: left;
|
248
|
+
margin-right: 10px;
|
249
|
+
<%idec%>}
|
250
|
+
|
251
|
+
<%nl%>
|
252
|
+
.stats {<%iinc%>
|
253
|
+
overflow: auto;
|
254
|
+
a {<%iinc%>
|
255
|
+
float: left;
|
256
|
+
padding: 0 10px;
|
257
|
+
border-left: 1px solid $grayLighter;
|
258
|
+
color: gray;
|
259
|
+
&:first-child {<%iinc%>
|
260
|
+
padding-left: 0;
|
261
|
+
border: 0;
|
262
|
+
<%idec%>}
|
263
|
+
&:hover {<%iinc%>
|
264
|
+
text-decoration: none;
|
265
|
+
color: $blue;
|
266
|
+
<%idec%>}
|
267
|
+
<%idec%>}
|
268
|
+
strong {<%iinc%>
|
269
|
+
display: block;
|
270
|
+
<%idec%>}
|
271
|
+
<%idec%>}
|
272
|
+
|
273
|
+
<%nl%>
|
274
|
+
.user_avatars {<%iinc%>
|
275
|
+
overflow: auto;
|
276
|
+
margin-top: 10px;
|
277
|
+
.gravatar {<%iinc%>
|
278
|
+
margin: 1px 1px;
|
279
|
+
<%idec%>}
|
280
|
+
<%idec%>}
|
281
|
+
|
282
|
+
<%nl%>
|
283
|
+
/* forms */
|
284
|
+
|
285
|
+
<%nl%>
|
286
|
+
input, textarea, select, .uneditable-input {<%iinc%>
|
287
|
+
border: 1px solid #bbb;
|
288
|
+
width: 100%;
|
289
|
+
padding: 10px;
|
290
|
+
margin-bottom: 15px;
|
291
|
+
@include box_sizing;
|
292
|
+
<%idec%>}
|
293
|
+
|
294
|
+
<%nl%>
|
295
|
+
input {<%iinc%>
|
296
|
+
height: auto !important;
|
297
|
+
<%idec%>}
|
298
|
+
|
299
|
+
<%nl%>
|
300
|
+
#error_explanation {<%iinc%>
|
301
|
+
color: #f00;
|
302
|
+
ul {<%iinc%>
|
303
|
+
list-style: none;
|
304
|
+
margin: 0 0 18px 0;
|
305
|
+
<%idec%>}
|
306
|
+
<%idec%>}
|
307
|
+
|
308
|
+
<%nl%>
|
309
|
+
.field_with_errors {<%iinc%>
|
310
|
+
@extend .control-group;
|
311
|
+
@extend .error;
|
312
|
+
<%idec%>}
|
313
|
+
|
314
|
+
<%nl%>
|
315
|
+
/* users index */
|
316
|
+
|
317
|
+
<%nl%>
|
318
|
+
.users {<%iinc%>
|
319
|
+
list-style: none;
|
320
|
+
margin: 0;
|
321
|
+
li {<%iinc%>
|
322
|
+
overflow: auto;
|
323
|
+
padding: 10px 0;
|
324
|
+
border-top: 1px solid $grayLighter;
|
325
|
+
&:last-child {<%iinc%>
|
326
|
+
border-bottom: 1px solid $grayLighter;
|
327
|
+
<%idec%>}
|
328
|
+
<%idec%>}
|
329
|
+
<%idec%>}
|
330
|
+
|
331
|
+
<%nl%>
|
332
|
+
/* microposts */
|
333
|
+
|
334
|
+
<%nl%>
|
335
|
+
.microposts {<%iinc%>
|
336
|
+
list-style: none;
|
337
|
+
margin: 10px 0 0 0;
|
338
|
+
li {<%iinc%>
|
339
|
+
padding: 10px 0;
|
340
|
+
border-top: 1px solid #e8e8e8;
|
341
|
+
<%idec%>}
|
342
|
+
<%idec%>}
|
343
|
+
|
344
|
+
<%nl%>
|
345
|
+
.content {<%iinc%>
|
346
|
+
display: block;
|
347
|
+
<%idec%>}
|
348
|
+
|
349
|
+
<%nl%>
|
350
|
+
.timestamp {<%iinc%>
|
351
|
+
color: $grayLight;
|
352
|
+
<%idec%>}
|
353
|
+
|
354
|
+
<%nl%>
|
355
|
+
.gravatar {<%iinc%>
|
356
|
+
float: left;
|
357
|
+
margin-right: 10px;
|
358
|
+
<%idec%>}
|
359
|
+
|
360
|
+
<%nl%>
|
361
|
+
aside {<%iinc%>
|
362
|
+
textarea {<%iinc%>
|
363
|
+
height: 100px;
|
364
|
+
margin-bottom: 5px;
|
365
|
+
<%idec%>}
|
366
|
+
<%idec%>}
|
367
|
+
|
368
|
+
<%nl%>
|
369
|
+
/* custom */
|
370
|
+
|
371
|
+
<% expand 'survey_page', foreach: pages %>
|
372
|
+
<% end %>
|
373
|
+
<% end %>
|
374
|
+
|
375
|
+
<% define 'survey_page', for: Page do %>
|
376
|
+
<% expand 'survey_question', foreach: questions %>
|
377
|
+
<% end %>
|
378
|
+
|
379
|
+
<% define 'survey_question', for: Question do %>
|
380
|
+
<% expand 'survey_answer', foreach: answers %>
|
381
|
+
<% end %>
|
382
|
+
|
383
|
+
<% define 'survey_answer', for: Answer do %>
|
384
|
+
<% expand 'survey_answer_option', foreach: options %>
|
385
|
+
<% end %>
|
386
|
+
|
387
|
+
<% define 'survey_answer_option', for: AnswerOption do %>
|
388
|
+
<% if name != nil && foreground != nil && background != nil %>
|
389
|
+
<%nl%>
|
390
|
+
.<%= name %> {<%iinc%>
|
391
|
+
<% if foreground != nil %>color: <%= foreground %>;<% end %>
|
392
|
+
<% if background != nil %>background-color: <%= background %>;<% end %>
|
393
|
+
<%idec%>}
|
394
|
+
<% end %>
|
395
|
+
<% end %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<% define 'survey_controller', for: Survey do %>
|
2
|
+
<% file "app/controllers/" + name.pluralize.downcase + "_controller.rb" do %>
|
3
|
+
class <%= name.pluralize %>Controller < ApplicationController
|
4
|
+
<%iinc%>def index
|
5
|
+
end
|
6
|
+
<%idec%>end
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% file "app/controllers/static_pages_controller.rb" do %>
|
10
|
+
class StaticPagesController < ApplicationController<%iinc%>
|
11
|
+
def home<%iinc%>
|
12
|
+
<%idec%>end
|
13
|
+
|
14
|
+
<%nl%>
|
15
|
+
def help<%iinc%>
|
16
|
+
<%idec%>end
|
17
|
+
|
18
|
+
<%nl%>
|
19
|
+
def about<%iinc%>
|
20
|
+
<%idec%>end
|
21
|
+
|
22
|
+
<%nl%>
|
23
|
+
def contact<%iinc%>
|
24
|
+
<%idec%>end
|
25
|
+
<%idec%>end
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% define 'application_helper' do %>
|
2
|
+
<% file "app/helpers/application_helper.rb" do %>
|
3
|
+
module ApplicationHelper<%iinc%>
|
4
|
+
def full_title(page_title)<%iinc%>
|
5
|
+
base_title = "Ruby on Rails Tutorial Sample App"
|
6
|
+
if page_title.empty?<%iinc%>
|
7
|
+
base_title
|
8
|
+
<%idec%>else<%iinc%>
|
9
|
+
"#{base_title} | #{page_title}"
|
10
|
+
<%idec%>end
|
11
|
+
<%idec%>end
|
12
|
+
<%idec%>end
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<% define 'survey_model', for: Survey do %>
|
2
|
+
<% file "app/models/" + name.downcase + ".rb" do %>
|
3
|
+
class <%= name %> < ActiveRecord::Base
|
4
|
+
<%iinc%>attr_accessible :<%= title %>, :<%= author %><%nl%>
|
5
|
+
<% expand 'survey_page', foreach: pages %>
|
6
|
+
<%idec%>end
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% file "app/models/survey.rb" do %>
|
10
|
+
class Survey < ActiveRecord::Base<%iinc%>
|
11
|
+
attr_accessible :author, :name, :title, :user_id
|
12
|
+
|
13
|
+
<%nl%>
|
14
|
+
has_many :pages, dependent: :destroy
|
15
|
+
<%idec%>end
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<% file "app/models/page.rb" do %>
|
19
|
+
class Page < ActiveRecord::Base<%iinc%>
|
20
|
+
attr_accessible :number, :survey_id, :title
|
21
|
+
|
22
|
+
<%nl%>
|
23
|
+
belongs_to :survey
|
24
|
+
has_many :questions, dependent: :destroy
|
25
|
+
<%idec%>end
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
<% file "app/models/question.rb" do %>
|
29
|
+
class Question < ActiveRecord::Base<%iinc%>
|
30
|
+
attr_accessible :content, :name, :page_id
|
31
|
+
|
32
|
+
<%nl%>
|
33
|
+
belongs_to :page
|
34
|
+
<%idec%>end
|
35
|
+
<% end %>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<% define 'survey_page', for: Page do %>
|
39
|
+
attr_accessible :<%= name %>
|
40
|
+
<% expand 'survey_question', foreach: questions %>
|
41
|
+
<% end %>
|
42
|
+
|
43
|
+
<% define 'survey_question', for: Question do %>
|
44
|
+
attr_accessible :<%= name %>, :<%= title %>
|
45
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<% define 'application' do %>
|
2
|
+
<% file "app/views/layouts/application.html.erb" do %>
|
3
|
+
<!DOCTYPE html>
|
4
|
+
<html><%iinc%>
|
5
|
+
<head><%iinc%>
|
6
|
+
<title><%%= full_title(yield(:title)) %></title>
|
7
|
+
<%%= stylesheet_link_tag "application", media: "all" %>
|
8
|
+
<%%= javascript_include_tag "application" %>
|
9
|
+
<%%= csrf_meta_tags %>
|
10
|
+
<%%= render 'layouts/shim' %>
|
11
|
+
<%idec%></head>
|
12
|
+
<body><%iinc%>
|
13
|
+
<%%= render 'layouts/header' %>
|
14
|
+
<div class="container"><%iinc%>
|
15
|
+
<%% flash.each do |key, value| %><%iinc%>
|
16
|
+
<div class="alert alert-<%%= key %>"><%%= value %></div>
|
17
|
+
<%idec%><%% end %>
|
18
|
+
<%%= yield %>
|
19
|
+
<%%= render 'layouts/footer' %>
|
20
|
+
<%%= debug(params) if Rails.env.development? %>
|
21
|
+
<%idec%></div>
|
22
|
+
<%idec%></body>
|
23
|
+
<%idec%></html>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% define 'footer' do %>
|
2
|
+
<% file "app/views/layouts/_footer.html.erb" do %>
|
3
|
+
<footer class="footer">
|
4
|
+
<small><%iinc%>
|
5
|
+
<a href="http://railstutorial.org/">Rails Tutorial</a>
|
6
|
+
by Michael Hartl
|
7
|
+
<%idec%></small>
|
8
|
+
<nav><%iinc%>
|
9
|
+
<ul><%iinc%>
|
10
|
+
<li><%%= link_to "About", about_path %></li>
|
11
|
+
<li><%%= link_to "Contact", contact_path %></li>
|
12
|
+
<li><a href="http://news.railstutorial.org/">News</a></li>
|
13
|
+
<%idec%></ul>
|
14
|
+
<%idec%></nav>
|
15
|
+
<%idec%></footer>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<% define 'header', for: Survey do %>
|
2
|
+
<% file "app/views/layouts/_header.html.erb" do %>
|
3
|
+
<header class="navbar navbar-fixed-top navbar-inverse"><%iinc%>
|
4
|
+
<div class="navbar-inner"><%iinc%>
|
5
|
+
<div class="container"><%iinc%>
|
6
|
+
<%%= link_to "sample app", root_path, id: "logo" %>
|
7
|
+
<nav><%iinc%>
|
8
|
+
<ul class="nav pull-right"><%iinc%>
|
9
|
+
<li><%%= link_to "Home", root_path %></li>
|
10
|
+
<li><%%= link_to "Help", help_path %></li>
|
11
|
+
<!--<li><%%= link_to "Users", '#' %></li>-->
|
12
|
+
|
13
|
+
<%nl%>
|
14
|
+
<li id="fat-menu" class="dropdown"><%iinc%>
|
15
|
+
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%iinc%>
|
16
|
+
Surveys <b class="caret"></b>
|
17
|
+
<%idec%></a>
|
18
|
+
<ul class="dropdown-menu"><%iinc%>
|
19
|
+
<li><%%= link_to "<%= name.pluralize.capitalize %>", <%= name.pluralize.downcase %>_path %></li>
|
20
|
+
<%idec%></ul>
|
21
|
+
<%idec%></li>
|
22
|
+
|
23
|
+
<%nl%>
|
24
|
+
<!--<li id="fat-menu" class="dropdown"><%iinc%>
|
25
|
+
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%iinc%>
|
26
|
+
Account <b class="caret"></b>
|
27
|
+
<%idec%></a>
|
28
|
+
<ul class="dropdown-menu"><%iinc%>
|
29
|
+
<li><%%= link_to "Profile", '#' %></li>
|
30
|
+
<li><%%= link_to "Settings", '#' %></li>
|
31
|
+
<li class="divider"></li>
|
32
|
+
<li><%%= link_to "Sign out", '#' %></li>
|
33
|
+
<%idec%></ul>
|
34
|
+
<%idec%></li>-->
|
35
|
+
<%idec%></ul>
|
36
|
+
<%idec%></nav>
|
37
|
+
<%idec%></div>
|
38
|
+
<%idec%></div>
|
39
|
+
<%idec%></header>
|
40
|
+
<% end %>
|
41
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% define 'error_messages', for: Survey do %>
|
2
|
+
<% file "app/views/shared/_error_messages.html.erb" do %>
|
3
|
+
<%% if object.errors.any? %><%iinc%>
|
4
|
+
<div id="error_explanation"><%iinc%>
|
5
|
+
<div class="alert alert-error"><%iinc%>
|
6
|
+
The survey contains <%%= pluralize(object.errors.count, "error") %>.
|
7
|
+
<%idec%></div>
|
8
|
+
<ul><%iinc%>
|
9
|
+
<%% object.errors.full_messages.each do |error| %><%iinc%>
|
10
|
+
<li>* <%%= error %></li>
|
11
|
+
<%idec%><%% end %>
|
12
|
+
<%idec%></ul>
|
13
|
+
<%idec%></div>
|
14
|
+
<%idec%><%% end %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<% define 'about' do %>
|
2
|
+
<% file "app/views/static_pages/about.html.erb" do %>
|
3
|
+
<%% provide(:title, 'About Us') %>
|
4
|
+
<h1>About Us</h1>
|
5
|
+
<p><%iinc%>
|
6
|
+
The <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
|
7
|
+
is a project to make a book and screencasts to teach web development
|
8
|
+
with <a href="http://rubyonrails.org/">Ruby on Rails</a>. This
|
9
|
+
is the sample application for the tutorial.
|
10
|
+
<%idec%></p>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% define 'contact' do %>
|
2
|
+
<% file "app/views/static_pages/contact.html.erb" do %>
|
3
|
+
<%% provide(:title, 'Contact') %>
|
4
|
+
<h1>Contact</h1>
|
5
|
+
<p><%iinc%>
|
6
|
+
Contact Ruby on Rails Tutorial about the sample app at the
|
7
|
+
<a href="http://railstutorial.org/contact">contact page</a>.
|
8
|
+
<%idec%></p>
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<% define 'help' do %>
|
2
|
+
<% file "app/views/static_pages/help.html.erb" do %>
|
3
|
+
<%% provide(:title, 'Help') %>
|
4
|
+
<h1>Help</h1>
|
5
|
+
<p><%iinc%>
|
6
|
+
Get help on the Ruby on Rails Tutorial at the
|
7
|
+
<a href="http://railstutorial.org/help">Rails Tutorial help page</a>.
|
8
|
+
To get help on this sample app, see the
|
9
|
+
<a href="http://railstutorial.org/book">Rails Tutorial book</a>.
|
10
|
+
<%idec%></p>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% define 'home' do %>
|
2
|
+
<% file "app/views/static_pages/home.html.erb" do %>
|
3
|
+
<div class="center hero-unit"><%iinc%>
|
4
|
+
<h1>Welcome to the Sample App</h1>
|
5
|
+
<h2><%iinc%>
|
6
|
+
This is the home page for the
|
7
|
+
<a href="http://railstutorial.org/">
|
8
|
+
Ruby on Rails Tutorial</a> sample application.
|
9
|
+
<%idec%></h2>
|
10
|
+
|
11
|
+
<%nl%>
|
12
|
+
<%%= link_to "Sign up now!", '#', class: "btn btn-large btn-primary" %>
|
13
|
+
<%idec%></div>
|
14
|
+
|
15
|
+
<%nl%>
|
16
|
+
<%%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<% define 'survey_index_view', for: Survey do %>
|
2
|
+
<% file "app/views/" + name.pluralize.downcase + "/index.html.erb" do %>
|
3
|
+
<%% provide(:title, "<%= title.capitalize %>") %>
|
4
|
+
<h1><%= title.capitalize %></h1>
|
5
|
+
|
6
|
+
<%nl%>
|
7
|
+
<div class="row"><%iinc%>
|
8
|
+
<div class="span6 offset3"><%iinc%>
|
9
|
+
<%%= form_tag <%= name.pluralize.downcase %>_path do %><%iinc%>
|
10
|
+
<%%# render 'shared/error_messages', object: f.object %>
|
11
|
+
<% expand 'survey_page', foreach: pages %>
|
12
|
+
<%idec%><%% end %>
|
13
|
+
|
14
|
+
<%nl%>
|
15
|
+
<div class="actions"><%%= submit_tag "Submit", class: "btn btn-large btn-primary" %></div>
|
16
|
+
<%idec%></div>
|
17
|
+
<%idec%></div>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% define 'survey_page', for: Page do %>
|
22
|
+
<% expand 'survey_question', foreach: questions %>
|
23
|
+
<% end %>
|
24
|
+
|
25
|
+
<% define 'survey_question', for: Question do %>
|
26
|
+
<% expand 'survey_answer', foreach: answers %>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% define 'survey_answer', for: Answer do %>
|
30
|
+
<% expand 'survey_answer_option', foreach: options %>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
<% define 'survey_answer_option', for: AnswerOption do %>
|
34
|
+
<div class="field"><%iinc%>
|
35
|
+
<%%= label_tag :name, "<%= name %>" %>
|
36
|
+
<%%= text_field_tag :name %>
|
37
|
+
<%idec%></div>
|
38
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% define 'root' do %>
|
2
|
+
<% expand 'layouts/application::application' %>
|
3
|
+
<% expand 'layouts/header::header' %>
|
4
|
+
<% expand 'layouts/footer::footer' %>
|
5
|
+
<% expand 'layouts/shim::shim' %>
|
6
|
+
|
7
|
+
<% expand 'shared/error_messages::error_messages' %>
|
8
|
+
|
9
|
+
<% expand 'static_pages/about::about' %>
|
10
|
+
<% expand 'static_pages/contact::contact' %>
|
11
|
+
<% expand 'static_pages/help::help' %>
|
12
|
+
<% expand 'static_pages/home::home' %>
|
13
|
+
|
14
|
+
<% expand 'survey/survey_index_view::survey_index_view' %>
|
15
|
+
<% expand 'survey/survey_form_view::survey_form_view' %>
|
16
|
+
<% end %>
|
@@ -0,0 +1,76 @@
|
|
1
|
+
<% define 'routes', for: Survey do %>
|
2
|
+
<% file "config/routes.rb" do %>
|
3
|
+
Generator::Application.routes.draw do<%iinc%>
|
4
|
+
resources :<%= name.pluralize.downcase %>
|
5
|
+
|
6
|
+
<%nl%>
|
7
|
+
root to: 'static_pages#home'
|
8
|
+
|
9
|
+
<%nl%>
|
10
|
+
match '/help', to: 'static_pages#help'
|
11
|
+
match '/about', to: 'static_pages#about'
|
12
|
+
match '/contact', to: 'static_pages#contact'
|
13
|
+
|
14
|
+
<%nl%>
|
15
|
+
match '/<%= name.pluralize.downcase %>', to: '<%= name.pluralize.downcase %>#index'
|
16
|
+
|
17
|
+
<%nl%>
|
18
|
+
# The priority is based upon order of creation:
|
19
|
+
# first created -> highest priority.
|
20
|
+
|
21
|
+
# Sample of regular route:
|
22
|
+
# match 'products/:id' => 'catalog#view'
|
23
|
+
# Keep in mind you can assign values other than :controller and :action
|
24
|
+
|
25
|
+
# Sample of named route:
|
26
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
27
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
28
|
+
|
29
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
30
|
+
# resources :products
|
31
|
+
|
32
|
+
# Sample resource route with options:
|
33
|
+
# resources :products do
|
34
|
+
# member do
|
35
|
+
# get 'short'
|
36
|
+
# post 'toggle'
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# collection do
|
40
|
+
# get 'sold'
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
|
44
|
+
# Sample resource route with sub-resources:
|
45
|
+
# resources :products do
|
46
|
+
# resources :comments, :sales
|
47
|
+
# resource :seller
|
48
|
+
# end
|
49
|
+
|
50
|
+
# Sample resource route with more complex sub-resources
|
51
|
+
# resources :products do
|
52
|
+
# resources :comments
|
53
|
+
# resources :sales do
|
54
|
+
# get 'recent', :on => :collection
|
55
|
+
# end
|
56
|
+
# end
|
57
|
+
|
58
|
+
# Sample resource route within a namespace:
|
59
|
+
# namespace :admin do
|
60
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
61
|
+
# # (app/controllers/admin/products_controller.rb)
|
62
|
+
# resources :products
|
63
|
+
# end
|
64
|
+
|
65
|
+
# You can have the root of your site routed with "root"
|
66
|
+
# just remember to delete public/index.html.
|
67
|
+
# root :to => 'welcome#index'
|
68
|
+
|
69
|
+
# See how all your routes lay out with "rake routes"
|
70
|
+
|
71
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
72
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
73
|
+
# match ':controller(/:action(/:id))(.:format)'
|
74
|
+
<%idec%>end
|
75
|
+
<% end %>
|
76
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% define 'create_pages' do %>
|
2
|
+
<% file "db/migrate/create_pages.rb" do %>
|
3
|
+
class CreatePages < ActiveRecord::Migration<%iinc%>
|
4
|
+
def change<%iinc%>
|
5
|
+
create_table :pages do |t|<%iinc%>
|
6
|
+
t.string :title
|
7
|
+
t.integer :number
|
8
|
+
t.integer :survey_id
|
9
|
+
|
10
|
+
<%nl%>
|
11
|
+
t.timestamps
|
12
|
+
<%idec%>end
|
13
|
+
|
14
|
+
add_index :microposts, [:user_id, :created_at]
|
15
|
+
<%idec%>end
|
16
|
+
<%idec%>end
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% define 'create_questions' do %>
|
2
|
+
<% file "db/migrate/create_questions.rb" do %>
|
3
|
+
class CreateQuestions < ActiveRecord::Migration<%iinc%>
|
4
|
+
def change<%iinc%>
|
5
|
+
create_table :questions do |t|<%iinc%>
|
6
|
+
t.string :name
|
7
|
+
t.string :content
|
8
|
+
t.integer :page_id
|
9
|
+
|
10
|
+
<%nl%>
|
11
|
+
t.timestamps
|
12
|
+
<%idec%>end
|
13
|
+
<%idec%>end
|
14
|
+
<%idec%>end
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% define 'create_surveys' do %>
|
2
|
+
<% file "db/migrate/create_surveys.rb" do %>
|
3
|
+
class CreateSurveys < ActiveRecord::Migration<%iinc%>
|
4
|
+
def change<%iinc%>
|
5
|
+
create_table :surveys do |t|<%iinc%>
|
6
|
+
t.string :name
|
7
|
+
t.string :title
|
8
|
+
t.string :author
|
9
|
+
t.integer :user_id
|
10
|
+
|
11
|
+
<%nl%>
|
12
|
+
t.timestamps
|
13
|
+
<%idec%>end
|
14
|
+
<%idec%>end
|
15
|
+
<%idec%>end
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<% define 'create_users' do %>
|
2
|
+
<% file "db/migrate/create_users.rb" do %>
|
3
|
+
class CreateUsers < ActiveRecord::Migration<%iinc%>
|
4
|
+
def change<%iinc%>
|
5
|
+
create_table :users do |t|<%iinc%>
|
6
|
+
t.string :name
|
7
|
+
t.string :email
|
8
|
+
t.string :remember_token
|
9
|
+
t.string :password_digest
|
10
|
+
t.boolean :admin, default: false
|
11
|
+
|
12
|
+
<%nl%>
|
13
|
+
t.timestamps
|
14
|
+
<%idec%>end
|
15
|
+
|
16
|
+
<%nl%>
|
17
|
+
add_index :users, :remember_token
|
18
|
+
add_index :users, :email, unique: true
|
19
|
+
<%idec%>end
|
20
|
+
<%idec%>end
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% define 'root', for: Survey do %>
|
2
|
-
<% expand '
|
3
|
-
<% expand '
|
4
|
-
<% expand '
|
2
|
+
<% expand 'app/app::root' %>
|
3
|
+
<% expand 'config/config::root' %>
|
4
|
+
<% expand 'db/db::root' %>
|
5
5
|
<% end %>
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: survey_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Dkemp04
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-12 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: A generator for surveys based on model-driven development with RGen.
|
14
15
|
email: dkemp04@gmail.com
|
@@ -17,35 +18,57 @@ extensions: []
|
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
19
20
|
- lib/generators/survey/metamodels/survey_metamodel.rb
|
21
|
+
- lib/generators/survey/metamodels/survey_metamodel_ext.rb
|
20
22
|
- lib/generators/survey/survey_generator.rb
|
21
|
-
- lib/generators/survey/templates/
|
23
|
+
- lib/generators/survey/templates/app/app.tpl
|
24
|
+
- lib/generators/survey/templates/app/assets/javascripts/application.tpl
|
25
|
+
- lib/generators/survey/templates/app/assets/stylesheets/stylesheet.tpl
|
26
|
+
- lib/generators/survey/templates/app/controllers/survey_controller.tpl
|
27
|
+
- lib/generators/survey/templates/app/helpers/application_helper.tpl
|
28
|
+
- lib/generators/survey/templates/app/models/survey_model.tpl
|
29
|
+
- lib/generators/survey/templates/app/views/layouts/application.tpl
|
30
|
+
- lib/generators/survey/templates/app/views/layouts/footer.tpl
|
31
|
+
- lib/generators/survey/templates/app/views/layouts/header.tpl
|
32
|
+
- lib/generators/survey/templates/app/views/layouts/shim.tpl
|
33
|
+
- lib/generators/survey/templates/app/views/shared/error_messages.tpl
|
34
|
+
- lib/generators/survey/templates/app/views/static_pages/about.tpl
|
35
|
+
- lib/generators/survey/templates/app/views/static_pages/contact.tpl
|
36
|
+
- lib/generators/survey/templates/app/views/static_pages/help.tpl
|
37
|
+
- lib/generators/survey/templates/app/views/static_pages/home.tpl
|
38
|
+
- lib/generators/survey/templates/app/views/survey/survey_form_view.tpl
|
39
|
+
- lib/generators/survey/templates/app/views/survey/survey_index_view.tpl
|
40
|
+
- lib/generators/survey/templates/app/views/views.tpl
|
41
|
+
- lib/generators/survey/templates/config/config.tpl
|
42
|
+
- lib/generators/survey/templates/config/routes.tpl
|
43
|
+
- lib/generators/survey/templates/db/db.tpl
|
44
|
+
- lib/generators/survey/templates/db/migrate/create_pages.tpl
|
45
|
+
- lib/generators/survey/templates/db/migrate/create_questions.tpl
|
46
|
+
- lib/generators/survey/templates/db/migrate/create_surveys.tpl
|
47
|
+
- lib/generators/survey/templates/db/migrate/create_users.tpl
|
22
48
|
- lib/generators/survey/templates/main.tpl
|
23
|
-
- lib/generators/survey/templates/models/survey_model.tpl
|
24
|
-
- lib/generators/survey/templates/views/survey_form_view.tpl
|
25
|
-
- lib/generators/survey/templates/views/survey_index_view.tpl
|
26
|
-
- lib/generators/survey/templates/views/survey_view.tpl
|
27
49
|
- lib/generators/survey/USAGE
|
28
50
|
homepage: http://rubygems.org/gems/survey_generator
|
29
51
|
licenses: []
|
30
|
-
metadata: {}
|
31
52
|
post_install_message:
|
32
53
|
rdoc_options: []
|
33
54
|
require_paths:
|
34
55
|
- lib
|
35
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
36
58
|
requirements:
|
37
59
|
- - ! '>='
|
38
60
|
- !ruby/object:Gem::Version
|
39
61
|
version: '0'
|
40
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
41
64
|
requirements:
|
42
65
|
- - ! '>='
|
43
66
|
- !ruby/object:Gem::Version
|
44
67
|
version: '0'
|
45
68
|
requirements: []
|
46
69
|
rubyforge_project:
|
47
|
-
rubygems_version:
|
70
|
+
rubygems_version: 1.8.24
|
48
71
|
signing_key:
|
49
|
-
specification_version:
|
72
|
+
specification_version: 3
|
50
73
|
summary: A generator for surveys based on model-driven development with RGen.
|
51
74
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
MmEwMDBmODUzYjViNjI0YmI4NWFjMDlkZDAyOWE0MTQ3NGJmMGJjOA==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Y2I5ZjIyZDIzZjVjZDU3YzAxZWM4MDFkMWZjYTA1ZDQwZmU2ZjQ5OQ==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MmM2MTIzODhhMWFjM2ExMzdlZmNlOWZjZGNhZTliM2FlYTA4MzM1ODAwMDBh
|
10
|
-
OWYwNWQxNTU2NmVlZTIyYmRmYTVlNDA3YWQzMDMzZjg2NGRhY2QxNmVhMTg5
|
11
|
-
NzUzMjZkZGY1YzYxOTVkNzVmMGEwNzZhYjZlZjc1M2NmNWFhOWQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjNhMzU2ZmU0NzgzOWYzZTg3YzI3ZTFiOTliM2M1YTJhZjUyOTM5YjA3ZjEw
|
14
|
-
MWIyYjczOTFkZWNhYTY4OGQyNWQzOTI5MDFiYzgwMDAwNDk0YjY3ZDY3MDIz
|
15
|
-
YzUxNzc1YTY3ZGUyYjlkZTFhYTA3NDEwZTYyOWRkOTM5YjNkZTU=
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<% define 'survey_model', for: Survey do %>
|
2
|
-
<% file "app/models/" + name.downcase + ".rb" do %>
|
3
|
-
class <%= name %>Model < ActiveRecord::Base
|
4
|
-
<%iinc%>attr_accessible :<%= title %>, :<%= author %><%nl%>
|
5
|
-
<% expand 'survey_page', foreach: page %>
|
6
|
-
<%idec%>end
|
7
|
-
<% end %>
|
8
|
-
<% end %>
|
9
|
-
|
10
|
-
<% define 'survey_page', for: Page do %>
|
11
|
-
attr_accessible :<%= name %>
|
12
|
-
<% expand 'survey_field', foreach: field %>
|
13
|
-
<% end %>
|
14
|
-
|
15
|
-
<% define 'survey_field', for: Field do %>
|
16
|
-
attr_accessible :<%= name %>, :<%= content %>
|
17
|
-
<% end %>
|
@@ -1,30 +0,0 @@
|
|
1
|
-
<% define 'survey_index_view', for: Survey do %>
|
2
|
-
<% file "app/views/" + name.pluralize.downcase + "/index.html.erb" do %>
|
3
|
-
<h1>Listing posts</h1><%nl%>
|
4
|
-
<table>
|
5
|
-
<%iinc%><tr>
|
6
|
-
<%iinc%><th>Name</th>
|
7
|
-
<th>Title</th>
|
8
|
-
<th>Content</th>
|
9
|
-
<th></th>
|
10
|
-
<th></th>
|
11
|
-
<th></th>
|
12
|
-
<%idec%></tr><%nl%>
|
13
|
-
|
14
|
-
<%% @posts.each do |post| %>
|
15
|
-
<%iinc%><tr>
|
16
|
-
<%iinc%><td><%%= post.name %></td>
|
17
|
-
<td><%%= post.title %></td>
|
18
|
-
<td><%%= post.content %></td>
|
19
|
-
<td><%%= link_to 'Show', post %></td>
|
20
|
-
<td><%%= link_to 'Edit', edit_post_path(post) %></td>
|
21
|
-
<td><%%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td>
|
22
|
-
<%idec%></tr>
|
23
|
-
<%idec%><%% end %>
|
24
|
-
<%idec%></table><%nl%>
|
25
|
-
|
26
|
-
<br /><%nl%>
|
27
|
-
|
28
|
-
<%% link_to 'New post', new_post_path %>
|
29
|
-
<% end %>
|
30
|
-
<% end %>
|