action_mailer_auto_url_options 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +57 -0
- data/Rakefile +22 -0
- data/lib/action_mailer_auto_url_options.rb +2 -0
- data/lib/action_mailer_auto_url_options/controller.rb +20 -0
- data/lib/action_mailer_auto_url_options/engine.rb +9 -0
- data/lib/action_mailer_auto_url_options/middleware/sidekiq.rb +36 -0
- data/lib/action_mailer_auto_url_options/version.rb +3 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4f9116fa35c026254314d6e822815ee50e8261be
|
4
|
+
data.tar.gz: ffd7a963374190575c2b59c8f63370ce0d9d4bd9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d5832f4c3b2c3188750d4d63c919bed90818f7a801f25ab60ac4c10f473d61bb6c01bd3bc910536afcd1862d8edc4d19be91b2c43cde17fd99210b0a6f52c62a
|
7
|
+
data.tar.gz: d6828c9fa57980a2340d3d7ef907ad72282a2b755143118a5883da217c2359f43efff6f07f171ba6445cb30b01e2c739cb39a368e5a5803efef84ecc80dc48d9
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 Sunny Ripert
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
ActionMailer automatic URL options
|
2
|
+
==================================
|
3
|
+
|
4
|
+
Make ActionMailer use the current request host, port and protocol for URL
|
5
|
+
generation.
|
6
|
+
|
7
|
+
|
8
|
+
Why?
|
9
|
+
----
|
10
|
+
|
11
|
+
In Rails apps, if you create links in your emails, you need to set the
|
12
|
+
host, port and protocol in every environment configuration file you use.
|
13
|
+
|
14
|
+
This plugin removes that need by using the current request's host, port and
|
15
|
+
protocol instead.
|
16
|
+
|
17
|
+
This is also helpful when you use different domain names, based on the language
|
18
|
+
for example.
|
19
|
+
|
20
|
+
|
21
|
+
Install
|
22
|
+
-------
|
23
|
+
|
24
|
+
Add this line to your Rails application's Gemfile:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
gem 'action_mailer_auto_url_options'
|
28
|
+
```
|
29
|
+
|
30
|
+
Run `bundle install`, restart your server and that's it!
|
31
|
+
|
32
|
+
|
33
|
+
Usage with Sidekiq
|
34
|
+
------------------
|
35
|
+
|
36
|
+
If you delay your emails with Sidekiq, include this middleware in your
|
37
|
+
`sidekiq.rb` initializer:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
require "action_mailer_auto_url_options/middleware/sidekiq"
|
41
|
+
```
|
42
|
+
|
43
|
+
|
44
|
+
Security considerations
|
45
|
+
-----------------------
|
46
|
+
|
47
|
+
This does not protect you from host-injection exploits, so please whitelist
|
48
|
+
requests to the allowed domain name in production.
|
49
|
+
|
50
|
+
Read more about [this vulnerability](http://seclists.org/fulldisclosure/2008/Jun/169)
|
51
|
+
because your app may already be vulnerable if it does any kind of cache.
|
52
|
+
|
53
|
+
|
54
|
+
License
|
55
|
+
-------
|
56
|
+
|
57
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# bundler
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
# rdoc
|
10
|
+
require 'rdoc/task'
|
11
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
+
rdoc.rdoc_dir = 'rdoc'
|
13
|
+
rdoc.title = 'LayoutValues'
|
14
|
+
rdoc.options << '--line-numbers'
|
15
|
+
rdoc.rdoc_files.include('README.rdoc')
|
16
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
17
|
+
end
|
18
|
+
|
19
|
+
# rspec
|
20
|
+
require 'rspec/core/rake_task'
|
21
|
+
RSpec::Core::RakeTask.new(:spec)
|
22
|
+
task :default => :spec
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActionMailerAutoUrlOptions
|
2
|
+
|
3
|
+
# Included in the app's Application Controller
|
4
|
+
module Controller
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
before_filter :make_action_mailer_use_request_host_and_protocol
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Via http://makandracards.com/makandra/1353
|
14
|
+
def make_action_mailer_use_request_host_and_protocol
|
15
|
+
ActionMailer::Base.default_url_options[:protocol] = request.protocol
|
16
|
+
ActionMailer::Base.default_url_options[:host] = request.host_with_port
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Sidekiq::Middleware::ActionMailerDefaultUrlOption
|
2
|
+
# Get the current Action Mailer default URL options and store them in the
|
3
|
+
# message to be sent to Sidekiq.
|
4
|
+
class Client
|
5
|
+
def call(worker_class, msg, queue, redis_pool)
|
6
|
+
options = ActionMailer::Base.default_url_options
|
7
|
+
msg['action_mailer_default_url_options'] ||= options
|
8
|
+
yield
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Pull the message's Action Mailer default URL options out and set the
|
13
|
+
# current thread to use them.
|
14
|
+
class Server
|
15
|
+
def call(worker, msg, queue)
|
16
|
+
options = msg['action_mailer_default_url_options'].symbolize_keys
|
17
|
+
ActionMailer::Base.default_url_options = options if options
|
18
|
+
yield
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Sidekiq.configure_client do |config|
|
24
|
+
config.client_middleware do |chain|
|
25
|
+
chain.add Sidekiq::Middleware::ActionMailerDefaultUrlOption::Client
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Sidekiq.configure_server do |config|
|
30
|
+
config.client_middleware do |chain|
|
31
|
+
chain.add Sidekiq::Middleware::ActionMailerDefaultUrlOption::Client
|
32
|
+
end
|
33
|
+
config.server_middleware do |chain|
|
34
|
+
chain.add Sidekiq::Middleware::ActionMailerDefaultUrlOption::Server
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: action_mailer_auto_url_options
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sunny Ripert
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: combustion
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Make ActionMailer use the current request host and protocol for URL generation
|
56
|
+
email:
|
57
|
+
- sunny@sunfox.org
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/action_mailer_auto_url_options/controller.rb
|
63
|
+
- lib/action_mailer_auto_url_options/engine.rb
|
64
|
+
- lib/action_mailer_auto_url_options/middleware/sidekiq.rb
|
65
|
+
- lib/action_mailer_auto_url_options/version.rb
|
66
|
+
- lib/action_mailer_auto_url_options.rb
|
67
|
+
- MIT-LICENSE
|
68
|
+
- Rakefile
|
69
|
+
- README.md
|
70
|
+
homepage: http://github.com/sunny/action_mailer_auto_url_options
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.1.11
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: ActionMailer automatic URL options
|
94
|
+
test_files: []
|