nullstyle-railmail 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.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +58 -0
- data/VERSION +1 -0
- data/app/controllers/railmail_controller.rb +31 -0
- data/app/helpers/railmail_helper.rb +25 -0
- data/app/models/railmail_delivery.rb +17 -0
- data/app/views/layouts/_javascripts.erb +5 -0
- data/app/views/layouts/_styles.erb +93 -0
- data/app/views/layouts/railmail.html.erb +25 -0
- data/app/views/railmail/_delivery.html.erb +28 -0
- data/app/views/railmail/index.html.erb +11 -0
- data/app/views/railmail/read.rjs +6 -0
- data/generators/railmail_migration/USAGE +15 -0
- data/generators/railmail_migration/railmail_migration_generator.rb +12 -0
- data/generators/railmail_migration/templates/migration.rb +16 -0
- data/lib/railmail/action_mailer.rb +22 -0
- data/lib/railmail.rb +5 -0
- data/rails/init.rb +1 -0
- data/test/railmail_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +77 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Scott Fleckenstein
|
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.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "railmail"
|
8
|
+
gem.summary = %Q{Provides a mock actionmailer with a web interface}
|
9
|
+
gem.email = "nullstyle@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/nullstyle/railmail"
|
11
|
+
gem.authors = ["Scott Fleckenstein"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
gem.files += Dir['{app,generators,rails,lib}/**/*']
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/*_test.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/*_test.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
if File.exist?('VERSION.yml')
|
47
|
+
config = YAML.load(File.read('VERSION.yml'))
|
48
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
49
|
+
else
|
50
|
+
version = ""
|
51
|
+
end
|
52
|
+
|
53
|
+
rdoc.rdoc_dir = 'rdoc'
|
54
|
+
rdoc.title = "railmail #{version}"
|
55
|
+
rdoc.rdoc_files.include('README*')
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
+
end
|
58
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class RailmailController < ApplicationController
|
2
|
+
layout 'railmail'
|
3
|
+
before_filter :load_delivery, :except => [:index, :styles, :javascripts]
|
4
|
+
|
5
|
+
def index
|
6
|
+
@deliveries = RailmailDelivery.find :all, :order => 'sent_at DESC',
|
7
|
+
:limit => 30
|
8
|
+
end
|
9
|
+
|
10
|
+
def read
|
11
|
+
@delivery.read_at = Time.now
|
12
|
+
@delivery.save!
|
13
|
+
end
|
14
|
+
|
15
|
+
def raw
|
16
|
+
render :text => @delivery.raw.to_s, :content_type => 'text/plain'
|
17
|
+
end
|
18
|
+
|
19
|
+
def part
|
20
|
+
@raw = @delivery.raw
|
21
|
+
@mime = params[:part]
|
22
|
+
|
23
|
+
@part = @raw.parts.select {|p| p.content_type == @mime }.first
|
24
|
+
render :text => @part.body.to_s, :content_type => @mime
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def load_delivery
|
29
|
+
@delivery = RailmailDelivery.find params[:id]
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RailmailHelper
|
2
|
+
def delivery_body(d)
|
3
|
+
raw = d.raw
|
4
|
+
return raw if raw.is_a? String
|
5
|
+
return raw.body unless raw.multipart?
|
6
|
+
|
7
|
+
part = get_body(raw, 'text/html')
|
8
|
+
part ||= begin
|
9
|
+
body = get_body(raw, 'text/plain')
|
10
|
+
if body
|
11
|
+
"<pre class=\"plain_text\">#{body}</pre>"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
part ||= raw.parts.first.body
|
15
|
+
part
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def get_body(raw, mime)
|
20
|
+
part = raw.parts.select{|p| p.content_type == mime}
|
21
|
+
if part.first
|
22
|
+
part.first.body
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class RailmailDelivery < ActiveRecord::Base
|
2
|
+
serialize :recipients
|
3
|
+
serialize :from
|
4
|
+
serialize :raw
|
5
|
+
|
6
|
+
def new?
|
7
|
+
read_at.nil?
|
8
|
+
end
|
9
|
+
|
10
|
+
def friendly_from
|
11
|
+
(from || []).join(", ")
|
12
|
+
end
|
13
|
+
|
14
|
+
def friendly_recipients
|
15
|
+
(recipients || []).join(", ")
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
body { margin: 0; padding: 0;}
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
#banner {
|
10
|
+
margin: 0;
|
11
|
+
padding: 1em;
|
12
|
+
font-size: 18pt;
|
13
|
+
background: #000;
|
14
|
+
color: #fff;
|
15
|
+
}
|
16
|
+
|
17
|
+
body * {
|
18
|
+
margin: 0;
|
19
|
+
padding: 0;
|
20
|
+
}
|
21
|
+
|
22
|
+
tr.summary td {
|
23
|
+
cursor: pointer;
|
24
|
+
padding-left: 0.2em;
|
25
|
+
padding-right: 0.2em;
|
26
|
+
}
|
27
|
+
|
28
|
+
#deliveries
|
29
|
+
{
|
30
|
+
width: 100%;
|
31
|
+
padding: 1em;
|
32
|
+
border-collapse: collapse;
|
33
|
+
border-bottom: solid 1px black;
|
34
|
+
}
|
35
|
+
|
36
|
+
#deliveries th {
|
37
|
+
text-align: left;
|
38
|
+
font-size: 12pt;
|
39
|
+
border-bottom: solid 1px black;
|
40
|
+
}
|
41
|
+
|
42
|
+
#deliveries td {
|
43
|
+
font-size: 9pt;
|
44
|
+
}
|
45
|
+
|
46
|
+
br.clear {
|
47
|
+
clear: both;
|
48
|
+
}
|
49
|
+
|
50
|
+
.delivery .details {
|
51
|
+
display: none;
|
52
|
+
}
|
53
|
+
|
54
|
+
ul.delivery_operations {
|
55
|
+
font-size: smaller;
|
56
|
+
}
|
57
|
+
|
58
|
+
ul.delivery_operations li {
|
59
|
+
display: inline;
|
60
|
+
float: left;
|
61
|
+
margin-left: 1.0em;
|
62
|
+
}
|
63
|
+
|
64
|
+
tbody.delivery {
|
65
|
+
border-bottom: solid 1px #888;
|
66
|
+
}
|
67
|
+
|
68
|
+
tbody.new {
|
69
|
+
font-weight: bolder;
|
70
|
+
}
|
71
|
+
|
72
|
+
div.delivery_body {
|
73
|
+
padding-left: 2em;
|
74
|
+
margin-left: 1em;
|
75
|
+
border-left: solid 2px #888;
|
76
|
+
}
|
77
|
+
|
78
|
+
#from_header {
|
79
|
+
width: 15%;
|
80
|
+
}
|
81
|
+
|
82
|
+
#to_header {
|
83
|
+
width: 30%;
|
84
|
+
}
|
85
|
+
|
86
|
+
#sent_header {
|
87
|
+
width: 13%;
|
88
|
+
}
|
89
|
+
|
90
|
+
#subject_header {
|
91
|
+
width: 42%;
|
92
|
+
}
|
93
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5
|
+
<title>Rail Mail</title>
|
6
|
+
<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" %>
|
7
|
+
|
8
|
+
<script type="text/javascript">
|
9
|
+
/*<![CDATA[*/
|
10
|
+
<%= render :partial => 'layouts/javascripts' %>
|
11
|
+
/*]]>*/
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<style type="text/css">
|
15
|
+
/*<![CDATA[*/
|
16
|
+
<%= render :partial => 'layouts/styles' %>
|
17
|
+
/*]]>*/
|
18
|
+
</style>
|
19
|
+
</head>
|
20
|
+
|
21
|
+
<body>
|
22
|
+
<div class="banner" id="banner">Rail Mail</div>
|
23
|
+
<%= @content_for_layout %>
|
24
|
+
</body>
|
25
|
+
</html>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<tbody class="delivery <%="new" if delivery.new?%>">
|
2
|
+
<tr class="summary">
|
3
|
+
<td><%= delivery.friendly_from %></td>
|
4
|
+
<td><%= delivery.friendly_recipients %></td>
|
5
|
+
<td><%= delivery.subject %></td>
|
6
|
+
<td><%= delivery.sent_at.strftime('%x %X') %></td>
|
7
|
+
</tr>
|
8
|
+
<tr class="details">
|
9
|
+
<td colspan="4">
|
10
|
+
<ul class="delivery_operations">
|
11
|
+
<li><%= link_to "view raw", {:action => "raw", :id => delivery}, :target => "_blank" %></li>
|
12
|
+
<% if delivery.raw.multipart?%>
|
13
|
+
<li>view part:
|
14
|
+
<%=
|
15
|
+
delivery.raw.parts.map do |p|
|
16
|
+
link_to h(p.content_type), {:action => 'part', :id => delivery, :part => p.content_type}, :target => "_blank"
|
17
|
+
end.join ' | '
|
18
|
+
%>
|
19
|
+
</li>
|
20
|
+
<% end %>
|
21
|
+
</ul>
|
22
|
+
<br class="clear" />
|
23
|
+
<div class="delivery_body">
|
24
|
+
<%=delivery_body delivery%>
|
25
|
+
</div>
|
26
|
+
</td>
|
27
|
+
</tr>
|
28
|
+
</tbody>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<table id="deliveries">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th id="from_header">from</th>
|
5
|
+
<th id="to_header">to</th>
|
6
|
+
<th id="subject_header">subject</th>
|
7
|
+
<th id="sent_header">sent at</th>
|
8
|
+
</tr>
|
9
|
+
</thead>
|
10
|
+
<%= render :partial => 'delivery', :collection => @deliveries%>
|
11
|
+
</table>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
page.replace "delivery_#{@delivery.id}", :partial => 'delivery', :locals => { :delivery => @delivery, :active => true }
|
2
|
+
|
3
|
+
page << <<-EOS
|
4
|
+
wire_delivery('delivery_#{@delivery.id}', 'delivery_#{@delivery.id}_summary');
|
5
|
+
wire_resender($$('#delivery_#{@delivery.id} .resend_link').first());
|
6
|
+
EOS
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Description:
|
2
|
+
The railmail table migration generator creates a migration for adding the railmail_deliveries table
|
3
|
+
used by Railmail.
|
4
|
+
|
5
|
+
The generator takes a migration name as its argument. The migration name may be
|
6
|
+
given in CamelCase or under_score.
|
7
|
+
|
8
|
+
The generator creates a migration class in db/migrate prefixed by its number
|
9
|
+
in the queue.
|
10
|
+
|
11
|
+
Example:
|
12
|
+
./script/generate railmail_migration AddRailmailTable
|
13
|
+
|
14
|
+
With 4 existing migrations, this will create an AddRailmailTable migration in the
|
15
|
+
file db/migrate/005_add_railmail_table.rb
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class RailmailMigrationGenerator < Rails::Generator::NamedBase
|
2
|
+
def initialize(runtime_args, runtime_options = {})
|
3
|
+
runtime_args << 'add_railmail_table' if runtime_args.empty?
|
4
|
+
super
|
5
|
+
end
|
6
|
+
|
7
|
+
def manifest
|
8
|
+
record do |m|
|
9
|
+
m.migration_template 'migration.rb', 'db/migrate'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class <%= class_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :railmail_deliveries do |t|
|
4
|
+
t.text :recipients
|
5
|
+
t.string :from
|
6
|
+
t.text :subject
|
7
|
+
t.datetime :sent_at
|
8
|
+
t.datetime :read_at
|
9
|
+
t.text :raw
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :railmail_deliveries
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Railmail
|
2
|
+
module ActionMailer
|
3
|
+
|
4
|
+
module InstanceMethods
|
5
|
+
@@railmail_settings = {}
|
6
|
+
mattr_accessor :railmail_settings
|
7
|
+
|
8
|
+
def perform_delivery_railmail(mail)
|
9
|
+
r = RailmailDelivery.new
|
10
|
+
|
11
|
+
r.recipients = mail.to
|
12
|
+
r.from = mail.from
|
13
|
+
r.subject = mail.subject
|
14
|
+
r.sent_at = Time.now
|
15
|
+
r.raw = mail
|
16
|
+
|
17
|
+
r.save!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/lib/railmail.rb
ADDED
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'railmail'
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nullstyle-railmail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Fleckenstein
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-26 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: nullstyle@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .document
|
27
|
+
- .gitignore
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- VERSION
|
32
|
+
- app/controllers/railmail_controller.rb
|
33
|
+
- app/helpers/railmail_helper.rb
|
34
|
+
- app/models/railmail_delivery.rb
|
35
|
+
- app/views/layouts/_javascripts.erb
|
36
|
+
- app/views/layouts/_styles.erb
|
37
|
+
- app/views/layouts/railmail.html.erb
|
38
|
+
- app/views/railmail/_delivery.html.erb
|
39
|
+
- app/views/railmail/index.html.erb
|
40
|
+
- app/views/railmail/read.rjs
|
41
|
+
- generators/railmail_migration/USAGE
|
42
|
+
- generators/railmail_migration/railmail_migration_generator.rb
|
43
|
+
- generators/railmail_migration/templates/migration.rb
|
44
|
+
- lib/railmail.rb
|
45
|
+
- lib/railmail/action_mailer.rb
|
46
|
+
- rails/init.rb
|
47
|
+
- test/railmail_test.rb
|
48
|
+
- test/test_helper.rb
|
49
|
+
has_rdoc: false
|
50
|
+
homepage: http://github.com/nullstyle/railmail
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options:
|
53
|
+
- --charset=UTF-8
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.2.0
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Provides a mock actionmailer with a web interface
|
75
|
+
test_files:
|
76
|
+
- test/railmail_test.rb
|
77
|
+
- test/test_helper.rb
|