tophat 1.2.0 → 1.3.0
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/.gitignore +3 -21
- data/.rspec +3 -0
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +100 -0
- data/Rakefile +18 -58
- data/lib/tophat/meta.rb +16 -25
- data/lib/tophat/opengraph.rb +11 -12
- data/lib/tophat/robots.rb +4 -6
- data/lib/tophat/stylesheet.rb +32 -28
- data/lib/tophat/title.rb +64 -68
- data/lib/tophat/version.rb +1 -1
- data/lib/tophat.rb +0 -4
- data/spec/spec_helper.rb +43 -0
- data/spec/tophat/meta_helper_spec.rb +64 -0
- data/spec/tophat/opengraph_helper_spec.rb +71 -0
- data/spec/tophat/robots_helper_spec.rb +39 -0
- data/spec/tophat/stylesheet_helper_spec.rb +148 -0
- data/spec/tophat/title_helper_spec.rb +96 -0
- data/spec/tophat_spec.rb +73 -0
- data/tophat.gemspec +23 -65
- metadata +108 -49
- data/README.textile +0 -123
- data/rails/init.rb +0 -1
- data/test/helper.rb +0 -9
- data/test/test_opengraph.rb +0 -88
- data/test/test_robots.rb +0 -54
- data/test/test_tophat.rb +0 -55
- data/test/test_tophat_meta.rb +0 -76
- data/test/test_tophat_stylesheets.rb +0 -119
- data/test/test_tophat_title.rb +0 -103
@@ -1,119 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TopHatStylesheetTestCase < Test::Unit::TestCase
|
4
|
-
|
5
|
-
context "using the stylesheet helper" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@template = ActionView::Base.new
|
9
|
-
end
|
10
|
-
|
11
|
-
context "stylesheets" do
|
12
|
-
setup do
|
13
|
-
@stylesheet = "ie.css"
|
14
|
-
end
|
15
|
-
|
16
|
-
should "define IE conditionals" do
|
17
|
-
assert_equal @template.ie_5_conditional {
|
18
|
-
@template.stylesheet_link_tag(@stylesheet)
|
19
|
-
}, "<!--[if IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
20
|
-
|
21
|
-
assert_equal @template.ie_5_5_conditional {
|
22
|
-
@template.stylesheet_link_tag(@stylesheet)
|
23
|
-
}, "<!--[if IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
24
|
-
|
25
|
-
assert_equal @template.ie_6_conditional {
|
26
|
-
@template.stylesheet_link_tag(@stylesheet)
|
27
|
-
}, "<!--[if IE 6]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
28
|
-
|
29
|
-
assert_equal @template.ie_7_conditional {
|
30
|
-
@template.stylesheet_link_tag(@stylesheet)
|
31
|
-
}, "<!--[if IE 7]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
32
|
-
|
33
|
-
assert_equal @template.ie_8_conditional {
|
34
|
-
@template.stylesheet_link_tag(@stylesheet)
|
35
|
-
}, "<!--[if IE 8]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
36
|
-
end
|
37
|
-
|
38
|
-
should "render defined IE conditional with greater than operator" do
|
39
|
-
assert_equal @template.ie_5_conditional(:gt) {
|
40
|
-
@template.stylesheet_link_tag(@stylesheet)
|
41
|
-
}, "<!--[if gt IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
42
|
-
|
43
|
-
assert_equal @template.ie_5_5_conditional(:gt) {
|
44
|
-
@template.stylesheet_link_tag(@stylesheet)
|
45
|
-
}, "<!--[if gt IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
46
|
-
end
|
47
|
-
|
48
|
-
should "render defined IE conditional with greater than or equal to operator" do
|
49
|
-
assert_equal @template.ie_5_conditional(:gte) {
|
50
|
-
@template.stylesheet_link_tag(@stylesheet)
|
51
|
-
}, "<!--[if gte IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
52
|
-
|
53
|
-
assert_equal @template.ie_5_5_conditional(:gte) {
|
54
|
-
@template.stylesheet_link_tag(@stylesheet)
|
55
|
-
}, "<!--[if gte IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
56
|
-
end
|
57
|
-
|
58
|
-
should "render defined IE conditional with ! operator" do
|
59
|
-
assert_equal @template.ie_5_conditional(:not) {
|
60
|
-
@template.stylesheet_link_tag(@stylesheet)
|
61
|
-
}, "<!--[if !IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
62
|
-
|
63
|
-
assert_equal @template.ie_5_5_conditional(:not) {
|
64
|
-
@template.stylesheet_link_tag(@stylesheet)
|
65
|
-
}, "<!--[if !IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
66
|
-
end
|
67
|
-
|
68
|
-
should "render defined IE conditional with less than operator" do
|
69
|
-
assert_equal @template.ie_5_conditional(:lt) {
|
70
|
-
@template.stylesheet_link_tag(@stylesheet)
|
71
|
-
}, "<!--[if lt IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
72
|
-
|
73
|
-
assert_equal @template.ie_5_5_conditional(:lt) {
|
74
|
-
@template.stylesheet_link_tag(@stylesheet)
|
75
|
-
}, "<!--[if lt IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
76
|
-
end
|
77
|
-
|
78
|
-
should "render defined IE conditional with less than or equal to operator" do
|
79
|
-
assert_equal @template.ie_5_conditional(:lte) {
|
80
|
-
@template.stylesheet_link_tag(@stylesheet)
|
81
|
-
}, "<!--[if lte IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
82
|
-
|
83
|
-
assert_equal @template.ie_5_5_conditional(:lte) {
|
84
|
-
@template.stylesheet_link_tag(@stylesheet)
|
85
|
-
}, "<!--[if lte IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
86
|
-
end
|
87
|
-
|
88
|
-
should "render defined IE conditional with equal to operator" do
|
89
|
-
assert_equal @template.ie_5_conditional(:eq) {
|
90
|
-
@template.stylesheet_link_tag(@stylesheet)
|
91
|
-
}, "<!--[if eq IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
92
|
-
|
93
|
-
assert_equal @template.ie_5_5_conditional(:eq) {
|
94
|
-
@template.stylesheet_link_tag(@stylesheet)
|
95
|
-
}, "<!--[if eq IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
96
|
-
end
|
97
|
-
|
98
|
-
should "render defined conditionals for other browsers" do
|
99
|
-
assert_equal @template.opera_conditional {
|
100
|
-
@template.stylesheet_link_tag(@stylesheet)
|
101
|
-
}, "<!--[if Opera]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
102
|
-
|
103
|
-
assert_equal @template.webkit_conditional {
|
104
|
-
@template.stylesheet_link_tag(@stylesheet)
|
105
|
-
}, "<!--[if Webkit]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
106
|
-
|
107
|
-
assert_equal @template.webkit_conditional(:eq) {
|
108
|
-
@template.stylesheet_link_tag(@stylesheet)
|
109
|
-
}, "<!--[if eq Webkit]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
110
|
-
|
111
|
-
assert_equal @template.gecko_conditional {
|
112
|
-
@template.stylesheet_link_tag(@stylesheet)
|
113
|
-
}, "<!--[if Gecko]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
data/test/test_tophat_title.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TopHatTitleTestCase < Test::Unit::TestCase
|
4
|
-
|
5
|
-
context "when using the title helper" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@template = ActionView::Base.new
|
9
|
-
end
|
10
|
-
|
11
|
-
context "saving a title" do
|
12
|
-
|
13
|
-
should "save the title" do
|
14
|
-
assert_equal @template.title('Kind of Blue'), 'Kind of Blue'
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
context "displaying a title" do
|
20
|
-
|
21
|
-
should "use the website name if title is empty" do
|
22
|
-
assert_equal @template.title(:site => "Miles Davis"), "<title>Miles Davis</title>"
|
23
|
-
end
|
24
|
-
|
25
|
-
should "display the title if no website was specified" do
|
26
|
-
save_basic_title
|
27
|
-
assert_equal @template.title(), '<title>Kind of Blue</title>'
|
28
|
-
end
|
29
|
-
|
30
|
-
should "use website before page by default" do
|
31
|
-
save_basic_title
|
32
|
-
assert_equal @template.title(:site => "Miles Davis", :separator => '|'), "<title>Miles Davis | Kind of Blue</title>"
|
33
|
-
end
|
34
|
-
|
35
|
-
should "only use markup in titles in the view" do
|
36
|
-
assert_equal save_basic_title("<b>Kind of Blue</b>"), "<b>Kind of Blue</b>"
|
37
|
-
assert_equal @template.title(:site => "Miles Davis", :separator => '|'), "<title>Miles Davis | Kind of Blue</title>"
|
38
|
-
end
|
39
|
-
|
40
|
-
should "use page before website if :reverse" do
|
41
|
-
save_basic_title
|
42
|
-
assert_equal @template.title(:site => "Miles Davis", :reverse => true, :separator => '|'), "<title>Kind of Blue | Miles Davis</title>"
|
43
|
-
end
|
44
|
-
|
45
|
-
should "use website before page if :reverse and :reverse_on_default" do
|
46
|
-
assert_equal @template.title(:site => "John Coltrane", :default => "My Favorite Things", :reverse => true, :reverse_on_default => false, :separator => '|'), "<title>John Coltrane | My Favorite Things</title>"
|
47
|
-
end
|
48
|
-
|
49
|
-
should "be lowercase if :lowercase" do
|
50
|
-
save_basic_title
|
51
|
-
assert_equal @template.title(:site => "Miles Davis", :lowercase => true, :separator => '|'), "<title>miles davis | kind of blue</title>"
|
52
|
-
end
|
53
|
-
|
54
|
-
should "use custom separator if :separator" do
|
55
|
-
save_basic_title
|
56
|
-
assert_equal @template.title(:site => "Miles Davis", :separator => "-"), "<title>Miles Davis - Kind of Blue</title>"
|
57
|
-
assert_equal @template.title(:site => "Miles Davis", :separator => ":"), "<title>Miles Davis : Kind of Blue</title>"
|
58
|
-
assert_equal @template.title(:site => "Miles Davis", :separator => "—"), "<title>Miles Davis — Kind of Blue</title>"
|
59
|
-
end
|
60
|
-
|
61
|
-
should "use custom prefix and suffix if available" do
|
62
|
-
save_basic_title
|
63
|
-
assert_equal @template.title(:site => "Miles Davis", :prefix => " |", :suffix => "| ", :separator => '|'), "<title>Miles Davis ||| Kind of Blue</title>"
|
64
|
-
end
|
65
|
-
|
66
|
-
should "collapse prefix if false" do
|
67
|
-
save_basic_title
|
68
|
-
assert_equal @template.title(:site => "Miles Davis", :prefix => false, :separator => ":"), "<title>Miles Davis: Kind of Blue</title>"
|
69
|
-
end
|
70
|
-
|
71
|
-
should "collapse suffix if false" do
|
72
|
-
save_basic_title
|
73
|
-
assert_equal @template.title(:site => "Miles Davis", :suffix => false, :separator => "~"), "<title>Miles Davis ~Kind of Blue</title>"
|
74
|
-
end
|
75
|
-
|
76
|
-
should "use all custom options if available" do
|
77
|
-
save_basic_title
|
78
|
-
custom_options = { :site => "Miles Davis", :prefix => " ", :suffix => " ", :separator => "-", :lowercase => true, :reverse => true }
|
79
|
-
assert_equal @template.title(custom_options), "<title>kind of blue - miles davis</title>"
|
80
|
-
end
|
81
|
-
|
82
|
-
should "use default one if title is not present or blank" do
|
83
|
-
save_basic_title("")
|
84
|
-
assert_equal @template.title(:site => "Miles Davis", :default => "Round About Midnight", :separator => '|'), "<title>Miles Davis | Round About Midnight</title>"
|
85
|
-
end
|
86
|
-
|
87
|
-
should "allow custom options per title" do
|
88
|
-
save_custom_title
|
89
|
-
assert_equal @template.title(:site => "Freddie Freeloader", :separator => '|'), "<title>Kind of Blue | Freddie Freeloader</title>"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
def save_basic_title(title='Kind of Blue')
|
96
|
-
@template.title(title)
|
97
|
-
end
|
98
|
-
|
99
|
-
def save_custom_title(title='Kind of Blue')
|
100
|
-
@template.title(title, { :reverse => true })
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|