Class: MailsViewer::HomeController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- MailsViewer::HomeController
- Defined in:
- app/controllers/mails_viewer/home_controller.rb
Instance Method Summary collapse
Instance Method Details
#attachment ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/mails_viewer/home_controller.rb', line 46 def if @filename mail = Mail.read(@filename) = mail.[params[:attachment]] if send_data .body.decoded, filename: params[:attachment], type: .content_type and return end end head :not_found end |
#html ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/mails_viewer/home_controller.rb', line 27 def html if @filename mail = Mail.read(@filename) body = mail.html_part ? mail.html_part.body : mail.body render text: body else head :not_found end end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/mails_viewer/home_controller.rb', line 7 def index if File.exist?(mails_path) Dir.chdir(mails_path) do @mails = Dir["**/*"] .select{|f| File.file?(f)} .map{|f| [Mail.read(f), f]} end else @mails = [] end end |
#plain ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/controllers/mails_viewer/home_controller.rb', line 37 def plain if @filename mail = Mail.read(@filename) @body = mail.text_part ? mail.text_part.body.to_s : mail.body.to_s else head :not_found end end |
#raw ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/controllers/mails_viewer/home_controller.rb', line 19 def raw if @filename render text: File.read(@filename) else head :not_found end end |