mailto 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +82 -0
- data/Rakefile +8 -0
- data/app/assets/config/mailto_manifest.js +0 -0
- data/app/helpers/mailto_helper.rb +10 -0
- data/config/routes.rb +2 -0
- data/lib/generators/mailto/install/USAGE +8 -0
- data/lib/generators/mailto/install/install_generator.rb +7 -0
- data/lib/generators/mailto/install/templates/mailtos/support.txt.erb +12 -0
- data/lib/mailto/engine.rb +4 -0
- data/lib/mailto/version.rb +3 -0
- data/lib/mailto.rb +20 -0
- data/lib/tasks/mailto_tasks.rake +4 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e1489b60f5885ab72863231dd4e0c287fb5651945b96bcd11d63d9a2261ed664
|
4
|
+
data.tar.gz: 6f4d3e2a53dd2b7b2c9df3ef5c7147800b6b0a4d9941a82d944b08518fe0bdf3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ef31fb17f622a5446d0661f94fa82c60f25bcd71b4d2977e1c7a2d64fcc5fe1a722f45ebd58381ea8bf7d4487338edfc5b1d9ee46895d497df16fbbe9ade7679
|
7
|
+
data.tar.gz: 60ef731a84b88f3aefa1008bf93b658642188471a9c64739cbaa2142afb860b175cc873d6eace7131228a0dd9148946017c83dfd7a638ae259040ef82ea405e5
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2022 Brad Gessler
|
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,82 @@
|
|
1
|
+
# Mailto
|
2
|
+
|
3
|
+
Mailto makes it easy to create mailto templates that customers can use to communicate quickly and efficiently with you. The result? You don't have to worry about the complexity of "contact us" forms, weird pop-up chat windows, and all that non-sense. It's just conversation between you and your customer over email.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Run from the root of your Rails application:
|
8
|
+
|
9
|
+
```sh
|
10
|
+
$ bundle add "mailto"
|
11
|
+
```
|
12
|
+
|
13
|
+
Then install it by running:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ ./bin/rails generate mailto:install
|
17
|
+
```
|
18
|
+
|
19
|
+
This creates the `./app/mailtos` directory and populates it with a few example templates, like `./app/mailtos/support.txt.erb`.
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Create a mailto template in the `app/mailtos` folder that looks like this:
|
24
|
+
|
25
|
+
```txt
|
26
|
+
---
|
27
|
+
subject: Having trouble at <%= request.url %>
|
28
|
+
to: support@example.com
|
29
|
+
---
|
30
|
+
|
31
|
+
Greetings,
|
32
|
+
|
33
|
+
I was trying to request the page <%= request.url %> and it said there was an error. Could you please have a look?
|
34
|
+
|
35
|
+
Here's my browser information: <%= request.user_agent %>
|
36
|
+
|
37
|
+
Cheers!
|
38
|
+
```
|
39
|
+
|
40
|
+
Then load the `mail_to_template` view helper from any of your views:
|
41
|
+
|
42
|
+
```
|
43
|
+
<h1>Get help!</h1>
|
44
|
+
|
45
|
+
<p>
|
46
|
+
If you're still having trouble after reading our <a href="/support">support docs</a>, you can
|
47
|
+
<% mail_to_template :support, "send us an email" %> and we'll check it out.
|
48
|
+
</p>
|
49
|
+
```
|
50
|
+
|
51
|
+
When the user clicks on the link, they'll get an email that's populated with the contents of your template.
|
52
|
+
|
53
|
+
### Production use case
|
54
|
+
|
55
|
+
[Rocketship](https://rocketship.io/) uses mailto templates on its websites, like [Legible News](https://www.legiblenews.com/) to streamline communications with customers.
|
56
|
+
|
57
|
+
Here's what it looks like for an error when a page isn't found:
|
58
|
+
|
59
|
+
```txt
|
60
|
+
---
|
61
|
+
subject: Not found error at <%= request.url %>
|
62
|
+
to: support@legiblenews.com
|
63
|
+
---
|
64
|
+
|
65
|
+
Greetings,
|
66
|
+
|
67
|
+
I was trying to request the page <%= request.url %> and it said it couldn't be found, but I'm pretty sure this should work. Could you please have a look?
|
68
|
+
|
69
|
+
Cheers!
|
70
|
+
```
|
71
|
+
|
72
|
+
When the customer clicks on the "email support" link, the templates is populated in their email:
|
73
|
+
|
74
|
+
![Email message is populated with contents of template when a customer clicks on the mailto link](https://s3.amazonaws.com/bradgessler/OTvCp9Xd3X6LkRNfSSN1jcTRPW9ezlt3oCw5R9R19sjyCa1Ywv2nbtRc9LtwMSxWLJ75X4mYm6Al90q6dNYcLEivnONalotmlQKa.png)
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
Open an recreatable issue or a PR with a fix and tests.
|
79
|
+
|
80
|
+
## License
|
81
|
+
|
82
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Make it a little easier to integrate email into support flows, etc.
|
2
|
+
module MailtoHelper
|
3
|
+
def mail_to_template(template, text, **kwargs)
|
4
|
+
contents = File.read Rails.root.join("app/mailtos/#{template}.txt.erb")
|
5
|
+
parser = Mailto::Frontmatter.new render inline: contents
|
6
|
+
data = parser.data.merge("body": parser.body)
|
7
|
+
email = data.delete("to")
|
8
|
+
mail_to email, text, **data.merge(kwargs)
|
9
|
+
end
|
10
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
subject: Having trouble at <%= request.url %>
|
3
|
+
to: support@example.com
|
4
|
+
---
|
5
|
+
|
6
|
+
Greetings,
|
7
|
+
|
8
|
+
I was trying to request the page <%= request.url %> and it said there was an error. Could you please have a look?
|
9
|
+
|
10
|
+
Here's my browser information: <%= request.user_agent %>
|
11
|
+
|
12
|
+
Cheers!
|
data/lib/mailto.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "mailto/version"
|
2
|
+
require "mailto/engine"
|
3
|
+
|
4
|
+
module Mailto
|
5
|
+
class Frontmatter
|
6
|
+
DELIMITER = "---".freeze
|
7
|
+
NEWLINE = /\r\n?|\n/.freeze
|
8
|
+
PATTERN = /\A(#{DELIMITER}#{NEWLINE}(.+?)#{NEWLINE}#{DELIMITER}#{NEWLINE}*)?(.+)\Z/m
|
9
|
+
|
10
|
+
attr_reader :body
|
11
|
+
|
12
|
+
def initialize(content)
|
13
|
+
_, @data, @body = content.match(PATTERN).captures
|
14
|
+
end
|
15
|
+
|
16
|
+
def data
|
17
|
+
@data ? YAML.load(@data) : {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mailto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brad Gessler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-01 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: 7.0.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 7.0.3
|
27
|
+
description: Use email for customer communications.
|
28
|
+
email:
|
29
|
+
- bradgessler@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- app/assets/config/mailto_manifest.js
|
38
|
+
- app/helpers/mailto_helper.rb
|
39
|
+
- config/routes.rb
|
40
|
+
- lib/generators/mailto/install/USAGE
|
41
|
+
- lib/generators/mailto/install/install_generator.rb
|
42
|
+
- lib/generators/mailto/install/templates/mailtos/support.txt.erb
|
43
|
+
- lib/mailto.rb
|
44
|
+
- lib/mailto/engine.rb
|
45
|
+
- lib/mailto/version.rb
|
46
|
+
- lib/tasks/mailto_tasks.rake
|
47
|
+
homepage: https://github.com/rocketshipio/mailto
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
metadata:
|
51
|
+
allowed_push_host: https://rubygems.org/
|
52
|
+
homepage_uri: https://github.com/rocketshipio/mailto
|
53
|
+
source_code_uri: https://github.com/rocketshipio/mailto
|
54
|
+
changelog_uri: https://github.com/rocketshipio/mailto
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubygems_version: 3.3.15
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Use email for customer communications.
|
74
|
+
test_files: []
|