Skip to content

Commit

Permalink
create a way to do s3 streaming routing.
Browse files Browse the repository at this point in the history
Deal with the mail from isue so that we can use custom URLs
  • Loading branch information
ehansen486 committed Feb 21, 2012
1 parent a61f12e commit 892e968
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
11 changes: 11 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
module ApplicationHelper
USE_S3 = defined?(USE_MODEL_DOCUMENT_S3) && USE_MODEL_DOCUMENT_S3

def s3_or_file_path model_document
client_id = defined?(Client) ? Client.current_client_id : 0
if USE_S3
"/s3/#{client_id}/#{model_document.id}"
else
model_document.document.url
end
end

def urlencode_filename(path)
require 'cgi'
fname, timestamp = path.split(/\?(\d+)/)
Expand Down
2 changes: 1 addition & 1 deletion app/views/model_documents/_model_document_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
- if current_user.has_update_for_model? model
%span.edit_link= link_to image_tag("/images/fluxx_engine/theme/default/icons/page_edit.png"), edit_model_document_path(model), :class => 'to-modal', :title => "Edit Document", 'data-on-success' => 'refreshCaller,close'
- if model.is_file? && model.document
= link_to(truncate(model.document_file_name, :length => 25), "/s3/#{client_id}/#{model.id}", :target => '_blank', :class => "air-download #{mime_type_to_class(model.document_content_type)}")
= link_to(truncate(model.document_file_name, :length => 25), s3_or_file_path(model), :target => '_blank', :class => "air-download #{mime_type_to_class(model.document_content_type)}")
- elsif model.is_text?
- if model.document_content_type.blank?
= link_to truncate(model.document_file_name, :length => 25), model_document_path(model), :class => 'new-detail', 'data-insert' => 'after', :title => "view/edit doc"
Expand Down
10 changes: 7 additions & 3 deletions lib/extensions/mailers/fluxx_grant_alert_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
module FluxxCrmAlertMailer
extend FluxxModuleHelper

when_included do
default :return_path => 'system@fluxxlabs.com'
end

instance_methods do
def from_email_address
Fluxx.config(:from_email_address)
Fluxx.config(:from_email_address) || 'do-not-reply@fluxxlabs.com'
end

def alert(recipient, alert, locals={})
mail(:from => 'do-not-reply@fluxxlabs.com', :reply_to => from_email_address, :to => recipient.is_a?(User) ? recipient.mailer_email : recipient.to_s,
mail(:from => from_email_address, :reply_to => from_email_address, :to => recipient.is_a?(User) ? recipient.mailer_email : recipient.to_s,
:cc => alert.cc_emails, :bcc => alert.bcc_emails,
:subject => alert.liquid_subject(locals.merge('recipient' => recipient))) do |format|
format.html { render :text => alert.liquid_body(locals.merge('recipient' => recipient)) }
Expand All @@ -16,7 +20,7 @@ def alert(recipient, alert, locals={})

def alert_grouped(recipient, alert, locals={})

mail(:from => 'do-not-reply@fluxxlabs.com', :reply_to => from_email_address, :to => recipient.is_a?(User) ? recipient.mailer_email : recipient.to_s,
mail(:from => from_email_address, :reply_to => from_email_address, :to => recipient.is_a?(User) ? recipient.mailer_email : recipient.to_s,
:subject => alert.liquid_subject(locals.merge('recipient' => recipient))) do |format|
format.html { render :text => alert.liquid_body(locals.merge('recipient' => recipient)) }
end
Expand Down
10 changes: 7 additions & 3 deletions lib/extensions/mailers/fluxx_user_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
module FluxxUserMailer
extend FluxxModuleHelper

when_included do
default :return_path => 'system@fluxxlabs.com'
end

instance_methods do
def from_email_address
Fluxx.config(:from_email_address)
Fluxx.config(:from_email_address) || 'do-not-reply@fluxxlabs.com'
end

def forgot_password(user, reset_link)
@reset_password_link = reset_link

mail(:to => user.mailer_email,
:subject => "Password Reset",
:from => 'do-not-reply@fluxxlabs.com', :reply_to => from_email_address,
:from => from_email_address, :reply_to => from_email_address,
:fail_to => from
) do |format|
format.text
Expand All @@ -24,7 +28,7 @@ def new_user(user)

mail(:to => user.mailer_email,
:subject => "New User Information",
:from => 'do-not-reply@fluxxlabs.com', :reply_to => from_email_address,
:from => from_email_address, :reply_to => from_email_address,
:fail_to => from
) do |format|
format.text
Expand Down

0 comments on commit 892e968

Please sign in to comment.