fine_print 0.0.1

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 (114) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +124 -0
  3. data/Rakefile +23 -0
  4. data/app/assets/javascripts/fine_print/agreements.js +19 -0
  5. data/app/assets/javascripts/fine_print/agreements.js~ +19 -0
  6. data/app/assets/javascripts/fine_print/application.js +4 -0
  7. data/app/assets/javascripts/fine_print/application.js~ +5 -0
  8. data/app/assets/javascripts/fine_print/dialog.js +2 -0
  9. data/app/assets/javascripts/fine_print/dialog.js~ +2 -0
  10. data/app/assets/javascripts/fine_print/user_agreements.js +20 -0
  11. data/app/assets/javascripts/fine_print/user_agreements.js~ +20 -0
  12. data/app/assets/stylesheets/fine_print/agreements.css +11 -0
  13. data/app/assets/stylesheets/fine_print/agreements.css~ +11 -0
  14. data/app/assets/stylesheets/fine_print/application.css +5 -0
  15. data/app/assets/stylesheets/fine_print/application.css~ +60 -0
  16. data/app/assets/stylesheets/fine_print/scaffold.css +56 -0
  17. data/app/assets/stylesheets/fine_print/user_agreements.css~ +3 -0
  18. data/app/assets/stylesheets/scaffold.css~ +56 -0
  19. data/app/controllers/fine_print/agreements_controller.rb +114 -0
  20. data/app/controllers/fine_print/agreements_controller.rb~ +113 -0
  21. data/app/controllers/fine_print/application_controller.rb +13 -0
  22. data/app/controllers/fine_print/application_controller.rb~ +13 -0
  23. data/app/controllers/fine_print/home_controller.rb +14 -0
  24. data/app/controllers/fine_print/home_controller.rb~ +15 -0
  25. data/app/controllers/fine_print/user_agreements_controller.rb +63 -0
  26. data/app/controllers/fine_print/user_agreements_controller.rb~ +63 -0
  27. data/app/models/fine_print/agreement.rb +50 -0
  28. data/app/models/fine_print/agreement.rb~ +50 -0
  29. data/app/models/fine_print/user_agreement.rb +19 -0
  30. data/app/models/fine_print/user_agreement.rb~ +21 -0
  31. data/app/views/fine_print/agreements/_agreement.html.erb +77 -0
  32. data/app/views/fine_print/agreements/_agreement.html.erb~ +77 -0
  33. data/app/views/fine_print/agreements/_dialog.html.erb +27 -0
  34. data/app/views/fine_print/agreements/_dialog.html.erb~ +27 -0
  35. data/app/views/fine_print/agreements/_form.html.erb +51 -0
  36. data/app/views/fine_print/agreements/_form.html.erb~ +51 -0
  37. data/app/views/fine_print/agreements/edit.html.erb +8 -0
  38. data/app/views/fine_print/agreements/edit.html.erb~ +8 -0
  39. data/app/views/fine_print/agreements/index.html.erb +32 -0
  40. data/app/views/fine_print/agreements/index.html.erb~ +32 -0
  41. data/app/views/fine_print/agreements/new.html.erb +7 -0
  42. data/app/views/fine_print/agreements/new.html.erb~ +7 -0
  43. data/app/views/fine_print/agreements/new_version.html.erb +7 -0
  44. data/app/views/fine_print/agreements/new_version.html.erb~ +7 -0
  45. data/app/views/fine_print/agreements/show.html.erb +15 -0
  46. data/app/views/fine_print/agreements/show.html.erb~ +14 -0
  47. data/app/views/fine_print/home/index.html.erb +7 -0
  48. data/app/views/fine_print/home/index.html.erb~ +7 -0
  49. data/app/views/fine_print/user_agreements/cancel.js.erb +1 -0
  50. data/app/views/fine_print/user_agreements/cancel.js.erb~ +2 -0
  51. data/app/views/fine_print/user_agreements/create.js.erb +2 -0
  52. data/app/views/fine_print/user_agreements/create.js.erb~ +2 -0
  53. data/app/views/fine_print/user_agreements/index.html.erb +25 -0
  54. data/app/views/fine_print/user_agreements/index.html.erb~ +25 -0
  55. data/app/views/layouts/fine_print/application.html.erb +14 -0
  56. data/config/initializers/fine_print.rb +53 -0
  57. data/config/initializers/fine_print.rb~ +53 -0
  58. data/config/routes.rb +7 -0
  59. data/config/routes.rb~ +7 -0
  60. data/db/migrate/0_create_fine_print_agreements.rb~ +22 -0
  61. data/db/migrate/0_install.rb +28 -0
  62. data/db/migrate/0_install.rb~ +28 -0
  63. data/lib/fine_print/agreements_helper.rb +13 -0
  64. data/lib/fine_print/agreements_helper.rb~ +11 -0
  65. data/lib/fine_print/engine.rb +5 -0
  66. data/lib/fine_print/fine_print_agreement.rb +26 -0
  67. data/lib/fine_print/fine_print_agreement.rb~ +26 -0
  68. data/lib/fine_print/require_agreement.rb~ +22 -0
  69. data/lib/fine_print/security_transgression.rb +4 -0
  70. data/lib/fine_print/security_transgression.rb~ +3 -0
  71. data/lib/fine_print/version.rb +3 -0
  72. data/lib/fine_print/version.rb~ +3 -0
  73. data/lib/fine_print.rb +69 -0
  74. data/lib/fine_print.rb~ +68 -0
  75. data/lib/tasks/fine_print_tasks.rake +42 -0
  76. data/lib/tasks/fine_print_tasks.rake~ +85 -0
  77. data/spec/dummy/README.md +3 -0
  78. data/spec/dummy/README.md~ +3 -0
  79. data/spec/dummy/Rakefile +7 -0
  80. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  81. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  82. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  83. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  84. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  85. data/spec/dummy/config/application.rb +59 -0
  86. data/spec/dummy/config/boot.rb +10 -0
  87. data/spec/dummy/config/database.yml +25 -0
  88. data/spec/dummy/config/environment.rb +5 -0
  89. data/spec/dummy/config/environments/development.rb +37 -0
  90. data/spec/dummy/config/environments/production.rb +67 -0
  91. data/spec/dummy/config/environments/test.rb +37 -0
  92. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  93. data/spec/dummy/config/initializers/inflections.rb +15 -0
  94. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  95. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  96. data/spec/dummy/config/initializers/session_store.rb +8 -0
  97. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  98. data/spec/dummy/config/locales/en.yml +5 -0
  99. data/spec/dummy/config/routes.rb +4 -0
  100. data/spec/dummy/config.ru +4 -0
  101. data/spec/dummy/db/development.sqlite3 +0 -0
  102. data/spec/dummy/db/schema.rb +36 -0
  103. data/spec/dummy/db/test.sqlite3 +0 -0
  104. data/spec/dummy/log/development.log +41 -0
  105. data/spec/dummy/log/test.log +3 -0
  106. data/spec/dummy/public/404.html +26 -0
  107. data/spec/dummy/public/422.html +26 -0
  108. data/spec/dummy/public/500.html +25 -0
  109. data/spec/dummy/public/favicon.ico +0 -0
  110. data/spec/dummy/script/rails +6 -0
  111. data/spec/fine_print_spec.rb +7 -0
  112. data/spec/fine_print_spec.rb~ +7 -0
  113. data/spec/minitest_helper.rb +12 -0
  114. metadata +277 -0
