ominous 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -71,26 +71,19 @@ For example:
71
71
 
72
72
  == Warning text
73
73
 
74
- Warnings contain a title and description. Closers contain a message and a link.
75
- The text used for each needs to be defined in your locale file.
76
-
77
- For the something_happened warning used above
78
- the entry needs to look like this:
79
-
80
- en:
81
-
82
- ominous:
83
- warning:
84
- something_happened:
85
- title: Warning
86
- description: You have triggered a warning.
87
- closer_one:
88
- message: This is the first closer
89
- link: Click here to activate closer_one
90
- closer_two:
91
- message: This is the second closer
92
- link: Click here to activate closer_two
74
+ Warnings contain a title and description. Closers contain a message and link_text.
75
+ These elements will be displayed within the warning message. See:
93
76
 
77
+ app/views/ominous/warnings/_list.html.erb
78
+
79
+ Default text will appear if these fields are empty. These defaults being the
80
+ minimum needed to generate a usable warning message.
81
+
82
+ If warning#title is blank, a humanized version of the warning name will be
83
+ displayed.
84
+
85
+ If closer.link_text is blank, the closer's link text will be constructed from
86
+ the closure_method.
94
87
 
95
88
  == Managing warnings
96
89
 
@@ -11,7 +11,7 @@ module Ominous
11
11
  end
12
12
 
13
13
  def closer_link_to(warning, closer)
14
- text = t("ominous.warning.#{warning.name}.#{closer.name}.link")
14
+ text = closer.link_text
15
15
  link_class = closer.closure_method
16
16
  url = closer_url(warning, closer)
17
17
  link_to(text, url, :method => :put, :class => link_class)
@@ -1,6 +1,6 @@
1
1
  module Ominous
2
2
  class Closer < ActiveRecord::Base
3
- attr_accessible :name, :url, :closure_method, :start_hidden
3
+ attr_accessible :name, :url, :closure_method, :start_hidden, :message, :link_text
4
4
 
