refinerycms-copywriting 1.0.6 → 1.0.7
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.
@@ -1,11 +1,14 @@
|
|
1
1
|
module CopywritingHelper
|
2
2
|
|
3
3
|
def copywriting(name, options = {}, &block)
|
4
|
+
options = @copywriting_options.merge(options) if @copywriting_options
|
4
5
|
options[:default] = block_given? ? capture(&block) : options[:default]
|
5
|
-
|
6
|
-
result = ::CopywritingPhrase.for(name, options)
|
7
|
-
|
8
|
-
options[:html_safe] ? result.html_safe : result
|
6
|
+
::CopywritingPhrase.for(name, options)
|
9
7
|
end
|
10
8
|
|
9
|
+
def copywriting_options(options, &block)
|
10
|
+
@copywriting_options = options
|
11
|
+
yield
|
12
|
+
@copywriting_options = nil
|
13
|
+
end
|
11
14
|
end
|
@@ -14,7 +14,6 @@ class CopywritingPhrase < ActiveRecord::Base
|
|
14
14
|
phrase = self.create(:name => name,
|
15
15
|
:scope => options[:scope],
|
16
16
|
:default => options[:default],
|
17
|
-
:value => options[:value],
|
18
17
|
:page_id => (options[:page].try(:id) || options[:page_id] || nil),
|
19
18
|
:phrase_type => options[:phrase_type])
|
20
19
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
<div class='field'>
|
2
2
|
<%= f.label :value, f.object.name.capitalize -%>
|
3
|
+
<% value = f.object.default_or_value %>
|
3
4
|
<% case f.object.phrase_type %>
|
4
5
|
<% when "text" %>
|
5
|
-
<%= f.text_area :value, :rows => 12, :class => 'widest' -%>
|
6
|
+
<%= f.text_area :value, :value => value, :rows => 12, :class => 'widest' -%>
|
6
7
|
<% when "wysiwyg" %>
|
7
|
-
<%= f.text_area :value, :rows => 5, :class => 'widest wymeditor' -%>
|
8
|
+
<%= f.text_area :value, :value => value, :rows => 5, :class => 'widest wymeditor' -%>
|
8
9
|
<% else %>
|
9
|
-
<%= f.text_field :value, :class => 'widest larger' -%>
|
10
|
+
<%= f.text_field :value, :value => value, :class => 'widest larger' -%>
|
10
11
|
<% end %>
|
11
12
|
</div>
|
@@ -24,7 +24,32 @@ describe CopywritingHelper do
|
|
24
24
|
|
25
25
|
copywriting("test block").should == block_text
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
|
+
it "it should allow you to set default options with copywriting_options block" do
|
29
|
+
copywriting_options({:scope => 'default_scope'}) do
|
30
|
+
copywriting("test with default scope")
|
31
|
+
end
|
32
|
+
|
33
|
+
CopywritingPhrase.where(:name => "test with default scope").scope.should == 'default_scope'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "it should allow you to overwrite the default options set with copywriting_options block" do
|
37
|
+
copywriting_options({:scope => 'default_scope'}) do
|
38
|
+
copywriting("test without default scope", {:scope => 'without_default_scope'})
|
39
|
+
end
|
40
|
+
|
41
|
+
CopywritingPhrase.where(:name => "test without default scope").scope.should == 'without_default_scope'
|
42
|
+
end
|
43
|
+
|
44
|
+
it "it should clear the default options after copywriting_options block" do
|
45
|
+
copywriting_options({:scope => 'default_scope'}) do
|
46
|
+
copywriting("test with default scope")
|
47
|
+
end
|
48
|
+
copywriting("test outside default scope")
|
49
|
+
|
50
|
+
CopywritingPhrase.where(:name => "test outside default scope").scope.should_not == 'default_scope'
|
51
|
+
end
|
52
|
+
|
28
53
|
end
|
29
54
|
|
30
55
|
end
|
metadata
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-copywriting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 7
|
10
|
+
version: 1.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Charles Barbier
|
14
|
+
- David Jones
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2011-07-
|
19
|
+
date: 2011-07-08 00:00:00 Z
|
19
20
|
dependencies: []
|
20
21
|
|
21
22
|
description: Extract all your strings and leave no human word behind, with i18n
|