disclaimer 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +54 -16
- data/config/routes.rb +24 -10
- data/lib/disclaimer/version.rb +1 -1
- data/lib/disclaimer.rb +9 -1
- data/test/dummy/config/initializers/disclaimer.rb +2 -0
- data/test/dummy/config/routes.rb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +1072 -0
- data/test/dummy/log/test.log +9700 -0
- data/test/functional/disclaimer/documents_controller_test.rb +1 -1
- data/test/test_helper.rb +8 -3
- metadata +4 -4
- data/test/dummy/tmp/pids/server.pid +0 -1
data/README.rdoc
CHANGED
@@ -4,7 +4,19 @@ A tool for adding disclaimers to applications.
|
|
4
4
|
|
5
5
|
== Installation
|
6
6
|
|
7
|
-
|
7
|
+
To use this engine:
|
8
|
+
|
9
|
+
=== Gemfile
|
10
|
+
|
11
|
+
Add the following to your Gemfile
|
12
|
+
|
13
|
+
gem 'disclaimer'
|
14
|
+
|
15
|
+
=== Migrations
|
16
|
+
|
17
|
+
To add disclaimer's migrations to the host apps' migrations, run this command:
|
18
|
+
|
19
|
+
rake disclaimer:install:migrations
|
8
20
|
|
9
21
|
=== Routing
|
10
22
|
|
@@ -16,12 +28,15 @@ See test/dummy/config/routes.rb
|
|
16
28
|
|
17
29
|
== Usage
|
18
30
|
|
19
|
-
First create a disclaimer document (see below) and give it a name. (The name is
|
31
|
+
First create a disclaimer document (see below) and give it a name. (The name is
|
32
|
+
in underscore form: like_this).
|
20
33
|
|
21
|
-
Then in your application controller, define the disclaimer you wish to use with
|
34
|
+
Then in your application controller, define the disclaimer you wish to use with
|
35
|
+
'disclaimer(:document_name)'.
|
22
36
|
|
23
|
-
So for example, you have a disclaimer document with the name :our_company_disclaimer
|
24
|
-
|
37
|
+
So for example, you have a disclaimer document with the name :our_company_disclaimer
|
38
|
+
and you want to make sure that everyone who visits your products controller has
|
39
|
+
accepted this disclaimer. Modify the controller like this:
|
25
40
|
|
26
41
|
class ProductsController < ApplicationController
|
27
42
|
|
@@ -32,29 +47,52 @@ everyone who visits your products controller has accepted this disclaimer. Modif
|
|
32
47
|
|
33
48
|
end
|
34
49
|
|
35
|
-
Then when a user navigates to the products controller, they will be redirected
|
50
|
+
Then when a user navigates to the products controller, they will be redirected
|
51
|
+
to the disclaimer document at:
|
36
52
|
|
37
53
|
/disclaimer/documents/our_company_disclaimer
|
38
54
|
|
39
|
-
If they accept the disclaimer, they will be redirected back to the page they were
|
55
|
+
If they accept the disclaimer, they will be redirected back to the page they were
|
56
|
+
originally aiming for.
|
40
57
|
|
41
|
-
The acceptance is stored in session and therefore will be remembered for as long
|
58
|
+
The acceptance is stored in session and therefore will be remembered for as long
|
59
|
+
as the browser is open.
|
42
60
|
|
43
61
|
=== Options
|
44
62
|
|
45
|
-
A before_filter is used to provide this functionality, and you can pass
|
46
|
-
the disclaimer declaration. Therefore, to
|
63
|
+
A before_filter is used to provide this functionality, and you can pass
|
64
|
+
before_filter options through from the disclaimer declaration. Therefore, to
|
65
|
+
only display a disclaimer for the index and show actions in a controller
|
47
66
|
use:
|
48
67
|
|
49
68
|
disclaimer :our_company_disclaimer, :only => [:index, :show]
|
50
69
|
|
51
70
|
== Documents and Segments
|
52
71
|
|
53
|
-
|
54
|
-
many
|
55
|
-
|
72
|
+
Each disclaimer consists of a Disclaimer::Document, and this document can have
|
73
|
+
many Segments. Segments can be shared across many documents.
|
74
|
+
|
75
|
+
== Controller CRUD actions
|
76
|
+
|
77
|
+
By default, documents#show (GET) and documents#accept (POST) are the only acceptable
|
78
|
+
disclaimer actions.
|
79
|
+
|
80
|
+
If you wish to enable all the CRUD actions available in the documents and segments
|
81
|
+
controllers, set Disclaimer.enable_crud! in an initializer. For example, see
|
82
|
+
test/dummy/config/initializers/disclaimer.rb
|
83
|
+
|
84
|
+
With CRUD actions enabled documents can be managed at /disclaimer/documents, and
|
85
|
+
Segments at /disclaimer/segments. If you wish to modify the controller behaviour
|
86
|
+
(for example by adding access control), copy disclaimer's app/disclaimer/controllers
|
87
|
+
to the same location in your application, and modify these copies. The versions
|
88
|
+
in your application will take precedence over those in disclaimer.
|
89
|
+
|
90
|
+
== Into production
|
91
|
+
|
92
|
+
I would recommend using seeding to generate your initial disclaimer documents,
|
93
|
+
or you could create a custom rake task to do this for you. Alternatively use
|
94
|
+
the option used in test/dummy:
|
56
95
|
|
57
|
-
|
58
|
-
the host application. However, everyone needs access to the disclaimer documents#show action so that they can read
|
59
|
-
and accept the disclaimer.
|
96
|
+
disclaimer Disclaimer::Document.first.name.to_sym
|
60
97
|
|
98
|
+
This will display the first disclaimer document in your database.
|
data/config/routes.rb
CHANGED
@@ -1,18 +1,32 @@
|
|
1
1
|
Disclaimer::Engine.routes.draw do
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
if Disclaimer.enable_crud?
|
4
|
+
root :to => "documents#index"
|
5
|
+
|
6
|
+
resources :documents do
|
7
|
+
member do
|
8
|
+
get :delete
|
9
|
+
post :accept
|
10
|
+
end
|
9
11
|
end
|
10
|
-
|
12
|
+
|
13
|
+
resources :segments do
|
14
|
+
member do
|
15
|
+
get :delete
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
else
|
11
20
|
|
12
|
-
|
13
|
-
|
14
|
-
|
21
|
+
resources :documents, :only => :show do
|
22
|
+
member do
|
23
|
+
post :accept
|
24
|
+
end
|
15
25
|
end
|
26
|
+
|
27
|
+
|
28
|
+
|
16
29
|
end
|
30
|
+
|
17
31
|
|
18
32
|
end
|
data/lib/disclaimer/version.rb
CHANGED
data/lib/disclaimer.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
require "disclaimer/engine"
|
2
|
-
require 'rails/actionpack/lib/action_controller/base'
|
2
|
+
require File.expand_path('rails/actionpack/lib/action_controller/base', File.dirname(__FILE__))
|
3
3
|
|
4
4
|
module Disclaimer
|
5
5
|
ACCEPTED = :accepted
|
6
|
+
|
7
|
+
def self.enable_crud?
|
8
|
+
@enable_crud
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.enable_crud!
|
12
|
+
@enable_crud = true
|
13
|
+
end
|
6
14
|
end
|
data/test/dummy/config/routes.rb
CHANGED
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|