5
5
  CLOSURE_METHODS = {
6
6
  :reveal_hidden => 'Hides the current closers and reveals any hidden closers',
@@ -14,6 +14,10 @@ module Ominous
14
14
  def self.closure_methods
15
15
  CLOSURE_METHODS
16
16
  end
17
+
18
+ def link_text
19
+ super.blank? ? "click here to #{closure_method}".humanize : super
20
+ end
17
21
 
18
22
  end
19
23
  end
@@ -1,6 +1,6 @@
1
1
  module Ominous
2
2
  class Warning < ActiveRecord::Base
3
- attr_accessible :name, :closers_attributes
3
+ attr_accessible :name, :closers_attributes, :title, :description
4
4
 
5
5
  validates :name, :presence => true
6
6
 
@@ -39,6 +39,10 @@ module Ominous
39
39
  clear_requests # So that warnings called while processing one action are not carried over to the next where they may not be relevant
40
40
  end
41
41
 
42
+ def title
43
+ super.blank? ? name.humanize : super
44
+ end
45
+
42
46
  private
43
47
  def method_missing(symbol, *args, &block)
44
48
  if acts_as_list_method?(symbol)
@@ -1,15 +1,15 @@
1
1
  <% warnings.each do |warning| %>
2
2
  <div class="warning">
3
3
  <div class="heading">
4
- <h2><%= t("ominous.warning.#{warning.name}.title") %></h2>
4
+ <h2><%= warning.title %></h2>
5
5
  </div>
6
6
  <div class="description">
7
- <%= t("ominous.warning.#{warning.name}.description") %>
7
+ <%= sanitize warning.description %>
8
8
  </div>
9
9
  <div class="closers">
10
10
  <% warning.closers.each do |closer| %>
11
11
  <div class="<%= classes_for(closer) %>">
12
- <p><%= t("ominous.warning.#{warning.name}.#{closer.name}.message") %></p>
12
+ <p><%= sanitize closer.message %></p>
13
13
  <p>
14
14
  <%= closer_link_to(warning, closer) %>
15
15
  </p>
@@ -0,0 +1,6 @@
1
+ class AddTitleAndDescriptionToOminousWarnings < ActiveRecord::Migration
2
+ def change
3
+ add_column :ominous_warnings, :title, :string
4
+ add_column :ominous_warnings, :description, :text
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddLinkTextAndMessageToOminousClosers < ActiveRecord::Migration
2
+ def change
3
+ add_column :ominous_closers, :link_text, :string
4
+ add_column :ominous_closers, :message, :text
5
+ end
6
+ end
@@ -1,3 +1,28 @@
1
1
  module Ominous
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
4
+
5
+ # History
6
+ # =======
7
+ #
8
+ # 0.0.5
9
+ # -----
10
+ # Moved text decoration of warnings and closers to models.
11
+ #
12
+ # Upgrading to this version requires a migration:
13
+ #
14
+ # rake ominous:install:migrations
15
+ # rake db:migrate
16
+ #
17
+ # In use, the separation of text (in translations) from the warning objects was
18
+ # confusing. It proved difficult for users to create new warning, and match them
19
+ # to translations.
20
+ #
21
+ # By using a more standard arrangement, translation options can be added to the
22
+ # host app, where all text output can be handled the same way, and therefore
23
+ # users will be familiar with the process of updating text.
24
+ #
25
+ # 0.0.4
26
+ # -----
27
+ # First working version. No history before this version.
28
+ #
@@ -1,18 +1,17 @@
1
1
 
2
2
  defaults: &defaults
3
- adapter: mysql2
4
- username: rails_app
5
- password: GTYHdse23B
6
- host: localhost
3
+ adapter: sqlite3
4
+ pool: 5
5
+ timeout: 5000
7
6
 
8
7
  development:
9
8
  <<: *defaults
10
- database: ominous_development
9
+ database: db/development.sqlite3
11
10
 
12
11
  test:
13
12
  <<: *defaults
14
- database: ominous_test
13
+ database: db/test.sqlite3
15
14
 
16
15
  production:
17
16
  <<: *defaults
18
- database: ominous
17
+ database: db/production.sqlite3
@@ -3,18 +3,3 @@
3
3
 
4
4
  en:
5
5
  hello: "Hello world"
6
-
7
- ominous:
8
- warning:
9
- thing_alert:
10
- title: Warning
11
- description: You have viewed a Thing with it's warning set.
12
- closer_one:
13
- message: This should not appear initially
14
- link: Click here to close the warning and tell the server not to show it again
15
- closer_two:
16
- message: This will redirect to another site
17
- link: Click to go elsewhere
18
- closer_three:
19
- message: This should appear initially
20
- link: Click here to see hidden closers
Binary file
@@ -0,0 +1,9 @@
1
+ # This migration comes from ominous (originally 20121206144249)
2
+ class CreateOminousWarnings < ActiveRecord::Migration
3
+ def change
4
+ create_table :ominous_warnings do |t|
5
+ t.column :name, :string
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # This migration comes from ominous (originally 20121206145743)
2
+ class CreateOminousWarningClosers < ActiveRecord::Migration
3
+ def change
4
+ create_table :ominous_warning_closers do |t|
5
+ t.column :warning_id, :integer
6
+ t.column :closer_id, :integer
7
+ t.column :position, :integer
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ # This migration comes from ominous (originally 20121206153254)
2
+ class CreateOminousClosers < ActiveRecord::Migration
3
+ def change
4
+ create_table :ominous_closers do |t|
5
+ t.column :name, :string
6
+ t.column :url, :string
7
+ t.column :closure_method, :string, :limit => 30
8
+ t.column :start_hidden, :boolean, :default => false
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ # This migration comes from ominous (originally 20130131131756)
2
+ class AddTitleAndDescriptionToOminousWarnings < ActiveRecord::Migration
3
+ def change
4
+ add_column :ominous_warnings, :title, :string
5
+ add_column :ominous_warnings, :description, :text
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # This migration comes from ominous (originally 20130131131934)
2
+ class AddLinkTextAndMessageToOminousClosers < ActiveRecord::Migration
3
+ def change
4
+ add_column :ominous_closers, :link_text, :string
5
+ add_column :ominous_closers, :message, :text
6
+ end
7
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20121207090710) do
14
+ ActiveRecord::Schema.define(:version => 20130131134024) do
15
15
 
16
16
  create_table "ominous_closers", :force => true do |t|
17
17
  t.string "name"
@@ -20,6 +20,8 @@ ActiveRecord::Schema.define(:version => 20121207090710) do
20
20
  t.boolean "start_hidden", :default => false
21
21
  t.datetime "created_at", :null => false
22
22
  t.datetime "updated_at", :null => false
23
+ t.string "link_text"
24
+ t.text "message"
23
25
  end
24
26
 
25
27
  create_table "ominous_warning_closers", :force => true do |t|
@@ -32,8 +34,10 @@ ActiveRecord::Schema.define(:version => 20121207090710) do
32
34
 
33
35
  create_table "ominous_warnings", :force => true do |t|
34
36
  t.string "name"
35
- t.datetime "created_at", :null => false
36
- t.datetime "updated_at", :null => false
37
+ t.datetime "created_at", :null => false
38
+ t.datetime "updated_at", :null => false
39
+ t.string "title"
40
+ t.text "description"
37
41
  end
38
42
 
39
43
  create_table "things", :force => true do |t|
@@ -1,11 +1,16 @@
1
1
  closer_one:
2
2
  closure_method: close_and_dismiss_warning
3
3
  start_hidden: true
4
+ message: This should not appear initially
5
+ link_text: Click here to close the warning and tell the server not to show it again
4
6
 
5
7
  closer_two:
6
8
  url: http://undervale.co.uk
7
9
  closure_method: redirect
10
+ message: This will redirect to another site
11
+ link_text: Click to go elsewhere
8
12
 
9
13
  closer_three:
10
14
  closure_method: reveal_hidden
11
-
15
+ message: This should appear initially
16
+ link_text: Click here to see hidden closers
@@ -1 +1,3 @@
1
- thing_alert:
1
+ thing_alert:
2
+ title: Warning
3
+ description: You have viewed a Thing with it's warning set.
Binary file