smart_titles 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,49 +1,48 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_titles (0.3.0)
4
+ smart_titles (0.3.2)
5
5
  actionpack
6
6
  activesupport
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionpack (3.1.3)
12
- activemodel (= 3.1.3)
13
- activesupport (= 3.1.3)
11
+ actionpack (3.2.9)
12
+ activemodel (= 3.2.9)
13
+ activesupport (= 3.2.9)
14
14
  builder (~> 3.0.0)
15
15
  erubis (~> 2.7.0)
16
- i18n (~> 0.6)
17
- rack (~> 1.3.5)
18
- rack-cache (~> 1.1)
19
- rack-mount (~> 0.8.2)
16
+ journey (~> 1.0.4)
17
+ rack (~> 1.4.0)
18
+ rack-cache (~> 1.2)
20
19
  rack-test (~> 0.6.1)
21
- sprockets (~> 2.0.3)
22
- activemodel (3.1.3)
23
- activesupport (= 3.1.3)
20
+ sprockets (~> 2.2.1)
21
+ activemodel (3.2.9)
22
+ activesupport (= 3.2.9)
24
23
  builder (~> 3.0.0)
24
+ activesupport (3.2.9)
25
25
  i18n (~> 0.6)
26
- activesupport (3.1.3)
27
26
  multi_json (~> 1.0)
28
- builder (3.0.0)
27
+ builder (3.0.4)
29
28
  erubis (2.7.0)
30
29
  guard (0.8.8)
31
30
  thor (~> 0.14.6)
32
31
  guard-minitest (0.4.0)
33
32
  guard (~> 0.4)
34
33
  hike (1.2.1)
35
- i18n (0.6.0)
36
- multi_json (1.0.4)
37
- rack (1.3.5)
38
- rack-cache (1.1)
34
+ i18n (0.6.1)
35
+ journey (1.0.4)
36
+ multi_json (1.3.7)
37
+ rack (1.4.1)
38
+ rack-cache (1.2)
39
39
  rack (>= 0.4)
40
- rack-mount (0.8.3)
41
- rack (>= 1.0.0)
42
- rack-test (0.6.1)
40
+ rack-test (0.6.2)
43
41
  rack (>= 1.0)
44
42
  rake (0.9.2.2)
45
- sprockets (2.0.3)
43
+ sprockets (2.2.1)
46
44
  hike (~> 1.2)
45
+ multi_json (~> 1.0)
47
46
  rack (~> 1.0)
48
47
  tilt (~> 1.1, != 1.3.0)
49
48
  thor (0.14.6)
data/Readme.md CHANGED
@@ -76,6 +76,9 @@ And now products#index page will have "Products from the Coolest Store" browser'
76
76
 
77
77
  Changelog
78
78
  ---
79
+ ### 0.3.2
80
+ Page title is no longer double-escaped.
81
+
79
82
  ### 0.3.0
80
83
  * Important change in the documentation: you have to call `title` with no arguments when you want to use translated title.
81
84
  * Fixed bug when `head_title` returned default title even if there was a custom title in locale.
@@ -29,7 +29,9 @@ module SmartTitles
29
29
  # * Set custom title for the current page if it is passed. Otherwise the title will be automatically set
30
30
  # * Return the title passed or looked up from locale wrapped into h1 tag
31
31
  def title(custom_title = nil)
32
- provide(:page_title, custom_title || page_title)
32
+ title = custom_title || page_title
33
+ title &&= title.html_safe
34
+ provide(:page_title, title)
33
35
  content_tag(:h1, page_title) if page_title
34
36
  end
35
37
 
@@ -1,3 +1,3 @@
1
1
  module SmartTitles
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -94,6 +94,19 @@ class SmartTitlesHelperTest < ActionView::TestCase
94
94
  assert_equal "My Website", head_title
95
95
  end
96
96
 
97
+
98
+ def test_head_title_template_is_escaped
99
+ store_translations title_template: '"%{title}"'
100
+ title 'New post'
101
+ assert_equal '&quot;New post&quot;', h(head_title)
102
+ end
103
+
104
+ def test_head_title_is_not_double_escaped
105
+ title 'New "post"'
106
+ assert_equal 'New &quot;post&quot;', h(head_title)
107
+ end
108
+
109
+
97
110
  private
98
111
 
99
112
  # Virtual path is used by Rails-patched version of I18n.translate
@@ -140,4 +153,8 @@ private
140
153
  store_translations title_template: "d %{title} b"
141
154
  end
142
155
 
156
+ def h(s)
157
+ ERB::Util.html_escape(s)
158
+ end
159
+
143
160
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_titles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-19 00:00:00.000000000 Z
12
+ date: 2012-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -100,10 +100,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 1.8.23
103
+ rubygems_version: 1.8.24
104
104
  signing_key:
105
105
  specification_version: 3
106
106
  summary: Really convenient way to set up page titles in a Rails application.
107
107
  test_files:
108
108
  - test/smart_titles/helper_test.rb
109
109
  - test/test_helper.rb
110
+ has_rdoc: