sinatra-static-assets 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/sinatra/static_assets.rb +13 -0
- data/sinatra-static-assets.gemspec +1 -1
- data/test/sinatra_app.rb +21 -0
- data/test/sinatra_baseapp.rb +5 -0
- data/test/sinatra_static_assets_test.rb +25 -0
- data/test/sinatra_static_assets_xhtml_test.rb +7 -0
- metadata +24 -9
data/README.md
CHANGED
@@ -38,6 +38,19 @@ module Sinatra
|
|
38
38
|
desc
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
def link_favicon_tag(source = nil, options = {})
|
43
|
+
source = "favicon.ico" if source.nil? or source.empty?
|
44
|
+
unless settings.xhtml
|
45
|
+
# html5 style like <link rel="icon" href="http://example.com/myicon.ico" />
|
46
|
+
options[:rel] = options[:rel] || "icon"
|
47
|
+
else
|
48
|
+
# xhtml style like <link rel="shortcut icon" href="http://example.com/myicon.ico" />
|
49
|
+
options[:rel] = "shortcut icon"
|
50
|
+
end
|
51
|
+
options[:href] = url_for(source)
|
52
|
+
tag("link", options)
|
53
|
+
end
|
41
54
|
|
42
55
|
private
|
43
56
|
|
data/test/sinatra_app.rb
CHANGED
@@ -47,3 +47,24 @@ get "/link_to_tag" do
|
|
47
47
|
#{link_to "Tatry Mountains Rescue Team", "/topr"}
|
48
48
|
EOD
|
49
49
|
end
|
50
|
+
|
51
|
+
get "/link_favicon_tag_empty" do
|
52
|
+
content_type "text/plain"
|
53
|
+
<<"EOD"
|
54
|
+
#{link_favicon_tag}
|
55
|
+
EOD
|
56
|
+
end
|
57
|
+
|
58
|
+
get "/link_favicon_tag_changing_filename" do
|
59
|
+
content_type "text/plain"
|
60
|
+
<<"EOD"
|
61
|
+
#{link_favicon_tag 'favicon2.ico'}
|
62
|
+
EOD
|
63
|
+
end
|
64
|
+
|
65
|
+
get "/link_favicon_tag_with_options" do
|
66
|
+
content_type "text/plain"
|
67
|
+
<<"EOD"
|
68
|
+
#{link_favicon_tag 'favicon.ico', :rel => "apple-touch-icon" }
|
69
|
+
EOD
|
70
|
+
end
|
data/test/sinatra_baseapp.rb
CHANGED
@@ -66,4 +66,29 @@ EOD
|
|
66
66
|
EOD
|
67
67
|
end
|
68
68
|
|
69
|
+
|
70
|
+
def test_link_tag_empty
|
71
|
+
get '/link_favicon_tag_empty', {}, 'SCRIPT_NAME' => '/bar'
|
72
|
+
assert last_response.ok?
|
73
|
+
assert_equal last_response.body, <<EOD
|
74
|
+
<link href="/bar/favicon.ico" rel="icon">
|
75
|
+
EOD
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_link_favicon_changing_filename
|
79
|
+
get '/link_favicon_tag_changing_filename', {}, 'SCRIPT_NAME' => '/bar'
|
80
|
+
assert last_response.ok?
|
81
|
+
assert_equal last_response.body, <<EOD
|
82
|
+
<link href="/bar/favicon2.ico" rel="icon">
|
83
|
+
EOD
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_link_favicon_tag_with_options
|
87
|
+
get '/link_favicon_tag_with_options', {}, 'SCRIPT_NAME' => '/bar'
|
88
|
+
assert last_response.ok?
|
89
|
+
assert_equal last_response.body, <<EOD
|
90
|
+
<link href="/bar/favicon.ico" rel="apple-touch-icon">
|
91
|
+
EOD
|
92
|
+
end
|
93
|
+
|
69
94
|
end
|
@@ -23,4 +23,11 @@ class SintraStaticAssetsXHTMLTest < Test::Unit::TestCase
|
|
23
23
|
"<link charset=\"utf-8\" href=\"/stylesheets/winter.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\"/>"
|
24
24
|
end
|
25
25
|
|
26
|
+
def test_link_favicon_tag_closes
|
27
|
+
get '/link_favicon_tag', {}, 'SCRIPT_NAME' => '/bar'
|
28
|
+
assert last_response.ok?
|
29
|
+
assert_equal last_response.body,
|
30
|
+
'<link href="/bar/favicon.ico" rel="shortcut icon"/>'
|
31
|
+
end
|
32
|
+
|
26
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-static-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 1.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.1.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rack
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rack-test
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
description: ! "This Sinatra extensions provides following helper methods:\n -
|
48
63
|
image_tag\n - stylesheet_link_tag\n - javascript_script_tag"
|
49
64
|
email:
|
@@ -123,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
138
|
version: '0'
|
124
139
|
requirements: []
|
125
140
|
rubyforge_project: sinatra-static-assets
|
126
|
-
rubygems_version: 1.8.
|
141
|
+
rubygems_version: 1.8.23
|
127
142
|
signing_key:
|
128
143
|
specification_version: 3
|
129
144
|
summary: A Sinatra extension.
|