Skip to content

Commit

Permalink
create install generator
Browse files Browse the repository at this point in the history
  • Loading branch information
zokioki committed Jul 3, 2016
1 parent e3d594b commit ffab770
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 27 deletions.
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
PATH
remote: .
specs:
inky-rb (0.0.3)
inky-rb (1.3.6.0)
foundation_emails (~> 2)

GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.2.5)
foundation_emails (2.1.0.1)
foundation_emails (2.2.0.0)
rake (11.2.2)
rspec-core (3.4.4)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
rspec-core (3.5.0)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)

PLATFORMS
ruby
Expand All @@ -28,4 +28,4 @@ DEPENDENCIES
rspec-expectations

BUNDLED WITH
1.12.4
1.11.2
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,25 @@ Ensure your mailer layout has the following structure:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Enables media queries -->
<meta name="viewport" content="width=device-width"/>
<!-- Link to the email's CSS, which will be inlined into the email -->
<link rel="stylesheet" href="assets/css/foundation-emails.css">
</head>

<body>
<table class="body" data-made-with-foundation>
<tr>
<td class="center" align="center" valign="top">
<center>
<%= yield %>
</center>
</td>
</tr>
</table>
</body>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Enables media queries -->
<meta name="viewport" content="width=device-width"/>
<!-- Link to the email's CSS, which will be inlined into the email -->
<%= stylesheet_link_tag "your_emails_stylesheet" %>
</head>

<body>
<table class="body" data-made-with-foundation>
<tr>
<td class="center" align="center" valign="top">
<center>
<%= yield %>
</center>
</td>
</tr>
</table>
</body>
</html>
```

Expand Down
29 changes: 29 additions & 0 deletions lib/generators/inky/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'rails/generators'

module Inky
module Generators
class InstallGenerator < ::Rails::Generators::Base
desc 'Install Foundation for Emails'
source_root File.join(File.dirname(__FILE__), 'templates')
argument :layout_name, :type => :string, :default => 'inky_mailer', :banner => 'layout_name'

def create_mailer_stylesheet
template 'foundation_emails.scss', File.join(stylesheets_base_dir, 'foundation_emails.scss')
end

def create_mailer_layout
template 'mailer_layout.html.erb', File.join(layouts_base_dir, "#{layout_name.underscore}.html.erb")
end

private

def stylesheets_base_dir
File.join('app', 'assets', 'stylesheets')
end

def layouts_base_dir
File.join('app', 'views', 'layouts')
end
end
end
end
1 change: 1 addition & 0 deletions lib/generators/inky/templates/foundation_emails.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "foundation-emails";
21 changes: 21 additions & 0 deletions lib/generators/inky/templates/mailer_layout.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />

<%%= stylesheet_link_tag "foundation_emails" %>
</head>

<body>
<table class="body" data-made-with-foundation>
<tr>
<td class="center" align="center" valign="top">
<center>
<%%= yield %>
</center>
</td>
</tr>
</table>
</body>
</html>

0 comments on commit ffab770

Please sign in to comment.