jekyll-autolink_email 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0019bccfada298555f99392c9d5b73f427d24b39
4
+ data.tar.gz: ee46f617ac3026408ed00f7441a67a2998c3b1f7
5
+ SHA512:
6
+ metadata.gz: fc7a834e8b6b33651ea6e1074d2b1a7063b19e0cd23c5b7506085acbb53861fce848c920ab94b22c42efdb2e6ff3e45dfe71a97d4d3ae66da2ebcdc4c25ff419
7
+ data.tar.gz: 6da9fd6374a040d909f0e2e4189e677419e19dec975e5aa520f55ebb51c7899039f8d08b86137b027cf17651dd4f3b22beb83ae9e8a4768884f6d1ec02e55e51
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ivan Tse
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,40 @@
1
+ # Jekyll::AutolinkEmail
2
+
3
+ Autolink emails for your Jekyll Site.
4
+
5
+ ## Installation
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```
10
+ gem 'jekyll-autolink_email'
11
+ ```
12
+
13
+ Add to your `_config.yml`:
14
+
15
+ ```yml
16
+ gems:
17
+ - jekyll-autolink_email
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ In any html page or post, emails will be autolinked. So if you write `foo@example.com`, the resulting html will be `<a href="mailto:foo@example.com">foo@example.com</a>`
23
+
24
+ ## Configuration
25
+
26
+ Autolinking is done by [Rinku](https://github.com/vmg/rinku) so visit that gem for a more in-depth explanation of the configuration options:
27
+
28
+ ```yml
29
+ autolink_email:
30
+ link_attr: class='email-link' # attributes to add to the link
31
+ skip_tags: ['div'] # tags to skip
32
+ ```
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it ( https://github.com/[my-github-username]/jekyll-autolink/fork )
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.test_files = FileList['test/test_*.rb']
7
+ t.verbose = true
8
+ end
9
+
@@ -0,0 +1,26 @@
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 = "jekyll-autolink_email"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Ivan Tse"]
9
+ spec.email = ["ivan.tse1@gmail.com"]
10
+ spec.summary = "Autolink emails for your Jekyll site."
11
+ spec.description = ""
12
+ spec.homepage = "https://github.com/ivantsepp/jekyll-autolink_email"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "jekyll", '~> 2.0'
20
+ spec.add_dependency "rinku", '~> 1.7.0'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "shoulda"
25
+ spec.add_development_dependency "mocha"
26
+ end
@@ -0,0 +1,33 @@
1
+ require 'jekyll'
2
+ require 'rinku'
3
+
4
+ module Jekyll
5
+ class AutolinkEmail < Jekyll::Generator
6
+
7
+ safe true
8
+
9
+ def initialize(config)
10
+ config['autolink_email'] ||= {}
11
+ end
12
+
13
+ def generate(site)
14
+ @site = site
15
+ site.pages.each { |page| autolinkify page if page.html?}
16
+ site.posts.each { |page| autolinkify page }
17
+ end
18
+
19
+ private
20
+
21
+ def autolinkify(page)
22
+ page.content = Rinku.auto_link(page.content, :email_addresses, link_attr, skip_tags)
23
+ end
24
+
25
+ def link_attr
26
+ @link_attr ||= @site.config['autolink_email']['link_attr']
27
+ end
28
+
29
+ def skip_tags
30
+ @skip_tags ||= Array(@site.config['autolink_email']['skip_tags'])
31
+ end
32
+ end
33
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/unit'
3
+ require 'shoulda'
4
+ require 'mocha/mini_test'
5
+ require 'jekyll-autolink_email'
@@ -0,0 +1,52 @@
1
+ require 'helper'
2
+
3
+ class Jekyll::AutolinkEmailTest < Minitest::Test
4
+ context 'AutolinkEmail' do
5
+
6
+ setup do
7
+ @site = Jekyll::Site.new(Jekyll::Configuration::DEFAULTS)
8
+ @autolink_email = Jekyll::AutolinkEmail.new(@site.config)
9
+ @page = Jekyll::Page.new(@site, File.expand_path('../../', __FILE__), '', 'README.md')
10
+ @page.instance_variable_set(:@content, '<div>ivan.tse1@gmail.com</div>')
11
+ @site.pages << @page
12
+ @email_link = '<div><a href="mailto:ivan.tse1@gmail.com">ivan.tse1@gmail.com</a></div>'
13
+ end
14
+
15
+ should 'replace email with link' do
16
+ @autolink_email.instance_variable_set(:@site, @site)
17
+ @autolink_email.send(:autolinkify, @page)
18
+ assert_equal @email_link, @page.content
19
+ end
20
+
21
+ should 'replace page content on generate' do
22
+ @autolink_email.generate(@site)
23
+ assert_equal @email_link, @page.content
24
+ end
25
+
26
+ should 'replace page content on site#generate' do
27
+ @site.generators = Array(@autolink_email)
28
+ @site.generate
29
+ assert_equal @email_link, @page.content
30
+ end
31
+
32
+ should 'pull link_attr from config' do
33
+ @site.config['autolink_email']['link_attr'] = 'class="ivan"'
34
+ @autolink_email.generate(@site)
35
+ assert @page.content.include?('class="ivan"')
36
+ end
37
+
38
+ should 'pull skip_tags from config' do
39
+ @site.config['autolink_email']['skip_tags'] = 'div'
40
+ @autolink_email.generate(@site)
41
+ assert_equal '<div>ivan.tse1@gmail.com</div>', @page.content
42
+ end
43
+
44
+ should 'not replace email with link if page is not html' do
45
+ @page = Jekyll::Page.new(@site, File.expand_path('../../', __FILE__), '', 'LICENSE.txt')
46
+ @page.instance_variable_set(:@content, '<div>ivan.tse1@gmail.com</div>')
47
+ @site.pages << @page
48
+ @autolink_email.generate(@site)
49
+ assert_equal '<div>ivan.tse1@gmail.com</div>', @page.content
50
+ end
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-autolink_email
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ivan Tse
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rinku
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.7.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mocha
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: ''
98
+ email:
99
+ - ivan.tse1@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - jekyll-autolink_email.gemspec
110
+ - lib/jekyll-autolink_email.rb
111
+ - test/helper.rb
112
+ - test/test_autolink_email.rb
113
+ homepage: https://github.com/ivantsepp/jekyll-autolink_email
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.2.2
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Autolink emails for your Jekyll site.
137
+ test_files:
138
+ - test/helper.rb
139
+ - test/test_autolink_email.rb