-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds more comments & documentation, moves env variables over to travi…
…s, bumps to V 0.0.8
- Loading branch information
Showing
11 changed files
with
95 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
simple_contact (0.0.7) | ||
simple_contact (0.0.8) | ||
rails (~> 3.2.15) | ||
|
||
GEM | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
require_dependency "simple_contact/application_controller" | ||
|
||
class SimpleContact::ContactController < SimpleContact::ApplicationController | ||
|
||
def new | ||
@message = SimpleContact::Message.new | ||
end | ||
|
||
def create | ||
@message = SimpleContact::Message.new(params[:message]) | ||
|
||
if @message.valid? | ||
SimpleContact::ContactMailer.contact_message(@message).deliver | ||
redirect_to main_app.root_path, notice: I18n.translate(:mailer_success_message) | ||
else | ||
flash.now.alert = "#{I18n.translate(:mailer_error_message)}" | ||
flash.now.alert = I18n.translate(:mailer_error_message) | ||
render :new | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
class SimpleContact::ContactMailer < ActionMailer::Base | ||
|
||
# The to, cc, and bcc addresses can be customized in your own application by creating the appropriate environment variables ENV['SIMPLE_CONTACT_TO_EMAIL'], ENV['SIMPLE_CONTACT_CC_EMAIL'], ENV['SIMPLE_CONTACT_BCC_EMAIL'] respectively | ||
# An optional subject prefix can be customized in your own application by creating the environment variable ENV['SIMPLE_CONTACT_SUBJECT_PREFIX']. e.g. if ENV['SIMPLE_CONTACT_SUBJECT_PREFIX'] = '[Our Cool Site]' the subject would be rendered as "[Our Cool Site] {subject of the message}" | ||
def contact_message(message) | ||
@message = message | ||
mail(to: ENV['SIMPLE_CONTACT_TO_EMAIL'], from: @message.email, subject: "#{ENV['SIMPLE_CONTACT_SUBJECT_PREFIX']} #{@message.subject}" ) | ||
mail( | ||
to: ENV['SIMPLE_CONTACT_TO_EMAIL'], | ||
cc: ENV['SIMPLE_CONTACT_CC_EMAIL'], | ||
bcc: ENV['SIMPLE_CONTACT_BCC_EMAIL'], | ||
from: @message.email, | ||
subject: [ENV['SIMPLE_CONTACT_SUBJECT_PREFIX'], @message.subject].join(' ') | ||
) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
app/views/simple_contact/contact_mailer/contact_message.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
<%# This message is left very basic by default. It is designed to be customized %> | ||
<h3> You've received a new message from: <%= mail_to @message.email, @message.name %> </h3> | ||
|
||
<hr /> | ||
|
||
<h3> <%=@message.subject %> </h3> | ||
|
||
<%= simple_format(@message.body) %> | ||
|
||
<br /> | ||
<hr /> | ||
|
||
<p> Please respond to <%= @message.name %> as soon as possible. </p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module SimpleContact | ||
VERSION = "0.0.7" | ||
VERSION = "0.0.8" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters