inline_css 0.0.1

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 ADDED
@@ -0,0 +1,26 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## BUNDLER::DEFAULTS
17
+ *.gem
18
+ .bundle
19
+ Gemfile.lock
20
+ pkg/*
21
+
22
+ ## PROJECT::GENERAL
23
+ coverage
24
+ rdoc
25
+
26
+ ## PROJECT::SPECIFIC
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in inline_css.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Morton Jonuschat <yabawock@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Inline CSS
2
+
3
+ Inline CSS provides a view helper method to Rails 3 applications that
4
+ lets you inline any CSS code present in the view into the applicable
5
+ elements.
6
+
7
+ This is mostly useful in ActionMailer views since mail programms are
8
+ known for their mediocre support of CSS styling in stylesheets.
9
+
10
+ Inline CSS is a uses the "premailer" gem to perform the magic. It is
11
+ nothing more than a simple wrapper around @to_inline_css@ provided by
12
+ Premailer.
13
+
14
+ Inline CSS has been inspired by the "incurve" gem which provides a very
15
+ similar function but uses some intermediate classes instead of
16
+ Premailers internal functions to use a string as source.
17
+
18
+ # Example
19
+
20
+ If you have this mail view:
21
+
22
+ <%= inline_css do %>
23
+ <html>
24
+ <head>
25
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
26
+ <style type="text/css">
27
+ body {
28
+ background-color: #e6e6e6;
29
+ background-position: top center;
30
+ background-repeat: no-repeat repeat-y;
31
+ margin: 0;
32
+ padding: 0;
33
+ }
34
+ </style>
35
+ </head>
36
+ <body>
37
+ </body>
38
+ </html>
39
+ <% end -%>
40
+
41
+ The mail you'll send will be like this:
42
+
43
+ <html>
44
+ <head>
45
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
46
+ </head>
47
+ <body style="background-color: #e6e6e6; background-position: top center; background-repeat: no-repeat repeat-y; margin: 0; padding: 0;">
48
+ </body>
49
+ </html>
50
+
51
+ ## Note on Patches/Pull Requests
52
+
53
+ * Fork the project.
54
+ * Make your feature addition or bug fix.
55
+ * Add tests for it. This is important so I don't break it in a
56
+ future version unintentionally.
57
+ * Commit, do not mess with rakefile, version, or history.
58
+ (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)
59
+ * Send me a pull request. Bonus points for topic branches.
60
+
61
+ ## Copyright
62
+
63
+ Copyright (c) 2011 Morton Jonuschat. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "inline_css/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "inline_css"
7
+ s.version = InlineCss::VERSION
8
+ s.authors = ["Morton Jonuschat"]
9
+ s.email = ["yabawock@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{InlineCss provides a view helper to inline your css styles}
12
+ s.description = %q{InlineCss provides the inline_css helper to inline css styles within a view. This is especially useful for ActionMailer te
13
+ nplates. InlineCss makes use of the excellent Premailer gem to accomplish this task.}
14
+
15
+ s.rubyforge_project = "inline_css"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ # specify any dependencies here; for example:
23
+ # s.add_development_dependency "rspec"
24
+ s.add_development_dependency "rake"
25
+ s.add_runtime_dependency "premailer", ">= 1.5.4"
26
+ end
@@ -0,0 +1,3 @@
1
+ module InlineCss
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ require 'premailer'
3
+
4
+ module InlineCss
5
+ module ViewHelpers
6
+
7
+ def inline_css(options = {}, &block)
8
+ html_code = capture(&block)
9
+ options[:with_html_string] = true
10
+
11
+ premailer = Premailer.new(html_code, options)
12
+ inlined = premailer.to_inline_css
13
+ inlined.html_safe
14
+ end
15
+ end
16
+ end
data/lib/inline_css.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'inline_css/version'
2
+ require 'active_support'
3
+
4
+ module InlineCss
5
+ class << self
6
+ def enable
7
+ enable_actionpack
8
+ end
9
+
10
+ def enable_actionpack
11
+ unless ActionView::Base.method_defined?(:inline_css)
12
+ require 'inline_css/view_helpers'
13
+ ActionView::Base.send :include, ViewHelpers
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ # Load the view helpers
20
+ if defined?(Rails) && defined?(ActionController)
21
+ InlineCss.enable_actionpack
22
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inline_css
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Morton Jonuschat
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-26 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70335069869180 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70335069869180
25
+ - !ruby/object:Gem::Dependency
26
+ name: premailer
27
+ requirement: &70335069868320 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.5.4
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70335069868320
36
+ description: ! "InlineCss provides the inline_css helper to inline css styles within
37
+ a view. This is especially useful for ActionMailer te\n nplates. InlineCss makes
38
+ use of the excellent Premailer gem to accomplish this task."
39
+ email:
40
+ - yabawock@gmail.com
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - LICENSE
48
+ - README.md
49
+ - Rakefile
50
+ - inline_css.gemspec
51
+ - lib/inline_css.rb
52
+ - lib/inline_css/version.rb
53
+ - lib/inline_css/view_helpers.rb
54
+ homepage: ''
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ segments:
67
+ - 0
68
+ hash: 884980791818808002
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ segments:
76
+ - 0
77
+ hash: 884980791818808002
78
+ requirements: []
79
+ rubyforge_project: inline_css
80
+ rubygems_version: 1.8.6
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: InlineCss provides a view helper to inline your css styles
84
+ test_files: []