louismrose-delivery 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.textile +75 -0
- data/Rakefile +41 -0
- data/app/controllers/delivery/subscriptions_controller.rb +33 -0
- data/app/views/delivery/subscriptions/new.html.erb +7 -0
- data/config/delivery_routes.rb +5 -0
- data/lib/delivery.rb +12 -0
- data/rails/init.rb +1 -0
- metadata +65 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Louis Rose
|
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.textile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
h1. Delivery
|
2
|
+
|
3
|
+
Delivery is a Rails engine, providing a simple mailing list.
|
4
|
+
|
5
|
+
Currently, Delivery supports:
|
6
|
+
* only one mailing list
|
7
|
+
* new subscriptions to the mailing list
|
8
|
+
* email notifications of new subscribers to the mailing list
|
9
|
+
|
10
|
+
Right now, the features are few but they suit my needs!
|
11
|
+
|
12
|
+
h2. Installation
|
13
|
+
|
14
|
+
Delivery is a Rails engine. It works with versions of Rails greater than 2.3.
|
15
|
+
|
16
|
+
In config/environment.rb:
|
17
|
+
|
18
|
+
<pre>
|
19
|
+
<code>
|
20
|
+
config.gem "louismrose-delivery",
|
21
|
+
:lib => 'delivery',
|
22
|
+
:source => 'http://gems.github.com',
|
23
|
+
:version => '0.1.1'
|
24
|
+
</code>
|
25
|
+
</pre>
|
26
|
+
|
27
|
+
Vendor the gem:
|
28
|
+
|
29
|
+
<pre>
|
30
|
+
<code>
|
31
|
+
rake gems:install
|
32
|
+
rake gems:unpack
|
33
|
+
</code>
|
34
|
+
</pre>
|
35
|
+
|
36
|
+
|
37
|
+
h2. Environment
|
38
|
+
|
39
|
+
Define a DELIVERY_OPTIONS constant in your environment files. Delivery uses "Pony":http://github.com/adamwiggins/pony to send email notifications. You must specify all the necessary Pony options (other than subject and body).
|
40
|
+
|
41
|
+
An example using SMTP (note the use of :password, rather than :pass which the Pony documentation incorrectly suggests):
|
42
|
+
<pre>
|
43
|
+
<code>
|
44
|
+
DELIVERY_OPTIONS = {
|
45
|
+
:to => 'admin@example.com',
|
46
|
+
:from => 'mailer@example.com',
|
47
|
+
:via => :smtp,
|
48
|
+
:smtp => {
|
49
|
+
:host => 'localhost',
|
50
|
+
:port => '25',
|
51
|
+
:user => 'mailer+example.com',
|
52
|
+
:password => 'secret',
|
53
|
+
:auth => :login,
|
54
|
+
:domain => 'www.example.com'
|
55
|
+
}
|
56
|
+
}
|
57
|
+
</code>
|
58
|
+
</pre>
|
59
|
+
|
60
|
+
For a full discussion of these options, see the "Pony documentation":http://github.com/adamwiggins/pony.
|
61
|
+
|
62
|
+
Define root_url to *something* in your config/routes.rb:
|
63
|
+
<pre>
|
64
|
+
<code>
|
65
|
+
map.root :controller => 'home'
|
66
|
+
</code>
|
67
|
+
</pre>
|
68
|
+
|
69
|
+
|
70
|
+
h1. Contributing
|
71
|
+
|
72
|
+
TODO.
|
73
|
+
|
74
|
+
|
75
|
+
Copyright (c) 2009 Louis Rose, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the delivery plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the delivery plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'Delivery'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
gem_spec = Gem::Specification.new do |s|
|
27
|
+
s.name = "delivery"
|
28
|
+
s.version = "0.1.1"
|
29
|
+
s.author = "Louis Rose"
|
30
|
+
s.email = "louismrose@gmail.com"
|
31
|
+
s.homepage = "http://github.com/louismrose/delivery"
|
32
|
+
s.summary = "Delivery is a Rails engine, providing a simple mailing list."
|
33
|
+
s.files = FileList["[A-Z]*", "{app,config,lib,rails}/**/*"]
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Generate gemspec for the delivery plugin."
|
37
|
+
task :gemspec do
|
38
|
+
File.open("#{gem_spec.name}.gemspec", 'w') do |f|
|
39
|
+
f.write gem_spec.to_yaml
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'pony'
|
2
|
+
|
3
|
+
class Delivery::SubscriptionsController < ApplicationController
|
4
|
+
attr_reader :emails
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@emails = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
render 'delivery/subscriptions/new'
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
send_new_subscription_email params[:email]
|
16
|
+
|
17
|
+
flash[:notice] = 'Thanks for subscribing to our mailing list.'
|
18
|
+
|
19
|
+
redirect_to :root
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def send_new_subscription_email(subscriber_email)
|
25
|
+
options = DELIVERY_OPTIONS.merge({ :body => "Subscriber: #{subscriber_email}" })
|
26
|
+
|
27
|
+
if options[:via] == :test
|
28
|
+
@emails << options
|
29
|
+
else
|
30
|
+
Pony.mail options
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/delivery.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module Delivery
|
2
|
+
end
|
3
|
+
|
4
|
+
class ActionController::Routing::RouteSet
|
5
|
+
def load_routes_with_delivery!
|
6
|
+
delivery_routes = File.join(File.dirname(__FILE__), *%w[.. config delivery_routes.rb])
|
7
|
+
add_configuration_file(delivery_routes) unless configuration_files.include? delivery_routes
|
8
|
+
load_routes_without_delivery!
|
9
|
+
end
|
10
|
+
|
11
|
+
alias_method_chain :load_routes!, :delivery
|
12
|
+
end
|
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'delivery'
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: louismrose-delivery
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Louis Rose
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-22 16:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: louismrose@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- MIT-LICENSE
|
26
|
+
- Rakefile
|
27
|
+
- README.textile
|
28
|
+
- app/controllers
|
29
|
+
- app/controllers/delivery
|
30
|
+
- app/controllers/delivery/subscriptions_controller.rb
|
31
|
+
- app/views
|
32
|
+
- app/views/delivery
|
33
|
+
- app/views/delivery/subscriptions
|
34
|
+
- app/views/delivery/subscriptions/new.html.erb
|
35
|
+
- config/delivery_routes.rb
|
36
|
+
- lib/delivery.rb
|
37
|
+
- rails/init.rb
|
38
|
+
has_rdoc: false
|
39
|
+
homepage: http://github.com/louismrose/delivery
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.2.0
|
61
|
+
signing_key:
|
62
|
+
specification_version: 2
|
63
|
+
summary: Delivery is a Rails engine, providing a simple mailing list.
|
64
|
+
test_files: []
|
65
|
+
|