mailbuilder-preview 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,31 +6,31 @@ module MailbuilderPreview
6
6
  def index
7
7
 
8
8
  @email_names = Dir.entries("./app/emails/").delete_if {|v| v == ".." || v == '.' }.sort
9
- render :layout => nil
9
+ render
10
10
 
11
11
  end
12
12
 
13
13
  def show
14
-
15
- if params[:text]
16
- render :text => "<pre>"+get_demo_text(MailBuilder.new(params[:email_id].to_sym))+"</pre>"
14
+ if params[:load_it]
15
+ if params[:text]
16
+ render :text => "<pre>"+get_demo_text(MailBuilder.new(params[:email_id].to_sym))+"</pre>"
17
+ else
18
+ render :text => get_demo_html(MailBuilder.new(params[:email_id].to_sym))
19
+ end
17
20
  elsif params[:email]
18
21
  builder = MailBuilder.new(params[:email_id].to_sym)
19
22
  path = builder.instance_variable_get("@path")
20
-
23
+
21
24
  source = if File.exist?("#{path}/locals.rb")
22
25
  File.read("#{path}/locals.rb")
23
26
  else
24
27
  "{}"
25
28
  end
26
-
27
- send_data builder.build(eval(source)).to_s, :type => "message/rfc822", :disposition => 'inline', :filename => "#{params[:email_id]}-preview.eml"
28
- else
29
- render :text => get_demo_html(MailBuilder.new(params[:email_id].to_sym))
30
- end
31
29
 
30
+ send_data builder.build(eval(source)).to_s, :type => "message/rfc822", :disposition => 'attachment', :filename => "#{params[:email_id]}-preview.eml"
31
+ end
32
32
  end
33
-
33
+
34
34
  def image
35
35
 
36
36
  path = "./app/emails/#{params[:email_id]}/#{params[:rest]}"
@@ -7,8 +7,33 @@
7
7
  <%= csrf_meta_tags %>
8
8
  </head>
9
9
  <body>
10
+
11
+ <div class="container-narrow">
10
12
 
11
- <%= yield %>
13
+ <div class="masthead">
14
+ <ul class="nav nav-pills pull-right">
15
+ <li class="<%= request.path.match(/^\/mail_preview\/(|email)$/) ? "active" : "bla" %>"><a href="/mail_preview/email/">Emails</a></li>
16
+ <li><a href="http://github.com/bjornblomqvist/mailbuilder-preview/">Github</a></li>
17
+ <li><a href="mailto:darwin@bits2life.com?subject=MailBuilder-preview">Contact me</a></li>
18
+ </ul>
19
+ <h3 class="muted">Mailbuilder Preview</h3>
20
+ </div>
21
+
22
+ <hr>
23
+
24
+ <div class="marketing">
25
+
26
+ <%= yield %>
27
+
28
+ </div>
29
+
30
+ <hr>
31
+
32
+ <div class="footer">
33
+ <p>&copy; Björn Blomqvist 2013</p>
34
+ </div>
35
+
36
+ </div> <!-- /container -->
12
37
 
13
38
  </body>
14
39
  </html>
@@ -1,25 +1,36 @@
1
1
 
2
+ <table class="table table-striped">
3
+ <thead>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Perview</th>
7
+ <th>File</th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% @email_names.each do |name| %>
2
12
 
3
- <h1>Email's</h1>
4
- <ul>
5
- <% @email_names.each do |name| %>
6
13
 
14
+ <tr>
15
+ <td><%= name.capitalize %></td>
16
+
17
+ <% if File.exist?("#{Rails.root}/app/emails/#{name}/#{name}.html.erb") || File.exist?("#{Rails.root}/app/emails/#{name}/#{name}.html") %>
18
+ <td><a href="/mail_preview/email/<%= name %>/?html=true">Html</a>
19
+ <% else %>
20
+ <span class="missing">Html</span><td>
21
+ <% end %>
22
+
23
+ <% if File.exist?("#{Rails.root}/app/emails/#{name}/#{name}.txt.erb") || File.exist?("#{Rails.root}/app/emails/#{name}/#{name}.txt") %>
24
+ | <a href="/mail_preview/email/<%= name %>/?text=true">Text</a></td>
25
+ <% else %>
26
+ | <span class="missing">Text</span> </td>
27
+ <% end %>
28
+
29
+ <td><a href="/mail_preview/email/<%= name %>/?email=true"><%= "#{name}_preview.eml" %></a></td>
30
+ </tr>
7
31
 
