m2fm-automatic-clowncar 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/lib/mail2frontmatter/automatic-clowncar.rb +37 -0
- data/m2fm-automatic-clowncar.gemspec +24 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 60ca00245f352070c3cd66ac322e64907fd16ff5
|
4
|
+
data.tar.gz: 31a79e03711466168fbd1c7669f16e9f22ebe5b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2bb2a07d9c4604fc3166350e6c9c673fbc5ba340a0fc31ca9474e0ee20c54dad1c5629e7074a0770098db8eca032ebfb5330b73047b310dc3663edb36959d5e3
|
7
|
+
data.tar.gz: a4da2cb2770e3587ffe19e57ee1195020cc7e9b5dab3c636f3edfcd88489858f680aff7cb87ec3b866cae53968035811f8c2b25bc96ccb79509251624e14a464
|
data/.gitignore
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,51 @@
|
|
1
|
+
# Mail2FrontMatter::AutomaticClowncar
|
2
|
+
|
3
|
+
[Mail2FrontMatter](https://github.com/whistlerbrk/mail2frontmatter) plugin for [Middleman](https://middlemanapp.com/) specific blogs using [Automatic Clowncar](https://github.com/Octo-Labs/middleman-automatic-clowncar) to generate responsive images for your blog.
|
4
|
+
|
5
|
+
```Mail2FrontMatter::AutomaticClowncar``` replaces markup from inline attachments in an email with Automatic Clowncar compatible markup as well as placing your attachments in the namespaced directory (e.g. photos).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'm2fm-automatic-clowncar', require: false
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
## Configuration
|
20
|
+
|
21
|
+
In your Mail2FrontMatter YAML configuration enable the plugin by adding it to your preprocessors:
|
22
|
+
|
23
|
+
```yaml
|
24
|
+
protocol: imap
|
25
|
+
receiver: yourblogemail@yourdomain.com
|
26
|
+
senders: yourpersonal@yourdomain.com
|
27
|
+
|
28
|
+
preprocessors:
|
29
|
+
- key: 'automatic-clowncar'
|
30
|
+
options:
|
31
|
+
namespace_directory: photos
|
32
|
+
|
33
|
+
mailman:
|
34
|
+
server: imap.gmail.com
|
35
|
+
port: 993
|
36
|
+
ssl: true
|
37
|
+
username: yourblogemail@yourdomain.com
|
38
|
+
password: yourpassword
|
39
|
+
```
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
That's it! Now incoming images will be moved to your namespaced directory or by default photos (source/photos). Additionally the markup will be changed to reflect that, and the next time you run middleman build, or in development, automatic clowncar should take care of the rest.
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( https://github.com/[my-github-username]/m2fm-automatic-clowncar/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'mail2frontmatter'
|
2
|
+
|
3
|
+
module Mail2FrontMatter
|
4
|
+
class AutomaticClowncar < PreProcessor
|
5
|
+
require 'nokogiri'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
def self.run(metadata, body)
|
9
|
+
|
10
|
+
parsed_body = Nokogiri::HTML.parse(body)
|
11
|
+
|
12
|
+
metadata[:attachments].each_pair do |id, data|
|
13
|
+
# get element
|
14
|
+
element = parsed_body.elements.xpath("//*[@src='cid:#{id}']")
|
15
|
+
|
16
|
+
namespaced_directory = @options[:namespace_directory] || 'photos'
|
17
|
+
|
18
|
+
# ensure directory exists...
|
19
|
+
FileUtils.mkdir_p(File.join(Dir.pwd, 'source', namespaced_directory))
|
20
|
+
|
21
|
+
# set destination for the file
|
22
|
+
destination = File.join(Dir.pwd, 'source', namespaced_directory, data[:filename])
|
23
|
+
|
24
|
+
# move it
|
25
|
+
FileUtils.mv(data[:filepath], destination)
|
26
|
+
|
27
|
+
# update the metadata with the new location
|
28
|
+
data[:filepath] = File.join(destination, data[:filename])
|
29
|
+
|
30
|
+
# replace the element
|
31
|
+
body.gsub!(element.to_s, "<%= automatic_clowncar_tag '#{namespaced_directory}/#{data[:filename]}' %>")
|
32
|
+
end
|
33
|
+
|
34
|
+
return metadata, body
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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-clowncar'
|
7
|
+
spec.version = '0.0.1'
|
8
|
+
spec.authors = ['Kunal Shah']
|
9
|
+
spec.email = ['me@kunalashah.com']
|
10
|
+
spec.summary = %q{mail2frontmatter plugin for middleman-automatic-clowncar}
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.homepage = 'https://github.com/whistlerbrk/m2fm-automatic-clowncar'
|
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'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: m2fm-automatic-clowncar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kunal Shah
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-12 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'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: mail2frontmatter plugin for middleman-automatic-clowncar
|
56
|
+
email:
|
57
|
+
- me@kunalashah.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/mail2frontmatter/automatic-clowncar.rb
|
68
|
+
- m2fm-automatic-clowncar.gemspec
|
69
|
+
homepage: https://github.com/whistlerbrk/m2fm-automatic-clowncar
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.4.5
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: mail2frontmatter plugin for middleman-automatic-clowncar
|
93
|
+
test_files: []
|