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
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/mails_viewer/home_controller.rb', line 42 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
23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/mails_viewer/home_controller.rb', line 23 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 |
# File 'app/controllers/mails_viewer/home_controller.rb', line 7 def index Dir.chdir(mails_path) do @mails = Dir["**/*"] .select{|f| File.file?(f)} .map{|f| [Mail.read(f), f]} end end |
#plain ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/controllers/mails_viewer/home_controller.rb', line 33 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
15 16 17 18 19 20 21 |
# File 'app/controllers/mails_viewer/home_controller.rb', line 15 def raw if @filename render text: File.read(@filename) else head :not_found end end |