├── fixtures └── test-app │ ├── config.rb │ └── source │ ├── index.html │ ├── with_no_email.html │ ├── with_body.html │ ├── with_url_params.html │ ├── with_multiple_emails.html │ └── with_complex_url_params.html ├── lib ├── middleman-protect-emails │ ├── version.rb │ ├── rot13_script.html │ └── extension.rb └── middleman-protect-emails.rb ├── .travis.yml ├── .gitignore ├── Gemfile ├── Rakefile ├── features ├── support │ └── env.rb └── extension.feature ├── middleman-protect-emails.gemspec ├── LICENSE.txt └── README.md /fixtures/test-app/config.rb: -------------------------------------------------------------------------------- 1 | activate :protect_emails 2 | -------------------------------------------------------------------------------- /fixtures/test-app/source/index.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /fixtures/test-app/source/with_no_email.html: -------------------------------------------------------------------------------- 1 |
Hello! 2 | -------------------------------------------------------------------------------- /fixtures/test-app/source/with_body.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/middleman-protect-emails/version.rb: -------------------------------------------------------------------------------- 1 | module Middleman 2 | module ProtectEmails 3 | VERSION = '0.4.0' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.2.0 4 | - 2.1.5 5 | - 2.1.0 6 | - 2.0.0 7 | before_install: 8 | - gem install bundler 9 | -------------------------------------------------------------------------------- /fixtures/test-app/source/with_url_params.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /fixtures/test-app/source/with_multiple_emails.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.bundle 11 | *.so 12 | *.o 13 | *.a 14 | mkmf.log 15 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | group :test do 6 | gem 'cucumber', '~> 2.0' 7 | gem 'aruba', '~> 0.7.4' 8 | gem 'codeclimate-test-reporter' 9 | end 10 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | require 'cucumber/rake/task' 3 | 4 | Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t| 5 | t.cucumber_opts = "--color --format progress" 6 | end 7 | 8 | task default: :cucumber 9 | -------------------------------------------------------------------------------- /lib/middleman-protect-emails.rb: -------------------------------------------------------------------------------- 1 | require 'middleman-core' 2 | require 'middleman-protect-emails/version' 3 | 4 | ::Middleman::Extensions.register(:protect_emails) do 5 | require 'middleman-protect-emails/extension' 6 | ::Middleman::ProtectEmailsExtension 7 | end 8 | -------------------------------------------------------------------------------- /features/support/env.rb: -------------------------------------------------------------------------------- 1 | PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__))) 2 | require 'middleman-core' 3 | require 'middleman-core/step_definitions' 4 | 5 | require 'codeclimate-test-reporter' 6 | CodeClimate::TestReporter.start 7 | 8 | require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-protect-emails') 9 | -------------------------------------------------------------------------------- /lib/middleman-protect-emails/rot13_script.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /fixtures/test-app/source/with_complex_url_params.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | localhost domain 5 | plus sign in subject 6 | spaces in subject 7 | cc param 8 | crazy case 9 | @example.com hacker 10 | 11 | 12 | -------------------------------------------------------------------------------- /middleman-protect-emails.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'middleman-protect-emails/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = 'middleman-protect-emails' 8 | spec.version = Middleman::ProtectEmails::VERSION 9 | spec.authors = ['Ankit Sardesai'] 10 | spec.email = ['amsardesai@gmail.com'] 11 | spec.summary = %q{Middleman extension for email link protection and obfuscation} 12 | spec.description = %q{Middleman extension for email link protection and obfuscation.} 13 | spec.homepage = '' 14 | spec.license = 'MIT' 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 | spec.required_ruby_version = '>= 2.0' 20 | 21 | spec.add_dependency 'middleman-core', '>= 3.4' 22 | 23 | spec.add_development_dependency 'rake', '~> 10.3' 24 | end 25 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Ankit Sardesai 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. 23 | -------------------------------------------------------------------------------- /features/extension.feature: -------------------------------------------------------------------------------- 1 | Feature: Email Protection 2 | 3 | Scenario: Inserts script into the page 4 | Given the Server is running at "test-app" 5 | When I go to "/" 6 | Then I should see "" 7 | 8 | Scenario: Shows obfuscated email on page 9 | Given the Server is running at "test-app" 10 | When I go to "/" 11 | Then I should see "" 12 | 13 | Scenario: Inserts script into end of body if a body tag exists 14 | Given the Server is running at "test-app" 15 | When I go to "/with_body.html" 16 | Then I should see: 17 | """ 18 | 19 |