-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from digitaltom/email
Implement sending picture sets by email
- Loading branch information
Showing
21 changed files
with
179 additions
and
17 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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require File.expand_path('config/application', __dir__) | ||
|
||
Rails.application.load_tasks |
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.container.mail-container | ||
.row | ||
.col-sm-12 | ||
%p.lead.text-center | ||
Get your picture send to you immediately: | ||
.row | ||
.col-sm-10 | ||
%form.center-block | ||
.form-group | ||
%input.input-lg.form-control#email{ 'ng-model' => 'emailFormData.email', 'type' => 'email', 'placeholder' => 'Email', 'size' => '20' } | ||
.col-sm-2 | ||
%a.btn.btn-default.btn-lg{ 'ng-click' => "send_email()" } | ||
%b Send email | ||
.row | ||
.col-sm-12 | ||
%img.img-responsive.center-block{'ng-src'=>'/{{picture_set.path}}/{{picture_set.animation}}'} | ||
|
||
.row.text-center | ||
%a.btn.btn-default.btn-lg{ 'ng-href' => "#/picture_set/{{picture_set.date}}" } | ||
%b Back |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module PictureSets | ||
class EmailsController < ApplicationController | ||
|
||
def create | ||
picture_set = PictureSet.find(params[:picture_set_id]) | ||
Thread.new do | ||
::PictureSetMailer.image_email(params[:email], picture_set).deliver_now | ||
end | ||
render json: '' | ||
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class ApplicationMailer < ActionMailer::Base | ||
default from: OPTS.mail_settings['from'] | ||
layout 'mailer' | ||
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class PictureSetMailer < ApplicationMailer | ||
|
||
def image_email(email, picture_set) | ||
image_path = Rails.root.join('public', picture_set[:path]) | ||
attachments.inline['animation.gif'] = File.read(File.join(image_path, picture_set[:animation])) | ||
if File.exist?(File.join(image_path, picture_set[:combined])) | ||
attachments.inline['combined.jpg'] = File.read(File.join(image_path, picture_set[:combined])) | ||
end | ||
I18n.with_locale(OPTS.locale) do | ||
mail(to: email, subject: I18n.t('picture_set_mailer.image_email.subject', name: OPTS.image_caption)) | ||
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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
!!! | ||
%html | ||
%head | ||
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ | ||
%body{ 'style' => "background-color: #{OPTS.background_color};" } | ||
= yield |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
%div{ 'style' => "text-align: center; color: #{OPTS.font_color};" } | ||
%h1 | ||
= t('.header', name: OPTS.image_caption) | ||
%p | ||
= t('.content') | ||
%p | ||
= t('.greeting') | ||
%p | ||
= image_tag attachments['animation.gif'].url | ||
- if attachments.inline['combined.jpg'] | ||
%p | ||
= image_tag attachments['combined.jpg'].url |
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Files in the config/locales directory are used for internationalization | ||
# and are automatically loaded by Rails. If you want to use locales other | ||
# than English, add the necessary files in this directory. | ||
# | ||
# To use the locales, use `I18n.t`: | ||
# | ||
# I18n.t 'hello' | ||
# | ||
# In views, this is aliased to just `t`: | ||
# | ||
# <%= t('hello') %> | ||
# | ||
# To use a different locale, set it with `I18n.locale`: | ||
# | ||
# I18n.locale = :es | ||
# | ||
# This would use the information in config/locales/es.yml. | ||
# | ||
# To learn more, please read the Rails Internationalization guide | ||
# available at http://guides.rubyonrails.org/i18n.html. | ||
|
||
de: | ||
picture_set_mailer: | ||
image_email: | ||
subject: "Deine Photobox Bilder von '%{name}'" | ||
header: 'Viele Grüße von %{name}' | ||
content: 'Wir hoffen du hattest eine ebenso unvergessliche Zeit wie wir. Vier dieser einmaligen Momente haben wir für dich festgehalten. Hier sind deine Erinnerungsstücke!' | ||
greeting: 'Viel Spaß!' |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.