inline-style 0.0.1 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -1
- data/inline-style.gemspec +1 -1
- data/lib/inline-style.rb +4 -2
- data/spec/fixtures/with-style-tag.html +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -94,6 +94,7 @@ As rack middleware:
|
|
94
94
|
== ISSUES:
|
95
95
|
|
96
96
|
* Doesn't work with relative stylesheet links
|
97
|
+
* It strips any numeric character (Rails may add) at the end of the stylesheet file name, anyway stylesheets should end with .css extension
|
97
98
|
|
98
99
|
== REQUIREMENTS:
|
99
100
|
|
@@ -101,7 +102,7 @@ tenderlove's nokogiri and csspool
|
|
101
102
|
|
102
103
|
== INSTALL:
|
103
104
|
|
104
|
-
|
105
|
+
sudo gem install inline-style --source http://gemcutter.org
|
105
106
|
|
106
107
|
== LICENSE:
|
107
108
|
|
data/inline-style.gemspec
CHANGED
data/lib/inline-style.rb
CHANGED
@@ -5,7 +5,7 @@ require 'csspool'
|
|
5
5
|
require "#{ File.dirname( __FILE__ ) }/inline-style/rack/middleware"
|
6
6
|
|
7
7
|
module InlineStyle
|
8
|
-
VERSION = '0.
|
8
|
+
VERSION = '0.1'
|
9
9
|
|
10
10
|
def self.process html, document_root
|
11
11
|
nokogiri_doc_given = Nokogiri::HTML::Document === html
|
@@ -41,14 +41,16 @@ module InlineStyle
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.extract_css html, document_root
|
44
|
+
|
44
45
|
CSSPool.CSS html.css('style, link').collect { |e|
|
45
46
|
next unless e['media'].nil? or e['media'].match /\bscreen\b/
|
46
47
|
next(e.remove and e.content) if e.name == 'style'
|
47
48
|
next unless e['rel'] == 'stylesheet'
|
48
49
|
e.remove
|
49
50
|
next open(e['href']).read if %r{^https?://} === e['href']
|
50
|
-
File.read File.join(document_root, e['href'])
|
51
|
+
File.read File.join(document_root, e['href'].sub(/\?\d+$/,''))
|
51
52
|
}.join("\n")
|
52
53
|
end
|
53
54
|
|
55
|
+
|
54
56
|
end
|
@@ -33,7 +33,7 @@
|
|
33
33
|
}
|
34
34
|
|
35
35
|
</style>
|
36
|
-
<link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
36
|
+
<link rel="stylesheet" href="style.css?1212121" type="text/css" media="screen" title="no title" charset="utf-8">
|
37
37
|
|
38
38
|
</head>
|
39
39
|
<body>
|