jekyll-phone-protect 1.0.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 54f08cbf046b0fb64230a93eec2882fbeef5371b05e199b5ddc80f5e04fac769
4
+ data.tar.gz: 4ed2b5f7c0c1f4a864f78c4830fd2e818c33f4faa67aa63984825a9a90b89974
5
+ SHA512:
6
+ metadata.gz: 06f913e1628c150cdb6fb8a3000f8c55a21b79c7109660d3914954d3161343e5d9975d90d734ad79183015ced0421eed5632268d0db3a899303ec561869d2d76
7
+ data.tar.gz: ac783af5dd7da7b97fae7de61e9780e943efb8e0490b7f06ef6eb286b6c244200185b07ec7523eb1cea615a109a453180004cc50ec99d5ddc6c95969af6b74ad
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Vincent Wochnik and Jacob Valdez.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Jekyll Phone Protect [![Gem Version](https://badge.fury.io/rb/jekyll-phone-protect.png)](http://badge.fury.io/rb/jekyll-phone-protect)
2
+
3
+ > Phone protection liquid filter for Jekyll
4
+
5
+ Jekyll Phone Protect is an phone protection liquid filter which can be used to obfuscate `mailto:` links to protect an phone address from spam bots.
6
+
7
+ ## Installation
8
+
9
+ This plugin is available as a [RubyGem][ruby-gem].
10
+
11
+ Add this line to your application's `Gemfile`:
12
+
13
+ ```
14
+ gem 'jekyll-phone-protect'
15
+ ```
16
+
17
+ And then execute the `bundle` command to install the gem.
18
+
19
+ Alternatively, you can also manually install the gem using the following command:
20
+
21
+ ```
22
+ $ gem install jekyll-phone-protect
23
+ ```
24
+
25
+ After the plugin has been installed successfully, add the following lines to your `_config.yml` in order to tell Jekyll to use the plugin:
26
+
27
+ ```
28
+ gems:
29
+ - jekyll-phone-protect
30
+ ```
31
+
32
+ ## Getting Started
33
+
34
+ In your markup, simply use the `encode_phone` liquid filter made available through this plugin:
35
+
36
+ ```
37
+ {{ '+1-123-456-7890' | encode_phone }}
38
+ ```
39
+
40
+ The above code will yield `%65%78%61%6D%70%6C%65@%65%78%61%6D%70%6C%65.%63%6F%6D`. Only use this filter within the `href` attribute of a given link.
41
+
42
+ ## Example
43
+
44
+ The following example shows how this plugin can be used to protect the `site`'s phone address:
45
+
46
+ ```
47
+ <a href="mailto:{{ site.phone | encode_phone }}" title="Contact me">Contact me</a>
48
+ ```
49
+
50
+ # Contribute
51
+
52
+ Fork this repository, make your changes and then issue a pull request. If you find bugs or have new ideas that you do not want to implement yourself, file a bug report.
53
+
54
+ # Copyright
55
+
56
+ Copyright (c) 2015 Vincent Wochnik and Jacob Valdez.
57
+
58
+ License: MIT
59
+
60
+ [ruby-gem]: https://rubygems.org/gems/jekyll-phone-protect
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module PhoneProtect
3
+ VERSION = '1.0.3'
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ module Jekyll
2
+ module PhoneProtect
3
+ module PhoneProtectionFilter
4
+
5
+ # Percent-encode alphanumeric characters of an phone address
6
+ def encode_phone(input)
7
+ input.to_s.chars.inject(String.new) do |result, char|
8
+ if char =~ /\p{Alnum}/
9
+ char.bytes.inject(result) do |result, byte|
10
+ result << '%%%02X' % byte
11
+ end
12
+ else
13
+ result << char
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ Liquid::Template.register_filter(Jekyll::PhoneProtect::PhoneProtectionFilter)
@@ -0,0 +1,7 @@
1
+ module Jekyll
2
+ module PhoneProtect
3
+ autoload :VERSION, 'jekyll/phone-protect/version.rb'
4
+ end
5
+ end
6
+
7
+ require 'jekyll/phone-protect.rb'
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe(Jekyll::PhoneProtect::PhoneProtectionFilter) do
4
+ let(:output) do
5
+ render_liquid(content, {'phone' => phone})
6
+ end
7
+
8
+ context "simple example number" do
9
+ let(:phone) { "+1-123-456-7890" }
10
+ let(:content) { "{{ '#{phone}' | encode_phone }}" }
11
+
12
+ it "produces the correct percent-encoded phone number" do
13
+ expect(output).to eq("tel:+1-123-456-7890")
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ TEST_DIR = File.dirname(__FILE__)
2
+
3
+ require 'liquid'
4
+ require File.expand_path("../lib/jekyll-phone-protect.rb", TEST_DIR)
5
+
6
+ RSpec.configure do |config|
7
+ config.run_all_when_everything_filtered = true
8
+ config.filter_run :focus
9
+ config.order = 'random'
10
+
11
+ def render_liquid(content, variables)
12
+ template = Liquid::Template.parse(content)
13
+ template.render(variables)
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-phone-protect
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Vincent Wochnik
8
+ - Jacob Valdez
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2022-06-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: liquid
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.6'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.6'
56
+ description: Phone protection liquid filter for Jekyll
57
+ email:
58
+ - v.wochnik@gmail.com
59
+ - jacobfv123@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - LICENSE.md
65
+ - README.md
66
+ - lib/jekyll-phone-protect.rb
67
+ - lib/jekyll/phone-protect.rb
68
+ - lib/jekyll/phone-protect/version.rb
69
+ - spec/protect_phone_filter_spec.rb
70
+ - spec/spec_helper.rb
71
+ homepage: https://github.com/JacobFV/jekyll-phone-protect
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 1.9.3
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 3.2.3
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: This plugin provides a simple liquid filter which converts phones into percent-encoded
94
+ strings.
95
+ test_files:
96
+ - spec/protect_phone_filter_spec.rb
97
+ - spec/spec_helper.rb