Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefano Verna
committed
Jul 30, 2010
1 parent
63c8b3a
commit 964ba24
Showing
6 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'active_support' | ||
require 'incurve/string_premailer' | ||
|
||
module InCurve | ||
|
||
class << self | ||
def enable | ||
enable_actionpack | ||
end | ||
|
||
def enable_actionpack | ||
return if ActionView::Base.instance_methods.include_method? :incurve_css | ||
require 'incurve/view_helpers' | ||
ActionView::Base.send :include, ViewHelpers | ||
end | ||
end | ||
|
||
end | ||
|
||
if defined? Rails | ||
InCurve.enable_actionpack if defined? ActionController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'premailer' | ||
|
||
class StringPremailer < Premailer | ||
|
||
protected | ||
|
||
def load_html(path) | ||
if path.is_a?(IO) || path.is_a?(StringIO) | ||
@html_file = "http://foo.bar" | ||
Hpricot(path.read) | ||
elsif @is_local_file | ||
Hpricot(File.open(path, "r") {|f| f.read }) | ||
else | ||
Hpricot(open(path)) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module InCurve | ||
module ViewHelpers | ||
|
||
def incurve_css(&block) | ||
c = capture(&block) | ||
premailer = StringPremailer.new(StringIO.new(c)) | ||
premailer.to_inline_css.html_safe | ||
end | ||
|
||
end | ||
end |