tophat 1.7.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -42
- data/lib/tophat/opengraph.rb +4 -11
- data/lib/tophat/stylesheet.rb +14 -14
- data/lib/tophat/title.rb +45 -44
- data/lib/tophat/twitter_card.rb +5 -7
- data/lib/tophat/version.rb +1 -1
- data/spec/tophat/opengraph_helper_spec.rb +18 -27
- data/spec/tophat/twitter_card_helper_spec.rb +29 -19
- data/spec/tophat_spec.rb +55 -57
- metadata +4 -4
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
# TopHat
|
1
|
+
# TopHat [![Build Status](https://secure.travis-ci.org/spagalloco/tophat.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/spagalloco/tophat.png?travis)][gemnasium]
|
2
|
+
|
3
|
+
[travis]: http://travis-ci.org/spagalloco/tophat
|
4
|
+
[gemnasium]: https://gemnasium.com/spagalloco/tophat
|
2
5
|
|
3
6
|
TopHat is a set of view helpers to keep your layouts and views DRY. Easily include meta tags like keywords and descriptions, Open Graph and Twitter Cards in your Rails views.
|
4
7
|
|
@@ -37,7 +40,7 @@ When rendered, the page title will be included in your view.
|
|
37
40
|
Use these options to customize the title format:
|
38
41
|
|
39
42
|
* `:prefix` (text between site name and separator) [default: '']
|
40
|
-
* `:separator` (text used to separate website name from page title
|
43
|
+
* `:separator` (text used to separate website name from page title) [default: '']
|
41
44
|
* `:suffix` (text between separator and page title) [default: ' ']
|
42
45
|
* `:lowercase` (when true, the entire title will be lowercase)
|
43
46
|
* `:uppercase` (when true, the entire title will be uppercase)
|
@@ -78,16 +81,16 @@ which will output the meta-tags:
|
|
78
81
|
<meta name="keywords" content="John, Paul, George, Ringo" />
|
79
82
|
<meta name="description" content="You say goodbye, I say hello." />
|
80
83
|
|
81
|
-
|
84
|
+
Keywords and descriptions can also take a default in the layout:
|
82
85
|
|
83
86
|
<%= keywords :default => 'Yoko, Linda' %>
|
84
87
|
<%= description :default => 'default description if none is passed' %>
|
85
88
|
|
86
|
-
|
89
|
+
Want to merge your default tags with those in your view? just pass `merge_default => true`
|
87
90
|
|
88
91
|
<%= keywords :default => 'Yoko, Linda', :merge_default => true %>
|
89
92
|
|
90
|
-
There are also convenience methods for
|
93
|
+
There are also convenience methods for common meta tags:
|
91
94
|
|
92
95
|
<%= noindex() %> # outputs: <meta content="noindex" name="robots" />
|
93
96
|
<%= noindex('googlebot') # outputs: <meta content="noindex" name="googlebot" />
|
@@ -97,7 +100,7 @@ There are also convenience methods for a few common meta tags:
|
|
97
100
|
|
98
101
|
## Browser Conditionals
|
99
102
|
|
100
|
-
TopHat can generate a lot of different browser conditional comments
|
103
|
+
TopHat can generate a lot of different browser conditional comments:
|
101
104
|
|
102
105
|
ie_5_conditional do
|
103
106
|
stylesheet_link_tag 'ie'
|
@@ -124,9 +127,9 @@ A lot of browsers are supported, check the code for the full listing.
|
|
124
127
|
|
125
128
|
TopHat can also generate Facebook OpenGraph tags. In your views, you can assign any number of attributes by passing a block to the opengraph helper. This will store the attributes for that page.
|
126
129
|
|
127
|
-
opengraph do
|
128
|
-
title 'Rain Man'
|
129
|
-
type 'Movie'
|
130
|
+
opengraph do |graph|
|
131
|
+
graph.title 'Rain Man'
|
132
|
+
graph.type 'Movie'
|
130
133
|
end
|
131
134
|
|
132
135
|
To embed OpenGraph tags on your page, you'll need to reference opengraph in your layout.
|
@@ -150,30 +153,23 @@ There's also a helper for the html tag along with the opengraph namespaces:
|
|
150
153
|
|
151
154
|
Note: TopHat does not include a "Like" button helper. TopHat's focus is inside the `<head>` tag.
|
152
155
|
|
153
|
-
TopHat previously supported a different syntax for defining the opengraph which has been deprecated:
|
154
|
-
|
155
|
-
opengraph do |graph|
|
156
|
-
graph.title 'Rain Man'
|
157
|
-
graph.type 'Movie'
|
158
|
-
end
|
159
|
-
|
160
156
|
## Twitter Card Helpers
|
161
157
|
|
162
158
|
TopHat has support for [Twitter Cards](https://dev.twitter.com/docs/cards).
|
163
159
|
|
164
|
-
twitter_card('summary') do
|
165
|
-
url 'http://mysite.com/page'
|
166
|
-
title 'this is my page title'
|
167
|
-
description 'some interesting info about my page'
|
168
|
-
image 'http://mysite.com/animage.jpg'
|
160
|
+
twitter_card('summary') do |card|
|
161
|
+
card.url 'http://mysite.com/page'
|
162
|
+
card.title 'this is my page title'
|
163
|
+
card.description 'some interesting info about my page'
|
164
|
+
card.image 'http://mysite.com/animage.jpg'
|
169
165
|
end
|
170
166
|
|
171
167
|
You can nest attributes inside a twitter card:
|
172
168
|
|
173
|
-
twitter_card('player') do
|
174
|
-
player 'https://example.com/embed/a' do
|
175
|
-
height '251'
|
176
|
-
width '435'
|
169
|
+
twitter_card('player') do |card|
|
170
|
+
card.player 'https://example.com/embed/a' do |player|
|
171
|
+
player.height '251'
|
172
|
+
player.width '435'
|
177
173
|
end
|
178
174
|
end
|
179
175
|
|
@@ -188,25 +184,9 @@ To render the twitter card in your layout, simply call the twitter_card helper w
|
|
188
184
|
|
189
185
|
<%= twitter_card %>
|
190
186
|
|
191
|
-
## <a name="build"></a>Build Status
|
192
|
-
[![Build Status](https://secure.travis-ci.org/spagalloco/tophat.png?branch=master)][travis]
|
193
|
-
|
194
|
-
[travis]: http://travis-ci.org/spagalloco/tophat
|
195
|
-
|
196
|
-
## <a name="dependencies"></a>Dependency Status
|
197
|
-
[![Dependency Status](https://gemnasium.com/spagalloco/tophat.png?travis)][gemnasium]
|
198
|
-
|
199
|
-
[gemnasium]: https://gemnasium.com/spagalloco/tophat
|
200
|
-
|
201
187
|
## Contributing
|
202
188
|
|
203
|
-
*
|
204
|
-
* Make your feature addition or bug fix.
|
205
|
-
* Add tests for it. This is important so I don't break it in a
|
206
|
-
future version unintentionally.
|
207
|
-
* Commit, do not mess with rakefile, version, or history.
|
208
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
209
|
-
* Send me a pull request. Bonus points for topic branches.
|
189
|
+
Pull requests welcome: fork, make a topic branch, commit (squash when possible) *with tests* and I'll happily consider.
|
210
190
|
|
211
191
|
## Copyright
|
212
192
|
|
data/lib/tophat/opengraph.rb
CHANGED
@@ -4,10 +4,12 @@ module TopHat
|
|
4
4
|
class OpenGraphGenerator
|
5
5
|
include ActionView::Helpers
|
6
6
|
|
7
|
-
def initialize(options={})
|
7
|
+
def initialize(options={}, &block)
|
8
8
|
@app_id = options.delete(:app_id) if options && options.has_key?(:app_id)
|
9
9
|
@admins = options.delete(:admins) if options && options.has_key?(:admins)
|
10
10
|
@graph_data = {}
|
11
|
+
|
12
|
+
yield self if block_given?
|
11
13
|
end
|
12
14
|
|
13
15
|
def merge(options={})
|
@@ -79,16 +81,7 @@ module TopHat
|
|
79
81
|
TopHat.current['open_graph_defaults'] = options
|
80
82
|
end
|
81
83
|
if block_given?
|
82
|
-
|
83
|
-
Kernel.warn("passing the graph object into the opengraph method has been deprecated, see README for details.")
|
84
|
-
|
85
|
-
TopHat.current['open_graph_generator'] = OpenGraphGenerator.new(TopHat.current['open_graph_defaults'])
|
86
|
-
yield(TopHat.current['open_graph_generator'])
|
87
|
-
else
|
88
|
-
opengraph_generator = OpenGraphGenerator.new(TopHat.current['open_graph_defaults'])
|
89
|
-
opengraph_generator.instance_eval(&block)
|
90
|
-
TopHat.current['open_graph_generator'] = opengraph_generator
|
91
|
-
end
|
84
|
+
TopHat.current['open_graph_generator'] = OpenGraphGenerator.new(TopHat.current['open_graph_defaults'], &block)
|
92
85
|
else
|
93
86
|
TopHat.current['open_graph_generator'] ||= OpenGraphGenerator.new
|
94
87
|
TopHat.current['open_graph_generator'].merge(TopHat.current['open_graph_defaults'])
|
data/lib/tophat/stylesheet.rb
CHANGED
@@ -67,21 +67,21 @@ module TopHat
|
|
67
67
|
|
68
68
|
private
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
browser_version = version.blank? ? "" : " #{version}"
|
78
|
-
|
79
|
-
output = ActiveSupport::SafeBuffer.new("<!--[if #{operator}#{browser}#{browser_version}]>")
|
80
|
-
output << "\n".html_safe
|
81
|
-
output << yield if block_given?
|
82
|
-
output << "\n".html_safe
|
83
|
-
output << "<![endif]-->".html_safe
|
70
|
+
def browser_conditional(browser, version = nil, operator = nil, &block)
|
71
|
+
unless operator.blank?
|
72
|
+
operator = operator.to_s
|
73
|
+
operator = '!' if operator == 'not'
|
74
|
+
operator << " " unless operator == '!'
|
84
75
|
end
|
85
76
|
|
77
|
+
browser_version = version.blank? ? "" : " #{version}"
|
78
|
+
|
79
|
+
output = ActiveSupport::SafeBuffer.new("<!--[if #{operator}#{browser}#{browser_version}]>")
|
80
|
+
output << "\n".html_safe
|
81
|
+
output << yield if block_given?
|
82
|
+
output << "\n".html_safe
|
83
|
+
output << "<![endif]-->".html_safe
|
84
|
+
end
|
85
|
+
|
86
86
|
end
|
87
87
|
end
|
data/lib/tophat/title.rb
CHANGED
@@ -8,62 +8,63 @@ module TopHat
|
|
8
8
|
display_tophat_title(title || options)
|
9
9
|
end
|
10
10
|
end
|
11
|
-
|
11
|
+
alias t title
|
12
|
+
|
12
13
|
private
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def display_tophat_title(options)
|
21
|
-
options = options.merge(TopHat.current['title_options']) unless TopHat.current['title_options'].nil?
|
15
|
+
def save_tophat_title(title, options)
|
16
|
+
TopHat.current['title'] = title
|
17
|
+
TopHat.current['title_options'] = options
|
18
|
+
title
|
19
|
+
end
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
title_segments << (TopHat.current['title'].blank? ? options[:default] : TopHat.current['title'])
|
21
|
+
def display_tophat_title(options)
|
22
|
+
options = options.merge(TopHat.current['title_options']) unless TopHat.current['title_options'].nil?
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
title_segments.map! { |t| t.upcase! } if options[:uppercase]
|
31
|
-
title_segments.map! { |t| strip_tags(t) }
|
24
|
+
title_segments = []
|
25
|
+
title_segments << options[:site] if options[:site]
|
26
|
+
title_segments << (TopHat.current['title'].blank? ? options[:default] : TopHat.current['title'])
|
32
27
|
|
33
|
-
|
34
|
-
|
28
|
+
title_segments.flatten! # flatten out in case the title is an array
|
29
|
+
title_segments.compact! # clean out any nils
|
30
|
+
title_segments.map! { |t| t.downcase! } if options[:lowercase]
|
31
|
+
title_segments.map! { |t| t.upcase! } if options[:uppercase]
|
32
|
+
title_segments.map! { |t| strip_tags(t) }
|
35
33
|
|
36
|
-
|
34
|
+
reverse = options[:reverse]
|
35
|
+
reverse = false if options[:default] && TopHat.current['title'].blank? && options[:reverse_on_default] == false
|
37
36
|
|
38
|
-
|
39
|
-
end
|
40
|
-
alias t title
|
37
|
+
title_segments.reverse! if reverse
|
41
38
|
|
42
|
-
|
43
|
-
|
39
|
+
content_tag :title, title_segments.join(delimiter_from(options)).strip
|
40
|
+
end
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
prefix = options[:prefix]
|
48
|
-
elsif options[:prefix] == false
|
49
|
-
prefix = ''
|
50
|
-
else
|
51
|
-
prefix = ' '
|
52
|
-
end
|
42
|
+
def delimiter_from(options={})
|
43
|
+
return "" if options.empty?
|
53
44
|
|
54
|
-
|
55
|
-
|
45
|
+
# Prefix (leading space)
|
46
|
+
if options[:prefix]
|
47
|
+
prefix = options[:prefix]
|
48
|
+
elsif options[:prefix] == false
|
49
|
+
prefix = ''
|
50
|
+
else
|
51
|
+
prefix = ' '
|
52
|
+
end
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
suffix = options[:suffix]
|
60
|
-
elsif options[:suffix] == false
|
61
|
-
suffix = ''
|
62
|
-
else
|
63
|
-
suffix = ' '
|
64
|
-
end
|
54
|
+
# Separator
|
55
|
+
separator = options[:separator] || ''
|
65
56
|
|
66
|
-
|
57
|
+
# Suffix (trailing space)
|
58
|
+
if options[:suffix]
|
59
|
+
suffix = options[:suffix]
|
60
|
+
elsif options[:suffix] == false
|
61
|
+
suffix = ''
|
62
|
+
else
|
63
|
+
suffix = ' '
|
67
64
|
end
|
65
|
+
|
66
|
+
prefix + separator + suffix
|
67
|
+
end
|
68
|
+
|
68
69
|
end
|
69
70
|
end
|
data/lib/tophat/twitter_card.rb
CHANGED
@@ -6,9 +6,11 @@ module TopHat
|
|
6
6
|
|
7
7
|
attr_reader :card_data
|
8
8
|
|
9
|
-
def initialize(type)
|
9
|
+
def initialize(type, &block)
|
10
10
|
@type = type
|
11
11
|
@card_data = {}
|
12
|
+
|
13
|
+
yield self if block_given?
|
12
14
|
end
|
13
15
|
|
14
16
|
def render
|
@@ -23,8 +25,7 @@ module TopHat
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def add_nested_attributes(method, &block)
|
26
|
-
image_generator = TwitterCardGenerator.new(method)
|
27
|
-
image_generator.instance_eval(&block) if block_given?
|
28
|
+
image_generator = TwitterCardGenerator.new(method, &block)
|
28
29
|
image_generator.card_data.each do |key, value|
|
29
30
|
@card_data["#{method}:#{key}"] = value
|
30
31
|
end
|
@@ -43,10 +44,7 @@ module TopHat
|
|
43
44
|
TopHat.current['twitter_card'].render
|
44
45
|
end
|
45
46
|
else
|
46
|
-
|
47
|
-
card_generator.instance_eval(&block) if block_given?
|
48
|
-
|
49
|
-
TopHat.current['twitter_card'] = card_generator
|
47
|
+
TopHat.current['twitter_card'] = TwitterCardGenerator.new(type, &block)
|
50
48
|
end
|
51
49
|
end
|
52
50
|
end
|
data/lib/tophat/version.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe TopHat::OpenGraphHelper do
|
4
|
+
before(:all) do
|
5
|
+
@title = 'Rain Man'
|
6
|
+
@type = 'movie'
|
7
|
+
end
|
4
8
|
|
5
9
|
before(:each) do
|
6
10
|
@template = ActionView::Base.new
|
@@ -61,20 +65,20 @@ describe TopHat::OpenGraphHelper do
|
|
61
65
|
|
62
66
|
context "additional open graph properties" do
|
63
67
|
it "generates opengraph meta tags" do
|
64
|
-
@template.opengraph { title 'The Great Gatsby' }
|
68
|
+
@template.opengraph { |og| og.title 'The Great Gatsby' }
|
65
69
|
@template.opengraph.should include('<meta content="The Great Gatsby" property="og:title" />')
|
66
70
|
end
|
67
71
|
|
68
72
|
it "allows use of the tag 'type'" do
|
69
|
-
@template.opengraph { type 'sports_team' }
|
73
|
+
@template.opengraph { |og| og.type 'sports_team' }
|
70
74
|
@template.opengraph.should include('<meta content="sports_team" property="og:type" />')
|
71
75
|
end
|
72
76
|
|
73
77
|
it "supports multiple tags" do
|
74
|
-
@template.opengraph
|
75
|
-
title 'Austin Powers: International Man of Mystery'
|
76
|
-
type 'movie'
|
77
|
-
|
78
|
+
@template.opengraph do |og|
|
79
|
+
og.title 'Austin Powers: International Man of Mystery'
|
80
|
+
og.type 'movie'
|
81
|
+
end
|
78
82
|
output = @template.opengraph
|
79
83
|
|
80
84
|
output.should include('<meta content="movie" property="og:type" />')
|
@@ -85,10 +89,10 @@ describe TopHat::OpenGraphHelper do
|
|
85
89
|
|
86
90
|
context "combined usage" do
|
87
91
|
it "generates all tags when app_id and admins passed as part of definition" do
|
88
|
-
@template.opengraph(:app_id => 'MyApp', :admins => [123, 1234])
|
89
|
-
title
|
90
|
-
type
|
91
|
-
|
92
|
+
@template.opengraph(:app_id => 'MyApp', :admins => [123, 1234]) do |og|
|
93
|
+
og.title @title
|
94
|
+
og.type @type
|
95
|
+
end
|
92
96
|
output = @template.opengraph
|
93
97
|
|
94
98
|
output.should include('<meta content="MyApp" property="fb:app_id" />')
|
@@ -98,10 +102,10 @@ describe TopHat::OpenGraphHelper do
|
|
98
102
|
end
|
99
103
|
|
100
104
|
it "generates all tags when app_id and admins passed as part of rendering" do
|
101
|
-
@template.opengraph
|
102
|
-
title
|
103
|
-
type
|
104
|
-
|
105
|
+
@template.opengraph do |og|
|
106
|
+
og.title @title
|
107
|
+
og.type @type
|
108
|
+
end
|
105
109
|
output = @template.opengraph(:app_id => 'MyApp', :admins => [123, 1234])
|
106
110
|
|
107
111
|
output.should include('<meta content="MyApp" property="fb:app_id" />')
|
@@ -111,17 +115,4 @@ describe TopHat::OpenGraphHelper do
|
|
111
115
|
end
|
112
116
|
end
|
113
117
|
|
114
|
-
context 'deprecated support' do
|
115
|
-
it 'generates multiple tags' do
|
116
|
-
@template.opengraph { |graph|
|
117
|
-
graph.title 'Rain Man'
|
118
|
-
graph.type 'movie'
|
119
|
-
}
|
120
|
-
output = @template.opengraph
|
121
|
-
|
122
|
-
output.should include('<meta content="movie" property="og:type" />')
|
123
|
-
output.should include('<meta content="Rain Man" property="og:title" />')
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
118
|
end
|
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe TopHat::TwitterCardHelper do
|
4
|
+
before(:all) do
|
5
|
+
@title = 'Rain Man'
|
6
|
+
@image = 'http://someurl.com/animage.jpg'
|
7
|
+
@height = 123
|
8
|
+
@width = 456
|
9
|
+
end
|
4
10
|
|
5
11
|
before(:each) do
|
6
12
|
@template = ActionView::Base.new
|
@@ -8,47 +14,51 @@ describe TopHat::TwitterCardHelper do
|
|
8
14
|
|
9
15
|
it 'generates a twitter:card meta tag' do
|
10
16
|
@template.twitter_card('summary')
|
17
|
+
|
11
18
|
output = @template.twitter_card
|
12
19
|
output.should eq('<meta name="twitter:card" value="summary" />')
|
13
20
|
end
|
14
21
|
|
15
22
|
it 'generates twitter:card meta tags' do
|
16
|
-
@template.twitter_card('summary') do
|
17
|
-
url 'http://someurl.com'
|
18
|
-
title
|
19
|
-
description 'blah blah'
|
20
|
-
image
|
23
|
+
@template.twitter_card('summary') do |card|
|
24
|
+
card.url 'http://someurl.com'
|
25
|
+
card.title @title
|
26
|
+
card.description 'blah blah'
|
27
|
+
card.image @image
|
21
28
|
end
|
22
29
|
|
23
30
|
output = @template.twitter_card
|
24
|
-
output.should include('twitter:title')
|
25
|
-
output.should include('twitter:
|
31
|
+
output.should include('<meta name="twitter:title" value="Rain Man" />')
|
32
|
+
output.should include('<meta name="twitter:image" value="http://someurl.com/animage.jpg" />')
|
26
33
|
end
|
27
34
|
|
28
35
|
it 'generates nested twitter:card meta tags' do
|
29
|
-
@template.twitter_card('player') do
|
30
|
-
image
|
31
|
-
height
|
32
|
-
width
|
36
|
+
@template.twitter_card('player') do |card|
|
37
|
+
card.image @image do |image|
|
38
|
+
image.height @height
|
39
|
+
image.width @width
|
33
40
|
end
|
34
41
|
end
|
42
|
+
|
35
43
|
output = @template.twitter_card
|
36
|
-
output.should include('twitter:image')
|
37
|
-
output.should include('twitter:image:height')
|
38
|
-
output.should include('twitter:image:width')
|
44
|
+
output.should include('<meta name="twitter:image" value="http://someurl.com/animage.jpg" />')
|
45
|
+
output.should include('<meta name="twitter:image:height" value="123" />')
|
46
|
+
output.should include('<meta name="twitter:image:width" value="456" />')
|
39
47
|
end
|
40
48
|
|
41
49
|
|
42
50
|
it 'generates multiple nested twitter:card meta tags' do
|
43
|
-
@template.twitter_card('player') do
|
44
|
-
player 'https://example.com/embed/a' do
|
45
|
-
stream 'http://example.com/raw-stream/a.mp4' do
|
46
|
-
content_type '123'
|
51
|
+
@template.twitter_card('player') do |card|
|
52
|
+
card.player 'https://example.com/embed/a' do |player|
|
53
|
+
player.stream 'http://example.com/raw-stream/a.mp4' do |stream|
|
54
|
+
stream.content_type '123'
|
47
55
|
end
|
48
56
|
end
|
49
57
|
end
|
58
|
+
|
50
59
|
output = @template.twitter_card
|
51
|
-
output.should include('twitter:player:stream
|
60
|
+
output.should include('<meta name="twitter:player:stream" value="http://example.com/raw-stream/a.mp4" />')
|
61
|
+
output.should include('<meta name="twitter:player:stream:content_type" value="123" />')
|
52
62
|
end
|
53
63
|
|
54
64
|
end
|
data/spec/tophat_spec.rb
CHANGED
@@ -2,80 +2,78 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe TopHat do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
5
|
+
before(:each) do
|
6
|
+
@template = ActionView::Base.new
|
7
|
+
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
it "is mixed into ActionView::Base" do
|
10
|
+
ActionView::Base.included_modules.include?(TopHat::TitleHelper).should be_true
|
11
|
+
ActionView::Base.included_modules.include?(TopHat::MetaHelper).should be_true
|
12
|
+
ActionView::Base.included_modules.include?(TopHat::StylesheetHelper).should be_true
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
it "responds to the 'title' helper" do
|
16
|
+
@template.respond_to?(:title).should be_true
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
it "responds to the 'title' helper alias" do
|
20
|
+
@template.respond_to?(:t).should be_true
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
it "responds to the 'description' helper" do
|
24
|
+
@template.respond_to?(:description).should be_true
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
it "responds to the 'keywords' helper" do
|
28
|
+
@template.respond_to?(:keywords).should be_true
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
it "responds to the 'ie_5_conditional' helper" do
|
32
|
+
@template.respond_to?(:ie_5_conditional).should be_true
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
it "responds to the 'ie_5_5_conditional' helper" do
|
36
|
+
@template.respond_to?(:ie_5_5_conditional).should be_true
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
it "responds to the 'ie_6_conditional' helper" do
|
40
|
+
@template.respond_to?(:ie_6_conditional).should be_true
|
41
|
+
end
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
it "responds to the 'ie_7_conditional' helper" do
|
44
|
+
@template.respond_to?(:ie_7_conditional).should be_true
|
45
|
+
end
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
it "responds to the 'ie_8_conditional' helper" do
|
48
|
+
@template.respond_to?(:ie_8_conditional).should be_true
|
49
|
+
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
it "responds to the 'ie_9_conditional' helper" do
|
52
|
+
@template.respond_to?(:ie_9_conditional).should be_true
|
53
|
+
end
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
it "responds to the 'opengraph' helper" do
|
56
|
+
@template.respond_to?(:opengraph).should be_true
|
57
|
+
end
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
it "responds to the 'noindex' helper" do
|
60
|
+
@template.respond_to?(:noindex).should be_true
|
61
|
+
end
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
it "responds to the 'nofollow' helper" do
|
64
|
+
@template.respond_to?(:nofollow).should be_true
|
65
|
+
end
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
it "responds to the 'canonical' helper" do
|
68
|
+
@template.respond_to?(:canonical).should be_true
|
69
|
+
end
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
it "responds to the 'twitter_card' helper" do
|
72
|
+
@template.respond_to?(:twitter_card).should be_true
|
73
|
+
end
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
75
|
+
it "responds to the 'html_tag' helper" do
|
76
|
+
@template.respond_to?(:html_tag).should be_true
|
79
77
|
end
|
80
78
|
|
81
79
|
describe '.current' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tophat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
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-08-
|
12
|
+
date: 2012-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -190,7 +190,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
190
190
|
version: '0'
|
191
191
|
segments:
|
192
192
|
- 0
|
193
|
-
hash:
|
193
|
+
hash: -3156332109712594110
|
194
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
195
|
none: false
|
196
196
|
requirements:
|
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
199
|
version: '0'
|
200
200
|
segments:
|
201
201
|
- 0
|
202
|
-
hash:
|
202
|
+
hash: -3156332109712594110
|
203
203
|
requirements: []
|
204
204
|
rubyforge_project:
|
205
205
|
rubygems_version: 1.8.24
|