m2fm-automatic-embeds 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/.gitignore +15 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +9 -0
- data/fixtures/config.yml +25 -0
- data/fixtures/no-links.eml +61 -0
- data/fixtures/soundcloud-link.eml +60 -0
- data/fixtures/wrapped-links.eml +64 -0
- data/fixtures/youtube-link.eml +60 -0
- data/lib/mail2frontmatter/automatic-embeds.rb +58 -0
- data/m2fm-automatic-embeds.gemspec +27 -0
- data/spec/automatic_embed_spec.rb +83 -0
- data/spec/spec_helper.rb +1 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 95b827c2daba74b0813300d30b0d0f6c49c0400e
|
4
|
+
data.tar.gz: dac107c7a913c34b1fc1e095b6dbbf3b93eee499
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3841bdbfbb1cbdd1e6787d91e3f817e515b1dc26efaf0c23c794dd5217a207b5e4269282356f55422f3e1b9936cd8e6a8c49f6724b5dcf8b699ac0e1144196e2
|
7
|
+
data.tar.gz: aad182501865a712129a50e4836b9632d54b7a8fee2591f2c05c070a7c601811bf4687f032ce32eeab06a239ba159ec63118c5d8addab91ae91f230dc28dc3b9
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Kunal Shah
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Mail2FrontMatter::AutomaticEmbeds
|
2
|
+
|
3
|
+
AutomaticEmbeds is a [Mail2FrontMatter](https://github.com/whistlerbrk/mail2frontmatter) plugin which generates embed codes for links. This is a thin layer around the [auto_html](https://github.com/whistlerbrk/auto_html) project to generate the necessary HTML.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'm2fm-automatic-embeds', require: false
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Configuration
|
18
|
+
|
19
|
+
In your Mail2FrontMatter YAML configuration enable the plugin by adding it to your preprocessors:
|
20
|
+
|
21
|
+
```yaml
|
22
|
+
preprocessors:
|
23
|
+
- key: 'automatic-embeds'
|
24
|
+
```
|
25
|
+
|
26
|
+
You can provide a whitelist or blacklist for filters as well as providing filters options. Filter options are documented at the auto_html project.
|
27
|
+
|
28
|
+
```yaml
|
29
|
+
preprocessors:
|
30
|
+
- key: 'automatic-embeds'
|
31
|
+
options:
|
32
|
+
white_list:
|
33
|
+
- youtube
|
34
|
+
- soundcloud
|
35
|
+
- vimeo
|
36
|
+
filters:
|
37
|
+
youtube:
|
38
|
+
autoplay: true
|
39
|
+
other_attribute: other_value
|
40
|
+
```
|
41
|
+
|
42
|
+
## Usage
|
43
|
+
|
44
|
+
That's it! Now incoming links from a number of [content providers](https://github.com/dejan/auto_html/tree/master/lib/auto_html/filters) will be embedded automatically.
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it ( https://github.com/whistlerbrk/m2fm-automatic-embed/fork )
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/fixtures/config.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
keys_demo:
|
2
|
+
white_list:
|
3
|
+
- youtube
|
4
|
+
- soundcloud
|
5
|
+
- vimeo
|
6
|
+
|
7
|
+
white_list_demo:
|
8
|
+
white_list:
|
9
|
+
- youtube
|
10
|
+
- soundcloud
|
11
|
+
- vimeo
|
12
|
+
|
13
|
+
black_list_demo:
|
14
|
+
black_list:
|
15
|
+
- vimeo
|
16
|
+
|
17
|
+
options_demo:
|
18
|
+
white_list:
|
19
|
+
- youtube
|
20
|
+
- soundcloud
|
21
|
+
- vimeo
|
22
|
+
filters:
|
23
|
+
youtube:
|
24
|
+
autoplay: true
|
25
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
Delivered-To: stream@kunalashah.com
|
3
|
+
Received: by 10.216.42.73 with SMTP id i51csp1200401web;
|
4
|
+
Mon, 12 Jan 2015 19:39:33 -0800 (PST)
|
5
|
+
X-Received: by 10.236.41.202 with SMTP id h50mr21052293yhb.140.1421120372875;
|
6
|
+
Mon, 12 Jan 2015 19:39:32 -0800 (PST)
|
7
|
+
Return-Path: <me@kunalashah.com>
|
8
|
+
Received: from mail-yh0-x232.google.com (mail-yh0-x232.google.com. [2607:f8b0:4002:c01::232])
|
9
|
+
by mx.google.com with ESMTPS id 79si10236396ykt.36.2015.01.12.19.39.32
|
10
|
+
for <stream@kunalashah.com>
|
11
|
+
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
|
12
|
+
Mon, 12 Jan 2015 19:39:32 -0800 (PST)
|
13
|
+
Received-SPF: none (google.com: me@kunalashah.com does not designate permitted sender hosts) client-ip=2607:f8b0:4002:c01::232;
|
14
|
+
Authentication-Results: mx.google.com;
|
15
|
+
spf=none (google.com: me@kunalashah.com does not designate permitted sender hosts) smtp.mail=me@kunalashah.com;
|
16
|
+
dkim=pass header.i=@kunalashah.com
|
17
|
+
Received: by mail-yh0-f50.google.com with SMTP id b6so356245yha.9
|
18
|
+
for <stream@kunalashah.com>; Mon, 12 Jan 2015 19:39:31 -0800 (PST)
|
19
|
+
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
20
|
+
d=kunalashah.com; s=google;
|
21
|
+
h=mime-version:date:message-id:subject:from:to:content-type;
|
22
|
+
bh=xvqejrLOBkvtZ/LV00B3w07XE6B1WPIeFwV0y5FOk48=;
|
23
|
+
b=Y310Cno+tXMfIFuHEFvEGd/U+K8EuUQQ+TUFCvla9JZ2m4Agh9Oog5PAETy4RAUXCw
|
24
|
+
OSgzTTYgEpVneeWNu/uXwTucwrTHzSEW2MeLLr/beQsEWLKeW1pg7IcO8o16WrI76nd1
|
25
|
+
xGqh4v/7YVHNK/Lyrrm0/7ANFVrdWu5b37t58=
|
26
|
+
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
27
|
+
d=1e100.net; s=20130820;
|
28
|
+
h=x-gm-message-state:mime-version:date:message-id:subject:from:to
|
29
|
+
:content-type;
|
30
|
+
bh=xvqejrLOBkvtZ/LV00B3w07XE6B1WPIeFwV0y5FOk48=;
|
31
|
+
b=LMSU/hDJIcMdBAId5WcNCGsT6zMUwCSBZXkHry3Ez19XT3tsHF/1V9nthO39yLzJTc
|
32
|
+
lKIIU6TVDOnRtj/6SSsSLLxOFjXu+hiNZsJNR32AzjzBwTZBV4YKFdlemn4tTDQG0Wpb
|
33
|
+
DDjUvzvNHOTT9h8wRQVZIrng1liJXO8Z20msNwdgsS1dB5EK4jCleU21l6KI10eenTHu
|
34
|
+
gbqwOqV2teAZ3gu3J6mR6BkyiRDc5qZuhSasdT+HRzgCRszbv49eaXPBz/Kax4aadhFU
|
35
|
+
zOLWEswjgpC+Rxj5i4WGvf7hIRyAf/9oLVZQW1DSavnOG6frEESyiAU7VJ457XTZw0uK
|
36
|
+
4H4Q==
|
37
|
+
X-Gm-Message-State: ALoCoQnXibjhC9yUZfwNU1j0v/wXuMTj5PBzoZXIMnGz+pWYPziFyExdgJVpO1fjHvGE/gcr3R9/
|
38
|
+
MIME-Version: 1.0
|
39
|
+
X-Received: by 10.170.49.6 with SMTP id 6mr28189061ykr.118.1421120371787; Mon,
|
40
|
+
12 Jan 2015 19:39:31 -0800 (PST)
|
41
|
+
Received: by 10.170.205.16 with HTTP; Mon, 12 Jan 2015 19:39:31 -0800 (PST)
|
42
|
+
X-Originating-IP: [66.108.230.254]
|
43
|
+
Date: Mon, 12 Jan 2015 22:39:31 -0500
|
44
|
+
Message-ID: <CAN-VoWm1nRXKLZk-g368U05SE7_Z9aHV9abL+PEbf-kn=0HDFw@mail.gmail.com>
|
45
|
+
Subject: the earth is the best manufacturer we have
|
46
|
+
From: Kunal Shah <me@kunalashah.com>
|
47
|
+
To: "stream@kunalashah.com" <stream@kunalashah.com>
|
48
|
+
Content-Type: multipart/alternative; boundary=001a11394e8ef1a379050c805e70
|
49
|
+
|
50
|
+
--001a11394e8ef1a379050c805e70
|
51
|
+
Content-Type: text/plain; charset=UTF-8
|
52
|
+
|
53
|
+
- vv
|
54
|
+
|
55
|
+
--001a11394e8ef1a379050c805e70
|
56
|
+
Content-Type: text/html; charset=UTF-8
|
57
|
+
|
58
|
+
<div dir="ltr">- vv
|
59
|
+
</div>
|
60
|
+
|
61
|
+
--001a11394e8ef1a379050c805e70--
|
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
Delivered-To: stream@kunalashah.com
|
3
|
+
Received: by 10.216.42.73 with SMTP id i51csp1200401web;
|
4
|
+
Mon, 12 Jan 2015 19:39:33 -0800 (PST)
|
5
|
+
X-Received: by 10.236.41.202 with SMTP id h50mr21052293yhb.140.1421120372875;
|
6
|
+
Mon, 12 Jan 2015 19:39:32 -0800 (PST)
|
7
|
+
Return-Path: <me@kunalashah.com>
|
8
|
+
Received: from mail-yh0-x232.google.com (mail-yh0-x232.google.com. [2607:f8b0:4002:c01::232])
|
9
|
+
by mx.google.com with ESMTPS id 79si10236396ykt.36.2015.01.12.19.39.32
|
10
|
+
for <stream@kunalashah.com>
|
11
|
+
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
|
12
|
+
Mon, 12 Jan 2015 19:39:32 -0800 (PST)
|
13
|
+
Received-SPF: none (google.com: me@kunalashah.com does not designate permitted sender hosts) client-ip=2607:f8b0:4002:c01::232;
|
14
|
+
Authentication-Results: mx.google.com;
|
15
|
+
spf=none (google.com: me@kunalashah.com does not designate permitted sender hosts) smtp.mail=me@kunalashah.com;
|
16
|
+
dkim=pass header.i=@kunalashah.com
|
17
|
+
Received: by mail-yh0-f50.google.com with SMTP id b6so356245yha.9
|
18
|
+
for <stream@kunalashah.com>; Mon, 12 Jan 2015 19:39:31 -0800 (PST)
|
19
|
+
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
20
|
+
d=kunalashah.com; s=google;
|
21
|
+
h=mime-version:date:message-id:subject:from:to:content-type;
|
22
|
+
bh=xvqejrLOBkvtZ/LV00B3w07XE6B1WPIeFwV0y5FOk48=;
|
23
|
+
b=Y310Cno+tXMfIFuHEFvEGd/U+K8EuUQQ+TUFCvla9JZ2m4Agh9Oog5PAETy4RAUXCw
|
24
|
+
OSgzTTYgEpVneeWNu/uXwTucwrTHzSEW2MeLLr/beQsEWLKeW1pg7IcO8o16WrI76nd1
|
25
|
+
xGqh4v/7YVHNK/Lyrrm0/7ANFVrdWu5b37t58=
|
26
|
+
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
27
|
+
d=1e100.net; s=20130820;
|
28
|
+
h=x-gm-message-state:mime-version:date:message-id:subject:from:to
|
29
|
+
:content-type;
|
30
|
+
bh=xvqejrLOBkvtZ/LV00B3w07XE6B1WPIeFwV0y5FOk48=;
|
31
|
+
b=LMSU/hDJIcMdBAId5WcNCGsT6zMUwCSBZXkHry3Ez19XT3tsHF/1V9nthO39yLzJTc
|
32
|
+
lKIIU6TVDOnRtj/6SSsSLLxOFjXu+hiNZsJNR32AzjzBwTZBV4YKFdlemn4tTDQG0Wpb
|
33
|
+
DDjUvzvNHOTT9h8wRQVZIrng1liJXO8Z20msNwdgsS1dB5EK4jCleU21l6KI10eenTHu
|
34
|
+
gbqwOqV2teAZ3gu3J6mR6BkyiRDc5qZuhSasdT+HRzgCRszbv49eaXPBz/Kax4aadhFU
|
35
|
+
zOLWEswjgpC+Rxj5i4WGvf7hIRyAf/9oLVZQW1DSavnOG6frEESyiAU7VJ457XTZw0uK
|
36
|
+
4H4Q==
|
37
|
+
X-Gm-Message-State: ALoCoQnXibjhC9yUZfwNU1j0v/wXuMTj5PBzoZXIMnGz+pWYPziFyExdgJVpO1fjHvGE/gcr3R9/
|
38
|
+
MIME-Version: 1.0
|
39
|
+
X-Received: by 10.170.49.6 with SMTP id 6mr28189061ykr.118.1421120371787; Mon,
|
40
|
+
12 Jan 2015 19:39:31 -0800 (PST)
|
41
|
+
Received: by 10.170.205.16 with HTTP; Mon, 12 Jan 2015 19:39:31 -0800 (PST)
|
42
|
+
X-Originating-IP: [66.108.230.254]
|
43
|
+
Date: Mon, 12 Jan 2015 22:39:31 -0500
|
44
|
+
Message-ID: <CAN-VoWm1nRXKLZk-g368U05SE7_Z9aHV9abL+PEbf-kn=0HDFw@mail.gmail.com>
|
45
|
+
Subject: Dan's Soundcloud
|
46
|
+
From: Kunal Shah <me@kunalashah.com>
|
47
|
+
To: "stream@kunalashah.com" <stream@kunalashah.com>
|
48
|
+
Content-Type: multipart/alternative; boundary=001a11394e8ef1a379050c805e70
|
49
|
+
|
50
|
+
--001a11394e8ef1a379050c805e70
|
51
|
+
Content-Type: text/plain; charset=UTF-8
|
52
|
+
|
53
|
+
My buddy Dan's track with his bro. https://soundcloud.com/danielamorse/pinball-1
|
54
|
+
|
55
|
+
--001a11394e8ef1a379050c805e70
|
56
|
+
Content-Type: text/html; charset=UTF-8
|
57
|
+
|
58
|
+
<div dir="ltr">My buddy Dan's track with his bro. https://soundcloud.com/danielamorse/pinball-1</div>
|
59
|
+
|
60
|
+
--001a11394e8ef1a379050c805e70--
|
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
Delivered-To: stream@kunalashah.com
|
3
|
+
Received: by 10.216.42.73 with SMTP id i51csp1200401web;
|
4
|
+
Mon, 12 Jan 2015 19:39:33 -0800 (PST)
|
5
|
+
X-Received: by 10.236.41.202 with SMTP id h50mr21052293yhb.140.1421120372875;
|
6
|
+
Mon, 12 Jan 2015 19:39:32 -0800 (PST)
|
7
|
+
Return-Path: <me@kunalashah.com>
|
8
|
+
Received: from mail-yh0-x232.google.com (mail-yh0-x232.google.com. [2607:f8b0:4002:c01::232])
|
9
|
+
by mx.google.com with ESMTPS id 79si10236396ykt.36.2015.01.12.19.39.32
|
10
|
+
for <stream@kunalashah.com>
|
11
|
+
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
|
12
|
+
Mon, 12 Jan 2015 19:39:32 -0800 (PST)
|
13
|
+
Received-SPF: none (google.com: me@kunalashah.com does not designate permitted sender hosts) client-ip=2607:f8b0:4002:c01::232;
|
14
|
+
Authentication-Results: mx.google.com;
|
15
|
+
spf=none (google.com: me@kunalashah.com does not designate permitted sender hosts) smtp.mail=me@kunalashah.com;
|
16
|
+
dkim=pass header.i=@kunalashah.com
|
17
|
+
Received: by mail-yh0-f50.google.com with SMTP id b6so356245yha.9
|
18
|
+
for <stream@kunalashah.com>; Mon, 12 Jan 2015 19:39:31 -0800 (PST)
|
19
|
+
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
20
|
+
d=kunalashah.com; s=google;
|
21
|
+
h=mime-version:date:message-id:subject:from:to:content-type;
|
22
|
+
bh=xvqejrLOBkvtZ/LV00B3w07XE6B1WPIeFwV0y5FOk48=;
|
23
|
+
b=Y310Cno+tXMfIFuHEFvEGd/U+K8EuUQQ+TUFCvla9JZ2m4Agh9Oog5PAETy4RAUXCw
|
24
|
+
OSgzTTYgEpVneeWNu/uXwTucwrTHzSEW2MeLLr/beQsEWLKeW1pg7IcO8o16WrI76nd1
|
25
|
+
xGqh4v/7YVHNK/Lyrrm0/7ANFVrdWu5b37t58=
|
26
|
+
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
27
|
+
d=1e100.net; s=20130820;
|
28
|
+
h=x-gm-message-state:mime-version:date:message-id:subject:from:to
|
29
|
+
:content-type;
|
30
|
+
bh=xvqejrLOBkvtZ/LV00B3w07XE6B1WPIeFwV0y5FOk48=;
|
31
|
+
b=LMSU/hDJIcMdBAId5WcNCGsT6zMUwCSBZXkHry3Ez19XT3tsHF/1V9nthO39yLzJTc
|
32
|
+
lKIIU6TVDOnRtj/6SSsSLLxOFjXu+hiNZsJNR32AzjzBwTZBV4YKFdlemn4tTDQG0Wpb
|
33
|
+
DDjUvzvNHOTT9h8wRQVZIrng1liJXO8Z20msNwdgsS1dB5EK4jCleU21l6KI10eenTHu
|
34
|
+
gbqwOqV2teAZ3gu3J6mR6BkyiRDc5qZuhSasdT+HRzgCRszbv49eaXPBz/Kax4aadhFU
|
35
|
+
zOLWEswjgpC+Rxj5i4WGvf7hIRyAf/9oLVZQW1DSavnOG6frEESyiAU7VJ457XTZw0uK
|
36
|
+
4H4Q==
|
37
|
+
X-Gm-Message-State: ALoCoQnXibjhC9yUZfwNU1j0v/wXuMTj5PBzoZXIMnGz+pWYPziFyExdgJVpO1fjHvGE/gcr3R9/
|
38
|
+
MIME-Version: 1.0
|
39
|
+
X-Received: by 10.170.49.6 with SMTP id 6mr28189061ykr.118.1421120371787; Mon,
|
40
|
+
12 Jan 2015 19:39:31 -0800 (PST)
|
41
|
+
Received: by 10.170.205.16 with HTTP; Mon, 12 Jan 2015 19:39:31 -0800 (PST)
|
42
|
+
X-Originating-IP: [66.108.230.254]
|
43
|
+
Date: Mon, 12 Jan 2015 22:39:31 -0500
|
44
|
+
Message-ID: <CAN-VoWm1nRXKLZk-g368U05SE7_Z9aHV9abL+PEbf-kn=0HDFw@mail.gmail.com>
|
45
|
+
Subject: Lover, Lover, Lover
|
46
|
+
From: Kunal Shah <me@kunalashah.com>
|
47
|
+
To: "stream@kunalashah.com" <stream@kunalashah.com>
|
48
|
+
Content-Type: multipart/alternative; boundary=001a11394e8ef1a379050c805e70
|
49
|
+
|
50
|
+
--001a11394e8ef1a379050c805e70
|
51
|
+
Content-Type: text/plain; charset=UTF-8
|
52
|
+
|
53
|
+
https://www.youtube.com/watch?v=oVURkMTDr3E
|
54
|
+
|
55
|
+
Leonard Cohen
|
56
|
+
|
57
|
+
--001a11394e8ef1a379050c805e70
|
58
|
+
Content-Type: text/html; charset=UTF-8
|
59
|
+
|
60
|
+
<div dir="ltr"><a href="https://www.youtube.com/watch?v=oVURkMTDr3E">https://www.youtube.com/watch?v=oVURkMTDr3E</a><br>
|
61
|
+
<div><br></div><div>Leonard Cohen</div></div>
|
62
|
+
|
63
|
+
--001a11394e8ef1a379050c805e70--
|
64
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
Delivered-To: stream@kunalashah.com
|
3
|
+
Received: by 10.216.42.73 with SMTP id i51csp1200401web;
|
4
|
+
Mon, 12 Jan 2015 19:39:33 -0800 (PST)
|
5
|
+
X-Received: by 10.236.41.202 with SMTP id h50mr21052293yhb.140.1421120372875;
|
6
|
+
Mon, 12 Jan 2015 19:39:32 -0800 (PST)
|
7
|
+
Return-Path: <me@kunalashah.com>
|
8
|
+
Received: from mail-yh0-x232.google.com (mail-yh0-x232.google.com. [2607:f8b0:4002:c01::232])
|
9
|
+
by mx.google.com with ESMTPS id 79si10236396ykt.36.2015.01.12.19.39.32
|
10
|
+
for <stream@kunalashah.com>
|
11
|
+
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
|
12
|
+
Mon, 12 Jan 2015 19:39:32 -0800 (PST)
|
13
|
+
Received-SPF: none (google.com: me@kunalashah.com does not designate permitted sender hosts) client-ip=2607:f8b0:4002:c01::232;
|
14
|
+
Authentication-Results: mx.google.com;
|
15
|
+
spf=none (google.com: me@kunalashah.com does not designate permitted sender hosts) smtp.mail=me@kunalashah.com;
|
16
|
+
dkim=pass header.i=@kunalashah.com
|
17
|
+
Received: by mail-yh0-f50.google.com with SMTP id b6so356245yha.9
|
18
|
+
for <stream@kunalashah.com>; Mon, 12 Jan 2015 19:39:31 -0800 (PST)
|
19
|
+
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
20
|
+
d=kunalashah.com; s=google;
|
21
|
+
h=mime-version:date:message-id:subject:from:to:content-type;
|
22
|
+
bh=xvqejrLOBkvtZ/LV00B3w07XE6B1WPIeFwV0y5FOk48=;
|
23
|
+
b=Y310Cno+tXMfIFuHEFvEGd/U+K8EuUQQ+TUFCvla9JZ2m4Agh9Oog5PAETy4RAUXCw
|
24
|
+
OSgzTTYgEpVneeWNu/uXwTucwrTHzSEW2MeLLr/beQsEWLKeW1pg7IcO8o16WrI76nd1
|
25
|
+
xGqh4v/7YVHNK/Lyrrm0/7ANFVrdWu5b37t58=
|
26
|
+
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
27
|
+
d=1e100.net; s=20130820;
|
28
|
+
h=x-gm-message-state:mime-version:date:message-id:subject:from:to
|
29
|
+
:content-type;
|
30
|
+
bh=xvqejrLOBkvtZ/LV00B3w07XE6B1WPIeFwV0y5FOk48=;
|
31
|
+
b=LMSU/hDJIcMdBAId5WcNCGsT6zMUwCSBZXkHry3Ez19XT3tsHF/1V9nthO39yLzJTc
|
32
|
+
lKIIU6TVDOnRtj/6SSsSLLxOFjXu+hiNZsJNR32AzjzBwTZBV4YKFdlemn4tTDQG0Wpb
|
33
|
+
DDjUvzvNHOTT9h8wRQVZIrng1liJXO8Z20msNwdgsS1dB5EK4jCleU21l6KI10eenTHu
|
34
|
+
gbqwOqV2teAZ3gu3J6mR6BkyiRDc5qZuhSasdT+HRzgCRszbv49eaXPBz/Kax4aadhFU
|
35
|
+
zOLWEswjgpC+Rxj5i4WGvf7hIRyAf/9oLVZQW1DSavnOG6frEESyiAU7VJ457XTZw0uK
|
36
|
+
4H4Q==
|
37
|
+
X-Gm-Message-State: ALoCoQnXibjhC9yUZfwNU1j0v/wXuMTj5PBzoZXIMnGz+pWYPziFyExdgJVpO1fjHvGE/gcr3R9/
|
38
|
+
MIME-Version: 1.0
|
39
|
+
X-Received: by 10.170.49.6 with SMTP id 6mr28189061ykr.118.1421120371787; Mon,
|
40
|
+
12 Jan 2015 19:39:31 -0800 (PST)
|
41
|
+
Received: by 10.170.205.16 with HTTP; Mon, 12 Jan 2015 19:39:31 -0800 (PST)
|
42
|
+
X-Originating-IP: [66.108.230.254]
|
43
|
+
Date: Mon, 12 Jan 2015 22:39:31 -0500
|
44
|
+
Message-ID: <CAN-VoWm1nRXKLZk-g368U05SE7_Z9aHV9abL+PEbf-kn=0HDFw@mail.gmail.com>
|
45
|
+
Subject: Interstellar OST
|
46
|
+
From: Kunal Shah <me@kunalashah.com>
|
47
|
+
To: "stream@kunalashah.com" <stream@kunalashah.com>
|
48
|
+
Content-Type: multipart/alternative; boundary=001a11394e8ef1a379050c805e70
|
49
|
+
|
50
|
+
--001a11394e8ef1a379050c805e70
|
51
|
+
Content-Type: text/plain; charset=UTF-8
|
52
|
+
|
53
|
+
I think B Colony made the wormhole. https://www.youtube.com/watch?v=jo5m5GXF9Ec
|
54
|
+
|
55
|
+
--001a11394e8ef1a379050c805e70
|
56
|
+
Content-Type: text/html; charset=UTF-8
|
57
|
+
|
58
|
+
<div dir="ltr">I think B Colony made the wormhole. https://www.youtube.com/watch?v=jo5m5GXF9Ec</div>
|
59
|
+
|
60
|
+
--001a11394e8ef1a379050c805e70--
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'mail2frontmatter'
|
2
|
+
require 'auto_html'
|
3
|
+
|
4
|
+
module Mail2FrontMatter
|
5
|
+
class AutomaticEmbeds < PreProcessor
|
6
|
+
require 'nokogiri'
|
7
|
+
|
8
|
+
extend AutoHtml
|
9
|
+
|
10
|
+
@all_filters = [:youtube, :soundcloud, :link, :ted, :twitter, :vimeo, :google_map, :gist, :flickr]
|
11
|
+
|
12
|
+
def self.register(options = {})
|
13
|
+
super
|
14
|
+
|
15
|
+
# I *could* introspect on auto_html here but I haven't vetted them all yet
|
16
|
+
if @options[:white_list]
|
17
|
+
@filters = @options[:white_list].map(&:to_sym)
|
18
|
+
elsif @options[:black_list]
|
19
|
+
@filters = @all_filters - @options[:black_list].map(&:to_sym)
|
20
|
+
else
|
21
|
+
@filters = @all_filters
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.run(metadata, body)
|
27
|
+
body = unwrap_links(body)
|
28
|
+
|
29
|
+
body = auto_html(body, { filters: @filters, options: @options[:filters] }) {
|
30
|
+
# use options passed to us...
|
31
|
+
@options[:filters].each do |filter|
|
32
|
+
options_for_filter = @options[:options] ? (@options[:options][filter.to_sym] || {}) : {}
|
33
|
+
self.send(filter.to_sym, options_for_filter)
|
34
|
+
end
|
35
|
+
|
36
|
+
# be sure to return @text here
|
37
|
+
@text
|
38
|
+
}
|
39
|
+
|
40
|
+
return metadata, body
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.unwrap_links(body)
|
44
|
+
parsed_body = Nokogiri::HTML::DocumentFragment.parse(body)
|
45
|
+
|
46
|
+
parsed_body.elements.css("a").each do |element|
|
47
|
+
href = element.attributes["href"].value
|
48
|
+
|
49
|
+
if href == element.inner_html
|
50
|
+
body.gsub!(element.to_s, href)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
body
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'm2fm-automatic-embeds'
|
7
|
+
spec.version = '0.1.0'
|
8
|
+
spec.authors = ['Kunal Shah']
|
9
|
+
spec.email = ['me@kunalashah.com']
|
10
|
+
spec.summary = %q{mail2frontmatter plugin to transform links into embed code automatically}
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.homepage = 'https://github.com/whistlerbrk/m2fm-automatic-embeds'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'mail2frontmatter', '~> 0.1.0'
|
21
|
+
spec.add_dependency 'auto_html-whistlerbrk', '2.0.0.pre'
|
22
|
+
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
24
|
+
spec.add_development_dependency "byebug", "~> 3.5" unless RUBY_VERSION =~ /1.9/
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mail2FrontMatter::AutomaticEmbeds, "configuration" do
|
4
|
+
let(:config) {
|
5
|
+
test_config = File.join(File.dirname(__FILE__), '..', 'fixtures', 'config.yml')
|
6
|
+
config = YAML.load_file(test_config).deep_symbolize_keys!
|
7
|
+
}
|
8
|
+
|
9
|
+
it "should store filters internally as symbols" do
|
10
|
+
Mail2FrontMatter::AutomaticEmbeds.register(config[:keys_demo])
|
11
|
+
keys = Mail2FrontMatter::AutomaticEmbeds.instance_variable_get :@filters
|
12
|
+
|
13
|
+
expect(keys.all?{|k|k.is_a?(Symbol)}).to eq(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should allow a white list" do
|
17
|
+
Mail2FrontMatter::AutomaticEmbeds.register(config[:white_list_demo])
|
18
|
+
keys = Mail2FrontMatter::AutomaticEmbeds.instance_variable_get :@filters
|
19
|
+
|
20
|
+
white_list = [:youtube, :soundcloud, :vimeo]
|
21
|
+
expect(keys.sort).to eq(white_list.sort)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should allow a black list" do
|
25
|
+
Mail2FrontMatter::AutomaticEmbeds.register(config[:black_list_demo])
|
26
|
+
keys = Mail2FrontMatter::AutomaticEmbeds.instance_variable_get :@filters
|
27
|
+
all_keys = Mail2FrontMatter::AutomaticEmbeds.instance_variable_get :@all_filters
|
28
|
+
|
29
|
+
black_list = [:vimeo]
|
30
|
+
expect(keys.sort).to eq((all_keys - black_list).sort)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should allow the forwarding of options to an auto_html filter" do
|
34
|
+
Mail2FrontMatter::AutomaticEmbeds.register(config[:options_demo])
|
35
|
+
|
36
|
+
metadata = {
|
37
|
+
subject: "Interstellar"
|
38
|
+
}
|
39
|
+
body = "I think B Colony made the wormhole. https://www.youtube.com/watch?v=jo5m5GXF9Ec"
|
40
|
+
|
41
|
+
expect_any_instance_of(AutoHtml::Builder).to receive(:youtube).with({autoplay: true})
|
42
|
+
|
43
|
+
# run it
|
44
|
+
Mail2FrontMatter::AutomaticEmbeds.run(metadata, body)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe Mail2FrontMatter::AutomaticEmbeds, "behaviour" do
|
49
|
+
|
50
|
+
let(:soundcloud) {
|
51
|
+
Mail::Message.new(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'soundcloud-link.eml')))
|
52
|
+
}
|
53
|
+
let(:youtube) {
|
54
|
+
Mail::Message.new(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'youtube-link.eml')))
|
55
|
+
}
|
56
|
+
let(:wrapped) {
|
57
|
+
Mail::Message.new(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'wrapped-links.eml')))
|
58
|
+
}
|
59
|
+
let(:control) {
|
60
|
+
Mail::Message.new(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'no-links.eml')))
|
61
|
+
}
|
62
|
+
|
63
|
+
it "should identify and transform youtube link" do
|
64
|
+
Mail2FrontMatter::AutomaticEmbeds.register
|
65
|
+
|
66
|
+
parser = Mail2FrontMatter::Parser.new(youtube)
|
67
|
+
metadata, body = Mail2FrontMatter::PreProcessor.process(parser.metadata, parser.body)
|
68
|
+
|
69
|
+
expect(body).to match(/embed/)
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should unwrap links without specific names before using filters" do
|
74
|
+
Mail2FrontMatter::AutomaticEmbeds.register
|
75
|
+
parser = Mail2FrontMatter::Parser.new(wrapped)
|
76
|
+
|
77
|
+
metadata, body = Mail2FrontMatter::AutomaticEmbeds.run(parser.metadata, parser.body)
|
78
|
+
|
79
|
+
expect(body).to_not match(/href/)
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'mail2frontmatter', 'automatic-embeds'))
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: m2fm-automatic-embeds
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kunal Shah
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mail2frontmatter
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: auto_html-whistlerbrk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.0.0.pre
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.0.0.pre
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.7'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
description: mail2frontmatter plugin to transform links into embed code automatically
|
98
|
+
email:
|
99
|
+
- me@kunalashah.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- fixtures/config.yml
|
111
|
+
- fixtures/no-links.eml
|
112
|
+
- fixtures/soundcloud-link.eml
|
113
|
+
- fixtures/wrapped-links.eml
|
114
|
+
- fixtures/youtube-link.eml
|
115
|
+
- lib/mail2frontmatter/automatic-embeds.rb
|
116
|
+
- m2fm-automatic-embeds.gemspec
|
117
|
+
- spec/automatic_embed_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
homepage: https://github.com/whistlerbrk/m2fm-automatic-embeds
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.4.5
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: mail2frontmatter plugin to transform links into embed code automatically
|
143
|
+
test_files:
|
144
|
+
- spec/automatic_embed_spec.rb
|
145
|
+
- spec/spec_helper.rb
|