Permalink
Browse files

Version 0.0.2; bugfixes

  • Loading branch information...
1 parent 13f7edc commit 97b83eba2ea1543bd0d9e2f420132611421fcd93 @glebm committed Jan 30, 2012
@@ -1,5 +1,4 @@
#message_headers
- height: 85px
padding: 10px 0 0 0
margin: 0
background: #fff
@@ -28,11 +27,4 @@
p.alternate
- position: absolute
- top: 0
- right: 15px
-
-
- p.alternate a
- color: #09c
-
+ float: right
@@ -12,8 +12,7 @@ def show_raw
@mail = @preview_class.new.send(params[:mail_action])
body_part = @mail
if @mail.multipart?
- content_type = Rack::Mime.mime_type(params[:format])
- body_part = @mail.parts.find { |part| part.content_type.match(content_type) } || @mail.parts.first
+ body_part = @mail.parts.find { |part| part.content_type.start_with?(@part_type) } || @mail.parts.first
end
body = body_part.body
if body_part.content_type =~ /plain/
@@ -25,5 +24,6 @@ def show_raw
private
def load_preview_class
@preview_class = (RailsEmailPreview.preview_classes || []).find {|pc| pc.name.underscore == params[:mail_class]}
+ @part_type = params[:part_type] || 'text/html'
end
end
@@ -1,5 +1,11 @@
%a#back-to-all{:href => rails_email_preview.root_url} « Back to list
#message_headers
+ - if @mail.multipart?
+ %p.alternate
+ - if @part_type == 'text/html'
+ %a{:href => rails_email_preview.email_url(params.merge(:part_type => 'text/plain'))} View plain text version
+ - else
+ %a{:href => rails_email_preview.email_url(params.merge(:part_type => 'text/html'))} View HTML version
%dl
%dt From:
%dd= @mail.from
@@ -14,15 +20,7 @@
%dt To:
%dd= @mail.to
- - if @mail.multipart?
- %p.alternate
- - if body_part.content_type && body_part.content_type.match(/text\/html/)
- %a{:href => rails_email_preview.email_url(params.merge(:format => 'txt'))}} View plain text version
- - else
- %a{:href => rails_email_preview.email_url(params.merge(:format => 'html'))}} View HTML version
-
-
-%iframe#src-iframe{:src => rails_email_preview.raw_email_url(params),
+%iframe#src-iframe{:src => rails_email_preview.raw_email_url(params.slice(:mail_class, :mail_action, :part_type)),
:width => "100%", :height => "800", :onload => 'emailLoaded()', :style => "display:none"}
%pre#loading Loading...
View
@@ -1,13 +1,11 @@
RailsEmailPreview::Engine.routes.draw do
root :to => 'emails#index'
- match 'raw/:mail_class/:mail_action(.:format)',
+ match 'raw/:mail_class/:mail_action',
:as => :raw_email,
:to => 'emails#show_raw',
- :defaults => {:format => 'html'},
:mail_class => %r([\w/]+)
- match ':mail_class/:mail_action(.:format)',
+ match ':mail_class/:mail_action',
:as => :email,
:to => 'emails#show',
- :defaults => {:format => 'html'},
:mail_class => %r([\w/]+)
end
@@ -1,3 +1,3 @@
module RailsEmailPreview
- VERSION = '0.0.1'
+ VERSION = '0.0.2'
end

0 comments on commit 97b83eb

Please sign in to comment.