@@ -0,0 +1,51 @@
1
+ <%= form_for(@agreement) do |f| %>
2
+ <% if @agreement.errors.any? %>
3
+ <div id="error_explanation" class="fine_print errors">
4
+ <h2 class="fine_print heading"><%= pluralize(@agreement.errors.count, "error") %> prohibited this agreement from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @agreement.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name, :class => "fine_print label" %><br/>
16
+ <%= f.text_field :name, :size => 40, :class => "fine_print text_field" %><br/>
17
+ (e.g., "Terms of Use"; changing this will reset the version count)<br/><br/>
18
+ </div>
19
+ <div class="field">
20
+ <%= f.label :content, :class => "fine_print label" %><br/>
21
+ <%= f.text_area :content, :cols => 56, :class => "fine_print text_area" %><br/><br/>
22
+ </div>
23
+ <div class="field">
24
+ <%= f.label :confirmation_text, :class => "fine_print label" %><br/>
25
+ <%= f.text_field :confirmation_text, :size => 40, :class => "fine_print text_field" %><br/>
26
+ (e.g., "I have read and agree to the terms and conditions above")<br/><br/>
27
+ </div>
28
+ <div class="field">
29
+ <%= f.label :ready, "Display the agreement's name to users as a heading?", :class => "fine_print label" %>
30
+ <%= f.check_box :display_name, :class => "fine_print checkbox" %><br/><br/>
31
+ </div>
32
+ <div class="field">
33
+ <%= f.label :ready, "Display the agreement's version to users?", :class => "fine_print label" %>
34
+ <%= f.check_box :display_version, :class => "fine_print checkbox" %><br/><br/>
35
+ </div>
36
+ <div class="field">
37
+ <%= f.label :ready, "Display the agreement's last updated date to users?", :class => "fine_print label" %>
38
+ <%= f.check_box :display_updated, :class => "fine_print checkbox" %><br/><br/>
39
+ </div>
40
+ <div class="field">
41
+ <%= f.label :ready, "Display a confirmation checkbox that users have to click?", :class => "fine_print label" %>
42
+ <%= f.check_box :display_confirmation, :class => "fine_print checkbox" %><br/><br/>
43
+ </div>
44
+ <div class="field">
45
+ <%= f.label :ready, "Ready to be used?", :class => "fine_print label" %>
46
+ <%= f.check_box :ready, :class => "fine_print checkbox" %><br/><br/>
47
+ </div>
48
+ <div class="actions">
49
+ <%= f.submit nil, :class => "fine_print submit" %>
50
+ </div>
51
+ <% end %>
@@ -0,0 +1,51 @@
1
+ <%= form_for(@agreement) do |f| %>
2
+ <% if @agreement.errors.any? %>
3
+ <div id="error_explanation" class="fine_print errors">
4
+ <h2 class="fine_print heading"><%= pluralize(@agreement.errors.count, "error") %> prohibited this agreement from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @agreement.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name, :class => "fine_print label" %><br/>
16
+ <%= f.text_field :name, :size => 40, :class => "fine_print text_field" %><br/>
17
+ (e.g., "Terms of Use"; changing this will reset the version count)<br/><br/>
18
+ </div>
19
+ <div class="field">
20
+ <%= f.label :content, :class => "fine_print label" %><br/>
21
+ <%= f.text_area :content, :cols => 56, :class => "fine_print text_area" %><br/><br/>
22
+ </div>
23
+ <div class="field">
24
+ <%= f.label :confirmation_text, :class => "fine_print label" %><br/>
25
+ <%= f.text_field :confirmation_text, :size => 40, :class => "fine_print text_field" %><br/>
26
+ (e.g., "I have read and agree to the terms and conditions above")<br/><br/>
27
+ </div>
28
+ <div class="field">
29
+ <%= f.label :ready, "Display the agreement's name to users (as a heading)?", :class => "fine_print label" %>
30
+ <%= f.check_box :display_name, :class => "fine_print checkbox" %><br/><br/>
31
+ </div>
32
+ <div class="field">
33
+ <%= f.label :ready, "Display the agreement's version to users?", :class => "fine_print label" %>
34
+ <%= f.check_box :display_version, :class => "fine_print checkbox" %><br/><br/>
35
+ </div>
36
+ <div class="field">
37
+ <%= f.label :ready, "Display the agreement's last updated date to users?", :class => "fine_print label" %>
38
+ <%= f.check_box :display_updated, :class => "fine_print checkbox" %><br/><br/>
39
+ </div>
40
+ <div class="field">
41
+ <%= f.label :ready, "Display a confirmation checkbox that users have to click?", :class => "fine_print label" %>
42
+ <%= f.check_box :display_confirmation, :class => "fine_print checkbox" %><br/><br/>
43
+ </div>
44
+ <div class="field">
45
+ <%= f.label :ready, "Ready to be used?", :class => "fine_print label" %>
46
+ <%= f.check_box :ready, :class => "fine_print checkbox" %><br/><br/>
47
+ </div>
48
+ <div class="actions">
49
+ <%= f.submit nil, :class => "fine_print submit" %>
50
+ </div>
51
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <h1 class="fine_print heading">Editing agreement</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <br/>
6
+
7
+ <%= link_to 'Show', @agreement, :class => "fine_print link" %> |
8
+ <%= link_to 'Back', agreements_path, :class => "fine_print link" %>
@@ -0,0 +1,8 @@
1
+ <h1 class="fine_print heading">Editing agreement</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <br/>
6
+
7
+ <%= link_to 'Show', @agreement, :class => fine_print link" %> |
8
+ <%= link_to 'Back', agreements_path, :class => fine_print link" %>
@@ -0,0 +1,32 @@
1
+ <h1 class="fine_print heading">FinePrint agreements</h1>
2
+
3
+ <table class="fine_print index">
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Version</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @agreements.each do |agreement| %>
13
+ <tr>
14
+ <td><%= agreement.name %></td>
15
+ <td><%= agreement.version %></td>
16
+ <td><%= link_to 'Show', agreement, :class => "fine_print link" %></td>
17
+ <td><% if agreement.can_be_edited_by?(@user) %>
18
+ <%= link_to 'Edit', edit_agreement_path(agreement), :class => "fine_print link" %>
19
+ <% else %>
20
+ <%= link_to 'New version', agreement_new_version_path(agreement), :class => "fine_print link" %>
21
+ <% end %></td>
22
+ <td><% if agreement.can_be_destroyed_by?(@user) %>
23
+ <%= link_to 'Delete', agreement, method: :delete, data: { confirm: 'Are you sure you wish to delete this agreement?' }, :class => "fine_print link" %>
24
+ <% end %></td>
25
+ </tr>
26
+ <% end %>
27
+ </table>
28
+
29
+ <br />
30
+
31
+ <%= link_to 'New Agreement', new_agreement_path, :class => "fine_print link" %> |
32
+ <%= link_to 'Back', root_path, :class => "fine_print link" %>
@@ -0,0 +1,32 @@
1
+ <h1 class="fine_print heading">FinePrint agreements</h1>
2
+
3
+ <table class="fine_print index">
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Version</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @agreements.each do |agreement| %>
13
+ <tr>
14
+ <td><%= agreement.name %></td>
15
+ <td><%= agreement.version %></td>
16
+ <td><%= link_to 'Show', agreement, :class => "fine_print link" %></td>
17
+ <td><% if agreement.can_be_edited_by?(@user) %>
18
+ <%= link_to 'Edit', edit_agreement_path(agreement), :class => "fine_print link" %>
19
+ <% else %>
20
+ <%= link_to 'New version', agreement_new_version_path(agreement), :class => "fine_print link" %>
21
+ <% end %></td>
22
+ <td><% if agreement.can_be_destroyed_by?(@user) %>
23
+ <%= link_to 'Delete', agreement, method: :delete, data: { confirm: 'Are you sure?' }, :class => "fine_print link" %>
24
+ <% end %></td>
25
+ </tr>
26
+ <% end %>
27
+ </table>
28
+
29
+ <br />
30
+
31
+ <%= link_to 'New Agreement', new_agreement_path, :class => "fine_print link" %> |
32
+ <%= link_to 'Back', root_path, :class => "fine_print link" %>
@@ -0,0 +1,7 @@
1
+ <h1 class="fine_print heading">New agreement</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <br/>
6
+
7
+ <%= link_to 'Back', agreements_path, :class => "fine_print link" %>
@@ -0,0 +1,7 @@
1
+ <h1 class="fine_print heading">New agreement</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <br/>
6
+
7
+ <%= link_to 'Back', agreements_path, :class => fine_print link" %>
@@ -0,0 +1,7 @@
1
+ <h1 class="fine_print heading">New version of <%= @agreement.name %></h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <br/>
6
+
7
+ <%= link_to 'Back', agreements_path, :class => "fine_print link" %>
@@ -0,0 +1,7 @@
1
+ <h1 class="fine_print heading"><%= @agreement.name %> version <%= @agreement.version + 1 %></h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <br/>
6
+
7
+ <%= link_to 'Back', agreements_path, :class => "fine_print link" %>
@@ -0,0 +1,15 @@
1
+ <%= render :partial => 'agreement', :locals => {
2
+ :agreement => @agreement,
3
+ :user => @user,
4
+ :notice => @notice,
5
+ :accept_path => @accept_path,
6
+ :cancel_path => @cancel_path,
7
+ :url => @url,
8
+ :ref => @ref } %>
9
+
10
+ <br/>
11
+
12
+ <% if @agreement.can_be_edited_by?(@user) %>
13
+ <%= link_to 'Edit', edit_agreement_path(@agreement), :class => "fine_print link" %> |
14
+ <%= link_to 'Back', agreements_path, :class => "fine_print link" %>
15
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <%= render :partial => 'agreement', :locals => {
2
+ :agreement => @agreement,
3
+ :user => @user,
4
+ :notice => @notice,
5
+ :accept_path => @accept_path,
6
+ :url => @url,
7
+ :ref => @ref } %>
8
+
9
+ <br/>
10
+
11
+ <% if @agreement.can_be_edited_by?(@user) %>
12
+ <%= link_to 'Edit', edit_agreement_path(@agreement), :class => "fine_print link" %> |
13
+ <%= link_to 'Back', agreements_path, :class => "fine_print link" %>
14
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <h1 class="fine_print heading">FinePrint</h1>
2
+
3
+ <ul>
4
+ <li><%= link_to 'Manage agreements', agreements_path, :class => "fine_print link" %></li>
5
+ <li><%= link_to 'View accepted agreements', user_agreements_path, :class => "fine_print link" %></li>
6
+ </ul>
7
+
@@ -0,0 +1,7 @@
1
+ <h1 class="fine_print heading">FinePrint</h1>
2
+
3
+ <ul>
4
+ <li><%= link_to 'Manage agreements', agreements_path, :class => "fine_print link" %></li>
5
+ <li><%= link_to 'Accepted agreements', user_agreements_path, :class => "fine_print link" %></li>
6
+ </ul>
7
+
@@ -0,0 +1 @@
1
+ window.history.back();
@@ -0,0 +1,2 @@
1
+ $("<%= "#fine_print_dialog_#{@index}" %>").off("dialogbeforeclose").dialog("close");
2
+ $("<%= "#fine_print_dialog_#{@index + 1}" %>").dialog("open");
@@ -0,0 +1,2 @@
1
+ $("<%= "#fine_print_dialog_#{@index}" %>").off("dialogbeforeclose").dialog("close");
2
+ $("<%= "#fine_print_dialog_#{@index + 1}" %>").dialog("open");
@@ -0,0 +1,2 @@
1
+ $("<%= "#fine_print_dialog_#{@index}" %>").off("dialogbeforeclose").dialog("close");
2
+ $("<%= "#fine_print_dialog_#{@next_index}" %>").dialog("open");
@@ -0,0 +1,25 @@
1
+ <h1 class="fine_print heading">Accepted FinePrint agreements</h1>
2
+
3
+ <table class="fine_print index">
4
+ <tr>
5
+ <th>User ID</th>
6
+ <th>Agreement name</th>
7
+ <th>Agreement version</th>
8
+ <th>Date accepted</th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @user_agreements.each do |user_agreement| %>
13
+ <tr>
14
+ <td><%= user_agreement.user.id %></td>
15
+ <td><%= user_agreement.agreement.name %></td>
16
+ <td><%= user_agreement.agreement.version %></td>
17
+ <td><%= user_agreement.created_at %></td>
18
+ <td><%= link_to 'Terminate', user_agreement, method: :delete, data: { confirm: 'User will be asked to accept the agreement again. Are you sure?' }, :class => "fine_print link" %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'Back', root_path, :class => "fine_print link" %>
@@ -0,0 +1,25 @@
1
+ <h1 class="fine_print heading">Accepted FinePrint agreements</h1>
2
+
3
+ <table class="fine_print index">
4
+ <tr>
5
+ <th>User ID</th>
6
+ <th>Agreement name</th>
7
+ <th>Agreement version</th>
8
+ <th>Date accepted</th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @user_agreements.each do |user_agreement| %>
13
+ <tr>
14
+ <td><%= user_agreement.user.id %></td>
15
+ <td><%= user_agreement.agreement.name %></td>
16
+ <td><%= user_agreement.agreement.version %></td>
17
+ <td><%= user_agreement.created_at %></td>
18
+ <td><%= link_to 'Terminate', user_agreement, method: :delete, data: { confirm: 'Are you sure? User will be asked to accept the agreement again.' }, :class => "fine_print link" %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'Back', root_path, :class => "fine_print link" %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>FinePrint</title>
5
+ <%= stylesheet_link_tag "fine_print/application", :media => "all" %>
6
+ <%= javascript_include_tag "fine_print/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,53 @@
1
+ # Change the settings below to suit your needs
2
+ # All settings are initially set to their default values
3
+ FinePrint.configure do |config|
4
+
5
+ # Engine Options (initializer only)
6
+
7
+ # Name of the ApplicationController helper method that returns the current user
8
+ # Default: "current_user"
9
+ config.current_user_method = "current_user"
10
+
11
+ # Proc called with user as argument that should return true if and only if the user is an admin
12
+ # Admins can create and edit agreements and terminate accepted agreements
13
+ # Default: lambda { |user| false } (no admins)
14
+ config.user_admin_proc = lambda { |user| false }
15
+
16
+ # Path to redirect users to when an error occurs (e.g. permission denied on admin pages)
17
+ # Default: "/"
18
+ config.redirect_path = "/"
19
+
20
+ # Path to link users to if they need to sign in
21
+ # Set to nil to disable the link
22
+ # Default: "/"
23
+ config.sign_in_path = "/"
24
+
25
+
26
+
27
+ # Agreement Options (initializer or inline)
28
+
29
+ # Message to be displayed to the user explaining that they need to accept an agreement
30
+ # Set to nil to disable
31
+ # Default: "You must accept the following agreement to proceed."
32
+ config.agreement_notice = "You must accept the following agreement to proceed."
33
+
34
+ # Path to redirect users to when an agreement is accepted and referer information is unavailable
35
+ # Default: "/"
36
+ config.accept_path = "/"
37
+
38
+ # Path to redirect users to when an agreement is not accepted and referer information is unavailable
39
+ # Default: "/"
40
+ config.cancel_path = "/"
41
+
42
+ # Whether to use referer information to redirect users after (not) accepting an agreement
43
+ # Default: true
44
+ config.use_referers = true
45
+
46
+ # If set to true, modal jQuery UI dialogs will be used instead of redirecting the user to the agreement page
47
+ # Note: users with javascript disabled will not even see the agreement and will be able to proceed without accepting it
48
+ # if users are not supposed to ever see or interact with a certain page without accepting the agreement,
49
+ # disable this option for that particular controller action
50
+ # Default: false
51
+ config.use_modal_dialogs = false
52
+
53
+ end
@@ -0,0 +1,53 @@
1
+ # Change the settings below to suit your needs
2
+ # All settings are initially set to their default values
3
+ FinePrint.configure do |config|
4
+
5
+ # Engine Options (initializer only)
6
+
7
+ # Name of the ApplicationController helper method that returns the current user
8
+ # Default: "current_user"
9
+ config.current_user_method = "current_user"
10
+
11
+ # Proc called with user as argument that should return true if and only if the user is an admin
12
+ # Admins can create and edit agreements and terminate accepted agreements
13
+ # Default: lambda { |user| false } (no admins)
14
+ config.user_admin_proc = lambda { |user| false }
15
+
16
+ # Path to redirect users to when an error occurs (e.g. permission denied on admin pages)
17
+ # Default: "/"
18
+ config.redirect_path = "/"
19
+
20
+ # Path to link users to if they need to sign in
21
+ # Set to nil to disable the link
22
+ # Default: "/"
23
+ config.sign_in_path = "/"
24
+
25
+
26
+
27
+ # Agreement Options (initializer or inline)
28
+
29
+ # Message to be displayed to the user explaining that they need to accept an agreement
30
+ # Set to nil to disable
31
+ # Default: "You must accept the following agreement to proceed."
32
+ config.agreement_notice = "You must accept the following agreement to proceed."
33
+
34
+ # Path to redirect users to when an agreement is accepted and referer information is unavailable
35
+ # Default: "/"
36
+ config.accept_path = "/"
37
+
38
+ # Path to redirect users to when an agreement is not accepted and referer information is unavailable
39
+ # Default: "/"
40
+ config.cancel_path = "/"
41
+
42
+ # Whether to use referer information to redirect users after (not) accepting an agreement
43
+ # Default: true
44
+ config.use_referers = true
45
+
46
+ # If set to true, modal jQuery UI dialogs will be used instead of redirecting the user to the agreement page
47
+ # Note: users with javascript disabled will not even see the agreement and will be able to proceed without accepting it
48
+ # if users are not supposed to ever see or interact with a certain page without accepting the agreement,
49
+ # disable this option for that particular controller action
50
+ # Default: false
51
+ config.use_modal_dialogs = false
52
+
53
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ FinePrint::Engine.routes.draw do
2
+ resources :agreements do
3
+ get :new_version
4
+ end
5
+ resources :user_agreements, :only => [:index, :create, :destroy]
6
+ root :to => 'home#index'
7
+ end
data/config/routes.rb~ ADDED
@@ -0,0 +1,7 @@
1
+ FinePrint::Engine.routes.draw do
2
+ resources :agreements do
3
+ get :new_version
4
+ end
5
+ resources :user_agreements, :only => [:index, :create, :destroy]
6
+ root :to => 'agreements#index'
7
+ end
@@ -0,0 +1,22 @@
1
+ class CreateFinePrintAgreements < ActiveRecord::Migration
2
+ def change
3
+ create_table :fine_print_agreements do |t|
4
+ t.string :name
5
+ t.text :content
6
+ t.integer :version
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ create_table :fine_print_user_agreements do |t|
12
+ t.integer :user_id
13
+ t.integer :agreement_id
14
+
15
+ t.timestamps
16
+ end
17
+
18
+ add_index :fine_print_agreements, [:name, :version]
19
+ add_index :fine_print_user_agreements, [:user_id, :agreement_id]
20
+ add_index :fine_print_user_agreements, :agreement_id
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ class Install < ActiveRecord::Migration
2
+ def change
3
+ create_table :fine_print_agreements do |t|
4
+ t.string :name, :null => false
5
+ t.integer :version, :null => false
6
+ t.text :content, :null => false
7
+ t.string :confirmation_text, :default => 'I have read and agree to the terms and conditions above', :null => false
8
+ t.boolean :display_name, :default => true
9
+ t.boolean :display_version, :default => false
10
+ t.boolean :display_updated, :default => false
11
+ t.boolean :display_confirmation, :default => true
12
+ t.boolean :ready, :default => false
13
+
14
+ t.timestamps
15
+ end
16
+
17
+ create_table :fine_print_user_agreements do |t|
18
+ t.integer :agreement_id, :null => false
19
+ t.references :user, :polymorphic => true, :null => false
20
+
21
+ t.timestamps
22
+ end
23
+
24
+ add_index :fine_print_agreements, [:name, :version]
25
+ add_index :fine_print_user_agreements, :agreement_id
26
+ add_index :fine_print_user_agreements, [:user_id, :user_type, :agreement_id], :name => 'index_fine_print_u_a_on_u_id_and_u_type_and_a_id'
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ class Install < ActiveRecord::Migration
2
+ def change
3
+ create_table :fine_print_agreements do |t|
4
+ t.string :name, :null => false
5
+ t.integer :version, :null => false
6
+ t.text :content, :null => false
7
+ t.string :confirmation_text, :default => 'I have read and agree to the terms and conditions above', :null => false
8
+ t.boolean :display_name, :default => true
9
+ t.boolean :display_version, :default => false
10
+ t.boolean :display_updated, :default => false
11
+ t.boolean :display_confirmation, :default => true
12
+ t.boolean :ready, :default => false
13
+
14
+ t.timestamps
15
+ end
16
+
17
+ create_table :fine_print_user_agreements do |t|
18
+ t.integer :agreement_id, :null => false
19
+ t.references :user, :polymorphic => true
20
+
21
+ t.timestamps
22
+ end
23
+
24
+ add_index :fine_print_agreements, [:name, :version]
25
+ add_index :fine_print_user_agreements, :agreement_id
26
+ add_index :fine_print_user_agreements, [:user_id, :user_type, :agreement_id], :name => 'index_fine_print_u_a_on_u_id_and_u_type_and_a_id'
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ module FinePrint
2
+ module AgreementsHelper
3
+ def fine_print_dialog(options = {})
4
+ render :partial => 'fine_print/agreements/dialog',
5
+ :locals => {:agreements => @fine_print_dialog_agreements,
6
+ :user => @fine_print_user,
7
+ :notice => @fine_print_dialog_notice,
8
+ :width => options[:width],
9
+ :height => options[:height]} \
10
+ unless @fine_print_dialog_agreements.blank?
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module FinePrint
2
+ module AgreementsHelper
3
+ def fine_print_dialog(options = {})
4
+ render :partial => 'fine_print/agreements/dialog',
5
+ :locals => {:agreements => @fine_print_dialog_agreements,
6
+ :user => @fine_print_user,
7
+ :notice => @fine_print_dialog_notice} \
8
+ unless @fine_print_dialog_agreements.blank?
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module FinePrint
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace FinePrint
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ require 'fine_print/agreements_helper'
2
+
3
+ module FinePrint
4
+ module FinePrintAgreement
5
+ def self.included(base)
6
+ base.helper FinePrint::AgreementsHelper
7
+ base.extend(ClassMethods)
8
+ end
9
+
10
+ module ClassMethods
11
+ def fine_print_agreement(*args)
12
+ options = args.last.is_a?(Hash) ? args.pop : {}
13
+ class_eval do
14
+ before_filter(options.except(*FinePrint::AGREEMENT_OPTIONS)) do |controller|
15
+ FinePrint.require_agreements(controller, args, options.slice(*FinePrint::AGREEMENT_OPTIONS))
16
+ end
17
+ end
18
+ end
19
+
20
+ alias_method :fine_print_agreements, :fine_print_agreement
21
+ end
22
+ end
23
+ end
24
+
25
+ ActionController::Base.send :include, FinePrint::FinePrintAgreement
26
+