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,60 @@
1
+ <% i = 1 %>
2
+
3
+ <% define 'pages_nav', :for => Form do %>
4
+ <% file "app/views/#{file_name}/_pages_nav.html.erb" do %>
5
+ <% if actual_pages_number >= 1 %>
6
+ <div class="pagination pagination-centered"><% iinc %>
7
+ <ul><% iinc %>
8
+ <% expand 'prev_link', snake_name, j if has_multiple_pages %>
9
+
10
+ <% i = 1 %>
11
+ <% j = 0 %>
12
+ <% page_elements.each do |page_elements| %>
13
+ <% j = j + 1 %>
14
+ <% expand 'page_link', snake_name, j if has_multiple_pages %>
15
+ <% page_title = (actual_pages_number == pages_number)? pages[j - 1].title: "" %>
16
+ <% expand 'page_file', file_name, page_title, page_elements, (j == actual_pages_number), j, :indent => 0 %>
17
+ <% end %>
18
+
19
+ <% expand 'next_link', snake_name, j if has_multiple_pages %>
20
+ <% idec %></ul>
21
+ <% idec %></div>
22
+ <% end %>
23
+ <% end %>
24
+ <% end %>
25
+
26
+ <% define 'page_link' do |form_name, page_number| %>
27
+ <%%= <%= form_name %>_page_link(<%= page_number %>) %>
28
+ <% end %>
29
+
30
+ <% define 'prev_link' do |form_name, pages_number| %>
31
+ <%%= <%= form_name %>_prev_link %>
32
+ <% end %>
33
+
34
+ <% define 'next_link' do |form_name, pages_number| %>
35
+ <%%= <%= form_name %>_next_link %>
36
+ <% end %>
37
+
38
+ <% define 'page_file' do |file_name, page_title, page_elements, has_submit_tag, page_number| %>
39
+ <% file "app/views/#{file_name}/_page#{page_number}.html.erb" do %>
40
+ <h2><%= page_title %></h2>
41
+ <% page_elements.each do |page_element| %>
42
+ <% expand 'element::element', page_element, i %>
43
+ <% if page_element.is_a?(Group) %>
44
+ <% i = i + page_element.elements.count %>
45
+ <% elsif page_element.has_model_element? %>
46
+ <% i = i + 1 %>
47
+ <% end %>
48
+ <% end %>
49
+
50
+ <% nl %>
51
+ <div class="submit_button"><% iinc %>
52
+ <br />
53
+ <% if has_submit_tag %>
54
+ <%%= button_tag "Submit", :class => "btn btn-large btn-block btn-primary" %>
55
+ <% else %>
56
+ <%%= button_tag "Save changes", :class => "btn btn-large btn-block" %>
57
+ <% end %>
58
+ <% idec %></div>
59
+ <% end %>
60
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <% define 'radio_button_group', :for => RadioButtonGroup do %>
2
+ <% if dropdown %>
3
+ <% expand 'choice_question::dropdown', name, real_class_name, choices, false %>
4
+ <% else %>
5
+ <% choices.each do |choice| %>
6
+ <% expand 'choice_question::choice', choice, nil %>
7
+ <br />
8
+ <% end %>
9
+ <% end %>
10
+ <% end %>
@@ -0,0 +1,54 @@
1
+ <% define 'table', :for => Table do %>
2
+ <table class="table table-bordered table-hover"><% iinc %>
3
+ <tr><% iinc %>
4
+ <th></th>
5
+ <% columns.each do |column| %>
6
+ <th id="data"><%= column.title %></th>
7
+ <% end %>
8
+ <% idec %></tr>
9
+
10
+ <% nl %>
11
+ <% if has_images? %><% i = 0 %><% end %>
12
+ <% rows.each do |row| %>
13
+ <tr><% iinc %>
14
+ <th><%= row.title %></th>
15
+ <% columns.each do |column| %>
16
+ <% content = "#{name}_#{row.name}_#{column.name}" %>
17
+ <% content_single = "#{name}_#{row.name}" %>
18
+ <% title = "#{row.title} & #{column.title}" %>
19
+ <% default = "(params[:#{content}] if !params[:#{content}].nil?)" %>
20
+ <% default_single = "(params[:#{content_single}] if (!params[:#{content_single}].nil? and params[:#{content_single}] == '#{title}'))" %>
21
+ <td id="data"><% iinc %>
22
+ <span class="<%= row.name %>"><% iinc %>
23
+ <% if has_images? %>
24
+ <% expand 'image::image', :for => real_images[i] %>
25
+ <% i = i + 1 %>
26
+ <% end %>
27
+ <% if dropdown %>
28
+ <% if type == :singleChoice %>
29
+ <% expand 'select_table', content, real_class_name, choices, false %>
30
+ <% elsif type == :multipleChoice %>
31
+ <% expand 'select_table', content, real_class_name, choices, true %>
32
+ <% end %>
33
+ <% else %>
34
+ <% if type == :singleChoice %>
35
+ <%%= radio_button_tag "<%= content_single %>", "<%= title %>", <%= default_single %> %>
36
+ <% elsif type == :multipleChoice %>
37
+ <%%= check_box_tag "<%= content %>", "<%= title %>", <%= default %> %>
38
+ <% elsif type == :text %>
39
+ <%%= text_field_tag "<%= content %>", <%= default %> %>
40
+ <% elsif type == :likert %>
41
+ <%%= radio_button_tag "<%= content_single %>", "<%= title %>", <%= default_single %> %>
42
+ <% end %>
43
+ <% end %>
44
+ <% idec %></span>
45
+ <% idec %></td>
46
+ <% end %>
47
+ <% idec %></tr>
48
+ <% end %>
49
+ <% idec %></table>
50
+ <% end %>
51
+
52
+ <% define 'select_table' do |name, class_name, choices, multiple| %>
53
+ <% expand 'dropdown::table_dropdown', name, name, "(params[:#{name}] if !params[:#{name}].nil?)", class_name, choices, multiple %>
54
+ <% end %>
@@ -0,0 +1,47 @@
1
+ <% define 'textfield', :for => Textfield do %>
2
+ <% if prefix? and !suffix? %>
3
+ <div class="input-prepend"><% iinc %>
4
+ <% elsif suffix? and !prefix? %>
5
+ <div class="input-append"><% iinc %>
6
+ <% elsif suffix? and prefix? %>
7
+ <div class="input-prepend input-append"><% iinc %>
8
+ <% end %>
9
+
10
+ <% if prefix? %>
11
+ <span class="add-on" style="height: 17px;"><%= prefix %></span>
12
+ <% end %>
13
+
14
+ <% expand 'original_textfield' %>
15
+
16
+ <% if suffix? %>
17
+ <span class="add-on" style="height: 17px;"><%= suffix %></span>
18
+ <% end %>
19
+
20
+ <% if prefix? or suffix? %>
21
+ <% idec %></div>
22
+ <% end %>
23
+ <% end %>
24
+
25
+ <% define 'original_textfield', :for => Textfield do %>
26
+ <% if type == :small %>
27
+ <%%= text_field_tag "<%= name %>[content]", <% expand 'textfield_def' %>, :size => 20, :class => "input-large <%= name %>", :id => "<% expand 'textfield_id' %>" %>
28
+ <% elsif type == :multiLine %>
29
+ <%%= text_area_tag "<%= name %>[content]", <% expand 'textfield_def' %>, :size => "64x6", :class => "span8 <%= name %>", :id => "<% expand 'textfield_id' %>" %>
30
+ <% else %>
31
+ <%%= text_field_tag "<%= name %>[content]", <% expand 'textfield_def' %>, :class => "span8 <%= name %>", :id => "<% expand 'textfield_id' %>" %>
32
+ <% end %>
33
+ <% end %>
34
+
35
+ <% define 'textfield_id', :for => Textfield do %>
36
+ <% if prefix and !suffix? %>
37
+ prependedInput<% nonl %><% nows %>
38
+ <% elsif !prefix and suffix? %>
39
+ appendedInput<% nonl %><% nows %>
40
+ <% else %>
41
+ appendedPrependedInput<% nonl %><% nows %>
42
+ <% end %>
43
+ <% end %>
44
+
45
+ <% define 'textfield_def', :for => Textfield do %>
46
+ ((!params[:<%= name %>].nil?)? params[:<%= name %>][:content]: nil)<% nonl %><% nows %>
47
+ <% 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 'jquery', '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,28 @@
1
+ <% indent = 3 %>
2
+
3
+ <% define 'static' do %>
4
+ <% file "app/views/layouts/_footer.html.erb" do %>
5
+ <% expand 'start' %>
6
+ <% expand 'end', :indent => indent %>
7
+ <% end %>
8
+ <% end %>
9
+
10
+ <% define 'dynamic', :for => View do %>
11
+ <% file "app/views/layouts/_footer.html.erb" do %>
12
+ <% expand 'start' %>
13
+ <% expand 'static_element::elements', footer.elements, forms, indent, :indent => indent %>
14
+ <% expand 'end', :indent => indent %>
15
+ <% end %>
16
+ <% end %>
17
+
18
+ <% define 'start' do %>
19
+ <footer class="footer"><% iinc %>
20
+ <nav><% iinc %>
21
+ <ul><% iinc %>
22
+ <% end %>
23
+
24
+ <% define 'end' do %>
25
+ <% idec %></ul>
26
+ <% idec %></nav>
27
+ <% idec %></footer>
28
+ <% end %>
@@ -0,0 +1,32 @@
1
+ <% indent = 5 %>
2
+
3
+ <% define 'static' do %>
4
+ <% file "app/views/layouts/_header.html.erb" do %>
5
+ <% expand 'start' %>
6
+ <% expand 'end', :indent => indent %>
7
+ <% end %>
8
+ <% end %>
9
+
10
+ <% define 'dynamic', :for => View do %>
11
+ <% file "app/views/layouts/_header.html.erb" do %>
12
+ <% expand 'start' %>
13
+ <% expand 'static_element::elements', header.elements, forms, indent, :indent => indent %>
14
+ <% expand 'end', :indent => indent %>
15
+ <% end %>
16
+ <% end %>
17
+
18
+ <% define 'start' do %>
19
+ <header class="navbar navbar-fixed-top navbar-inverse"><% iinc %>
20
+ <div class="navbar-inner"><% iinc %>
21
+ <div class="container"><% iinc %>
22
+ <nav><% iinc %>
23
+ <ul class="nav pull-right"><% iinc %>
24
+ <% end %>
25
+
26
+ <% define 'end' do %>
27
+ <% idec %></ul>
28
+ <% idec %></nav>
29
+ <% idec %></div>
30
+ <% idec %></div>
31
+ <% idec %></header>
32
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <% define 'shim' do %>
2
+ <% file "app/views/layouts/_shim.html.erb" do %>
3
+ <!--[if lt IE 9]><% iinc %>
4
+ <script scr="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
5
+ <% idec %><![endif]-->
6
+ <% end %>
7
+ <% end %>
@@ -0,0 +1,52 @@
1
+ <% define 'elements' do |elements, forms, indent| %>
2
+ <% elements.each do |element| %>
3
+ <% if element.is_a?(SurveyManagement) %>
4
+ <% expand 'survey_management', forms, :for => element, :indent => indent %>
5
+ <% elsif element.is_a?(UserManagement) %>
6
+ <% expand 'user_management', :for => element, :indent => indent %>
7
+ <% else %>
8
+ <% if element.is_a?(Link) %>
9
+ <li><%%= link_to "<%= element.title %>", <% if element.path %><%= element.url %><% else %>"<%= element.url %>"<% end %>, :class =>"<%= element.name %>" %></li>
10
+ <% elsif element.is_a?(Label) %>
11
+ <li class="<%= element.name %>"><%= element.content %></li>
12
+ <% end %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
16
+
17
+ <% define 'survey_management', :for => SurveyManagement do |forms| %>
18
+ <%% if signed_in? %><% iinc %>
19
+ <li id="fat-menu" class="dropdown"><% iinc %>
20
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown"><% iinc %>
21
+ Surveys <b class="caret"></b>
22
+ <% idec %></a>
23
+ <ul class="dropdown-menu"><% iinc %>
24
+ <%% if current_user.admin? %><% iinc %>
25
+ <li><%%= link_to "Show Replies", surveys_path %></li>
26
+ <li class="divider"></li>
27
+ <% idec %><%% end %>
28
+ <% forms.each do |form| %>
29
+ <li><%%= link_to "<%= form.title.capitalize %>", <%= form.snake_name %>_path(:page => 1) %></li>
30
+ <% end %>
31
+ <% idec %></ul>
32
+ <% idec %></li>
33
+ <% idec %><%% end %>
34
+ <% end %>
35
+
36
+ <% define 'user_management', :for => UserManagement do %>
37
+ <%% if signed_in? %><% iinc %>
38
+ <li id="fat-menu" class="dropdown"><% iinc %>
39
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown"><% iinc %>
40
+ Account <b class="caret"></b>
41
+ <% idec %></a>
42
+ <ul class="dropdown-menu"><% iinc %>
43
+ <li><%%= link_to "Profile", current_user %></li>
44
+ <li><%%= link_to "Settings", edit_user_path(current_user) %></li>
45
+ <li class="divider"></li>
46
+ <li><%%= link_to "Sign out", signout_path, method: "delete" %></li>
47
+ <% idec %></ul>
48
+ <% idec %></li>
49
+ <% idec %><%% else %><% iinc %>
50
+ <li><%%= link_to "Sign in", signin_path %></li>
51
+ <% idec %><%% end %>
52
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <% define 'question' do %>
2
+ <% file "app/views/questions/_question.html.erb" do %>
3
+ <li><% iinc %>
4
+ <span><%%= question.title %></span><br />
5
+ <span class="question_content"><%%= question.content %></span>
6
+ <% idec %></li>
7
+ <% end %>
8
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <% define 'new' do %>
2
+ <% file "app/views/sessions/new.html.erb" do %>
3
+ <%% provide(:title, "Sign in") %>
4
+ <h1>Sign in</h1>
5
+
6
+ <% nl %>
7
+ <div class="row"><% iinc %>
8
+ <div class="span6 offset3"><% iinc %>
9
+ <%%= form_tag sessions_path do %><% iinc %>
10
+ <div class="field"><% iinc %>
11
+ <%%= label_tag :email %>
12
+ <%%= text_field_tag :email, params[:email] %>
13
+ <% idec %></div>
14
+ <div class="field"><% iinc %>
15
+ <%%= label_tag :password %>
16
+ <%%= password_field_tag :password %>
17
+ <% idec %></div>
18
+
19
+ <% nl %>
20
+ <div class="actions"><%%= submit_tag "Sign in", class: "btn btn-large btn-primary" %></div>
21
+ <% idec %><%% end %>
22
+
23
+ <% nl %>
24
+ <p>New user? <%%= link_to "Sign up now!", signup_path %></p>
25
+ <% idec %></div>
26
+ <% idec %></div>
27
+ <% end %>
28
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <% define 'error_messages' 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,5 @@
1
+ <% define 'static_page' do %>
2
+ <% file "app/views/shared/_static_page.html.erb" do %>
3
+ <h3>Loading questions...</h3>
4
+ <% end %>
5
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <% define 'index' do %>
2
+ <% file "app/views/surveys/index.html.erb" do %>
3
+ <%% provide(:title, 'Replies') %>
4
+
5
+ <% nl %>
6
+ <div class="row">
7
+ <div class="span10 offset1">
8
+ <h1>Replies (<%%= @surveys.count %>)</h1>
9
+
10
+ <% nl %>
11
+ <%% if @surveys.any? %>
12
+ <%%= will_paginate @surveys, :align => "center" %>
13
+
14
+ <% nl %>
15
+ <ol class="surveys"><% iinc %>
16
+ <%%= render @surveys %>
17
+ <% idec %></ol>
18
+
19
+ <% nl %>
20
+ <%%= will_paginate @surveys, :align => "center" %>
21
+ <%% end %>
22
+ </div>
23
+ </div>
24
+ <% end %>
25
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <% define 'survey' do %>
2
+ <% file "app/views/surveys/_survey.html.erb" do %>
3
+ <li><% iinc %>
4
+ <span class="content">
5
+ <h3>"<%%= survey.title %>" by <%%= survey.author %></h3>
6
+ <h4>Answers (<%%= survey.questions.count %>)</h4>
7
+ <ol><% iinc %>
8
+ <%%= render survey.questions %>
9
+ <% idec %></ol>
10
+ </span>
11
+ <span class="timestamp">Answered <%%= time_ago_in_words(survey.created_at) %> ago<%% if !survey.user_id.blank? %> by <%%= User.find_by_id(survey.user_id).name %><%% end %></span>
12
+ <% idec %></li>
13
+ <% end %>
14
+ <% end %>
@@ -0,0 +1,19 @@
1
+ <% define 'edit' do %>
2
+ <% file "app/views/users/edit.html.erb" do %>
3
+ <%% provide(:title, "Edit user") %>
4
+ <h1>Update your profile</h1>
5
+
6
+ <% nl %>
7
+ <div class="row"><% iinc %>
8
+ <div class="span6 offset3"><% iinc %>
9
+ <%%= form_for(@user) do |f| %><% iinc %>
10
+ <%%= render 'fields', f: f, password_confirm_label: "Confirm Password", submit_label: "Save changes" %>
11
+ <% idec %><%% end %>
12
+
13
+ <% nl %>
14
+ <%%= gravatar_for @user, 80 %>
15
+ <%%= link_to "change", "http://gravatar.com/emails", target: "_blank"%>
16
+ <% idec %></div>
17
+ <% idec %></div>
18
+ <% end %>
19
+ <% end %>
@@ -0,0 +1,24 @@
1
+ <% define 'fields' do %>
2
+ <% file "app/views/users/_fields.html.erb" do %>
3
+ <%%= render 'shared/error_messages', object: f.object %>
4
+
5
+ <% nl %>
6
+ <%%= f.label :name %>
7
+ <%%= f.text_field :name %>
8
+
9
+ <% nl %>
10
+ <%%= f.label :email %>
11
+ <%%= f.text_field :email %>
12
+
13
+ <% nl %>
14
+ <%%= f.label :password %>
15
+ <%%= f.password_field :password %>
16
+
17
+ <% nl %>
18
+ <%%= f.label :password_confirmation, password_confirm_label %>
19
+ <%%= f.password_field :password_confirmation %>
20
+
21
+ <% nl %>
22
+ <%%= f.submit submit_label , class: "btn btn-large btn-primary" %>
23
+ <% end %>
24
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <% define 'index' do %>
2
+ <% file "app/views/users/index.html.erb" do %>
3
+ <%% provide(:title, 'All users') %>
4
+ <h1>All users</h1>
5
+
6
+ <% nl %>
7
+ <%%= will_paginate %>
8
+
9
+ <% nl %>
10
+ <ul class="users"><% iinc %>
11
+ <%%= render @users %>
12
+ <% idec %></ul>
13
+
14
+ <% nl %>
15
+ <%%= will_paginate %>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <% define 'new' do %>
2
+ <% file "app/views/users/new.html.erb" do %>
3
+ <%% provide(:title, 'Sign up') %>
4
+ <h1>Sign up</h1>
5
+
6
+ <% nl %>
7
+ <div class="row"><% iinc %>
8
+ <div class="span6 offset3"><% iinc %>
9
+ <%%= form_for(@user) do |f| %><% iinc %>
10
+ <%%= render 'fields', f: f, password_confirm_label: "Confirmation", submit_label:"Create my account" %>
11
+ <% idec %><%% end %>
12
+ <% idec %></div>
13
+ <% idec %></div>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <% define 'show' do %>
2
+ <% file "app/views/users/show.html.erb" do %>
3
+ <%% provide(:title, @user.name) %>
4
+
5
+ <% nl %>
6
+ <div class="row"><% iinc %>
7
+ <aside class="span4"><% iinc %>
8
+ <section><% iinc %>
9
+ <h1><% iinc %>
10
+ <%%= gravatar_for @user, 80 %>
11
+ <%%= @user.name %>
12
+ <% idec %></h1>
13
+ <% idec %></section>
14
+ <% idec %></aside>
15
+ </div>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <% define 'user' do %>
2
+ <% file "app/views/users/_user.html.erb" do %>
3
+ <li><% iinc %>
4
+ <%%= gravatar_for user, 52 %>
5
+ <%%= link_to user.name, user %>
6
+ <%% if current_user.admin? and !current_user?(user) %><% iinc %>
7
+ | <%%= link_to "delete", user, method: :delete, data: { confirm: "You sure?" } %>
8
+ <%% end %>
9
+ <% idec %></li>
10
+ <% end %>
11
+ <% end %>
@@ -0,0 +1,30 @@
1
+ <% define 'static' do %>
2
+ <% expand 'layouts/application::application' %>
3
+ <% expand 'layouts/footer::static' %>
4
+ <% expand 'layouts/header::static' %>
5
+ <% expand 'layouts/shim::shim' %>
6
+
7
+ <% expand 'questions/question::question' %>
8
+
9
+ <% expand 'sessions/new::new' %>
10
+
11
+ <% expand 'shared/error_messages::error_messages' %>
12
+ <% expand 'shared/static_page::static_page' %>
13
+
14
+ <% expand 'surveys/index::index' %>
15
+ <% expand 'surveys/survey::survey' %>
16
+
17
+ <% expand 'users/new::new' %>
18
+ <% expand 'users/fields::fields' %>
19
+ <% expand 'users/edit::edit' %>
20
+ <% expand 'users/show::show' %>
21
+ <% expand 'users/index::index' %>
22
+ <% expand 'users/user::user' %>
23
+ <% end %>
24
+
25
+ <% define 'dynamic' do %>
26
+ <% expand 'layouts/footer::dynamic', :for => view %>
27
+ <% expand 'layouts/header::dynamic', :for => view %>
28
+
29
+ <% expand 'form/form::form', :foreach => view.forms %>
30
+ <% end %>
@@ -0,0 +1,26 @@
1
+ <% define 'static' do %>
2
+ <% file "config/application.rb" do %>
3
+ require File.expand_path('../boot', __FILE__)
4
+
5
+ <% nl %>
6
+ require 'rails/all'
7
+
8
+ <% nl %>
9
+ if defined?(Bundler)<% iinc %>
10
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
11
+ <% idec %>end
12
+
13
+ <% nl %>
14
+ module <%= Rails.application.class.parent_name %><% iinc %>
15
+ class Application < Rails::Application<% iinc %>
16
+ config.encoding = "utf-8"
17
+ config.filter_parameters += [:password]
18
+ config.active_support.escape_html_entities_in_json = true
19
+ config.active_record.whitelist_attributes = true
20
+ config.assets.enabled = true
21
+ config.assets.version = '1.0'
22
+ config.autoload_paths += Dir["lib"]
23
+ <% idec %>end
24
+ <% idec %>end
25
+ <% end %>
26
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <% define 'static' do %>
2
+ <% expand 'application::static' %>
3
+ <% expand 'routes::static' %>
4
+ <% end %>
5
+
6
+ <% define 'dynamic' do %>
7
+ <% expand 'routes::dynamic', :for => view %>
8
+ <% end %>