Skip to content

Commit

Permalink
Merge pull request spree-contrib#1 from r3ap3r2004/master
Browse files Browse the repository at this point in the history
Modified to work with deface and multiple domains
  • Loading branch information
Trung Le committed Jul 6, 2011
2 parents e4609ff + 49dca16 commit 3fc29a2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/controllers/email_sender_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def send_mail

def mail_to_friend
@mail_to_friend = MailToFriend.new(params[:mail_to_friend])
@mail_to_friend.host = request.env["HTTP_HOST"]
respond_to do |format|
format.html do
captcha_passed = !Spree::Captcha::Config[:use_captcha] || verify_recaptcha(:private_key => Spree::Captcha::Config[:private_key])
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/to_friend_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class ToFriendMailer < ActionMailer::Base
default_url_options[:host] = Spree::Config[:site_url]
default :from => Spree::Config[:mails_from]

def mail_to_friend(object, mail)
Expand All @@ -13,6 +12,7 @@ def mail_to_friend(object, mail)
else
opts[:to] = mail.recipient_email
end
default_url_options[:host] = mail.host
opts[:subject] = mail.subject
opts[:reply_to] = mail.sender_email

Expand Down
2 changes: 1 addition & 1 deletion app/models/mail_to_friend.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class MailToFriend
include ActiveModel::Validations
include ActiveModel::Conversion
attr_accessor :subject, :sender_name, :sender_email, :recipient_name, :recipient_email, :message, :recipients, :invalid_recipients, :hide_recipients
attr_accessor :host, :subject, :sender_name, :sender_email, :recipient_name, :recipient_email, :message, :recipients, :invalid_recipients, :hide_recipients

EMAILREGEX = /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,8}$/i

Expand Down
21 changes: 12 additions & 9 deletions lib/spree_email_to_friend_hooks.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
class SpreeEmailToFriendHooks < Spree::ThemeSupport::HookListener
insert_after :admin_configurations_menu do
"<%= configurations_menu_item(I18n.t('captcha.captcha_settings'), admin_captcha_settings_path, I18n.t('captcha.manage_keys')) %>"
end

insert_after :product_description do
%(<p class="email_to_friend">
<%= link_to(t('email_to_friend.send_to_friend'), email_to_friend_url('product', @product)) %>
</p>)
end
Deface::Override.new(:virtual_path => "admin/configurations/index",
:name => "converted_admin_configurations_menu_384123912",
:insert_after => "[data-hook='admin_configurations_menu'], #admin_configurations_menu[data-hook]",
:text => "<%= configurations_menu_item(I18n.t('captcha.captcha_settings'), admin_captcha_settings_path, I18n.t('captcha.manage_keys')) %>",
:disabled => false)
Deface::Override.new(:virtual_path => "products/show",
:name => "converted_product_description_351026984",
:insert_bottom => "[data-hook='product_description'], #product_description[data-hook]",
:text => "<p class=\"email_to_friend\">
<%= link_to(t('email_to_friend.send_to_friend'), email_to_friend_url('product', @product)) %>
</p>",
:disabled => false)
end
1 change: 1 addition & 0 deletions spree_email_to_friend.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_email_to_friend'
Expand Down

0 comments on commit 3fc29a2

Please sign in to comment.