8
- <li>
9
- <%= name.capitalize %>
10
-
11
- (
12
- <% if File.exist?("#{Rails.root}/app/emails/#{name}/#{name}.html.erb") || File.exist?("#{Rails.root}/app/emails/#{name}/#{name}.html") %>
13
- <a href="/mail_preview/email/<%= name %>/">html</a>
14
- <% end %>
15
- <% if File.exist?("#{Rails.root}/app/emails/#{name}/#{name}.txt.erb") || File.exist?("#{Rails.root}/app/emails/#{name}/#{name}.txt") %>
16
- | <a href="/mail_preview/email/<%= name %>/?text=true">txt</a>
17
32
  <% end %>
18
- )
19
-
20
- <a href="/mail_preview/email/<%= name %>/?email=true">Download</a>
21
- </li>
33
+ </tbody>
34
+ </table>
22
35
 
23
- <% end %>
24
- </ul>
25
36
 
@@ -0,0 +1,14 @@
1
+
2
+
3
+ <iframe class="email-preview" src="<%= (request.fullpath+"&load_it=true").gsub("?","/?") %>">
4
+
5
+ </iframe>
6
+
7
+
8
+
9
+ <script type="text/javascript" charset="utf-8">
10
+ $(window).load(function() {
11
+ var height = $('.email-preview').contents().height();
12
+ $('.email-preview').css('height',height);
13
+ });
14
+ </script>
data/config/routes.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  MailbuilderPreview::Engine.routes.draw do
2
2
 
3
+ match "/" => "mail_preview#index"
4
+
3
5
  match "/email" => "mail_preview#index"
4
6
  match "/email/:email_id" => "mail_preview#show"
5
7
  match "/email/:email_id/:rest" => "mail_preview#image", :constraints => { :rest => /.*/ }
@@ -11,5 +13,5 @@ if Rails.env == "development"
11
13
  Rails.application.routes.draw do
12
14
  mount MailbuilderPreview::Engine => "/mail_preview"
13
15
  end
14
-
16
+
15
17
  end
@@ -1,3 +1,3 @@
1
1
  module MailbuilderPreview
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailbuilder-preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-17 00:00:00.000000000 Z
12
+ date: 2013-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -66,15 +66,20 @@ executables: []
66
66
  extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
+ - app/assets/images/mailbuilder-preview/glyphicons-halflings-white.png
70
+ - app/assets/images/mailbuilder-preview/glyphicons-halflings.png
69
71
  - app/assets/javascripts/mailbuilder-preview/application.js
72
+ - app/assets/javascripts/mailbuilder-preview/bootstrap.js
70
73
  - app/assets/javascripts/mailbuilder_preview/mail_preview.js
71
74
  - app/assets/stylesheets/mailbuilder-preview/application.css
75
+ - app/assets/stylesheets/mailbuilder-preview/bootstrap.css
72
76
  - app/assets/stylesheets/mailbuilder_preview/mail_preview.css
73
77
  - app/controllers/mailbuilder_preview/application_controller.rb
74
78
  - app/controllers/mailbuilder_preview/mail_preview_controller.rb
75
79
  - app/helpers/mailbuilder_preview/application_helper.rb
76
80
  - app/views/layouts/mailbuilder_preview/application.html.erb
77
81
  - app/views/mailbuilder_preview/mail_preview/index.html.erb
82
+ - app/views/mailbuilder_preview/mail_preview/show.html.erb
78
83
  - config/routes.rb
79
84
  - lib/mailbuilder-preview/engine.rb
80
85
  - lib/mailbuilder-preview/version.rb
@@ -98,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
103
  version: '0'
99
104
  segments:
100
105
  - 0
101
- hash: -4071782170397537632
106
+ hash: 4115436358008712270
102
107
  required_rubygems_version: !ruby/object:Gem::Requirement
103
108
  none: false
104
109
  requirements:
@@ -107,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
112
  version: '0'
108
113
  segments:
109
114
  - 0
110
- hash: -4071782170397537632
115
+ hash: 4115436358008712270
111
116
  requirements: []
112
117
  rubyforge_project:
113
118
  rubygems_version: 1.8.24