middleman-aria_current 0.1.0

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
+ SHA1:
3
+ metadata.gz: ed1a17eadfd68508ba8bf1c572cdfa910b878f9a
4
+ data.tar.gz: 86d2dfaa60bc5fb9d7f8c9344f4b00783bc26052
5
+ SHA512:
6
+ metadata.gz: db356f86365f428dba966a77b1d9399d7ccd3ab307a1a6a2e30c1f5e5f51167152c3ffcd812b8d3babe388b8e75daa12ca06364963cc4f99bf3b4dfe60ef76fc
7
+ data.tar.gz: 3d10bf8cd475d29f1e0012f943b35ba88a03a6bde11e706cb360d6aaf82808bbc079afed1a3d9ba418d4f3dde1312fd171958284ba4396aeac3cbd8dba68fc21
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /Gemfile.lock
2
+ /pkg
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Change log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is loosely based on [Keep a Changelog] and this project adheres to
6
+ [Semantic Versioning].
7
+
8
+ [Keep a Changelog]: http://keepachangelog.com/
9
+ [Semantic Versioning]: http://semver.org/
10
+
11
+ ## 0.1.0 - 2017-03-17
12
+
13
+ ### Added
14
+
15
+ - First release!
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem "middleman-cli"
7
+ end
8
+
9
+ group :development do
10
+ gem "rake"
11
+ gem "rdoc"
12
+ gem "yard"
13
+ end
14
+
15
+ group :test do
16
+ gem "cucumber"
17
+ gem "aruba"
18
+ gem "rspec"
19
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Tyson Gach and thoughtbot, inc.
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,57 @@
1
+ # middleman-aria_current
2
+
3
+ A [Middleman] extension for indicating a current (active) link using
4
+ [`aria-current`][spec].
5
+
6
+ If you're new to `aria-current`, [Léonie Watson wrote a _wonderful_ article
7
+ detailing its usage][article].
8
+
9
+ [Middleman]: https://middlemanapp.com/
10
+ [spec]: https://www.w3.org/TR/wai-aria-1.1/#aria-current
11
+ [article]: http://tink.uk/using-the-aria-current-attribute/
12
+
13
+ # Install
14
+
15
+ 1. Add middleman-aria_current to your `Gemfile`:
16
+
17
+ ```
18
+ gem "middleman-aria_current"
19
+ ```
20
+
21
+ 1. Run:
22
+
23
+ ```
24
+ bundle install
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ```erb
30
+ <%= current_link_to "Home", "/" %>
31
+ ```
32
+
33
+ ```html
34
+ <a href="/" aria-current="page">Home</a>
35
+ ```
36
+
37
+ ## License
38
+
39
+ middleman-aria_current is Copyright (c) 2017 Tyson Gach and thoughtbot, inc.
40
+ It is free software, and may be redistributed
41
+ under the terms specified in the [LICENSE] file.
42
+
43
+ [LICENSE]: LICENSE.md
44
+
45
+ ## About
46
+
47
+ ![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg)
48
+
49
+ middleman-aria_current is maintained and funded by thoughtbot, inc.
50
+ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
51
+
52
+ We love open source software!
53
+ See [our other projects][community]
54
+ or [hire us][hire] to help build your product.
55
+
56
+ [community]: https://thoughtbot.com/community?utm_source=github
57
+ [hire]: https://thoughtbot.com/hire-us?utm_source=github
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "cucumber/rake/task"
5
+
6
+ Cucumber::Rake::Task.new(:cucumber, "Run features that should pass") do |t|
7
+ t.cucumber_opts = "--color --tags ~@wip --strict"
8
+ end
9
+
10
+ require "rake/clean"
11
+
12
+ task test: ["cucumber"]
13
+
14
+ task default: :test
@@ -0,0 +1,41 @@
1
+ Feature: ARIA current link
2
+
3
+ Scenario: Without the aria_current parameter
4
+ Given a fixture app "aria_current-app"
5
+ Given a successfully built app at "aria_current-app" with flags "--verbose"
6
+ Then the file "build/without-params.html" should contain:
7
+ """
8
+ <a href="/without-params" aria-current="page">Home</a>
9
+ """
10
+
11
+ Scenario: With the aria_current parameter
12
+ Given a fixture app "aria_current-app"
13
+ Given a successfully built app at "aria_current-app" with flags "--verbose"
14
+ Then the file "build/with-params.html" should contain:
15
+ """
16
+ <a href="/with-params" aria-current="step">Home</a>
17
+ """
18
+
19
+ Scenario: when the link's URL is not the current page's URL
20
+ Given a fixture app "aria_current-app"
21
+ Given a successfully built app at "aria_current-app" with flags "--verbose"
22
+ Then the file "build/different-url.html" should contain:
23
+ """
24
+ <a href="/other-page">Home</a>
25
+ """
26
+
27
+ Scenario: when the helper is invoked with a block
28
+ Given a fixture app "aria_current-app"
29
+ Given a successfully built app at "aria_current-app" with flags "--verbose"
30
+ Then the file "build/with-block.html" should contain:
31
+ """
32
+ <a href="/with-block" aria-current="page">Hello</a>
33
+ """
34
+
35
+ Scenario: when the current page's URL contains a portion of the link's URL (i.e. /foo-bar and /foo)
36
+ Given a fixture app "aria_current-app"
37
+ Given a successfully built app at "aria_current-app" with flags "--verbose"
38
+ Then the file "build/foo-bar.html" should contain:
39
+ """
40
+ <a href="/foo">Hello</a>
41
+ """
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-aria_current')
@@ -0,0 +1 @@
1
+ <a href="/" aria_current="page">Home</a>
@@ -0,0 +1 @@
1
+ activate :aria_current
@@ -0,0 +1 @@
1
+ <%= current_link_to "Home", "/other-page" %>
@@ -0,0 +1 @@
1
+ <%= current_link_to "Hello", "/foo" %>
@@ -0,0 +1 @@
1
+ <%= current_link_to("/with-block") { "Hello" } %>
@@ -0,0 +1 @@
1
+ <%= current_link_to "Home", "/with-params", aria_current: "step" %>
@@ -0,0 +1 @@
1
+ <%= current_link_to "Home", "/without-params" %>
@@ -0,0 +1,6 @@
1
+ require "middleman-core"
2
+
3
+ Middleman::Extensions.register :aria_current do
4
+ require "middleman-aria_current/extension"
5
+ AriaCurrent
6
+ end
@@ -0,0 +1,26 @@
1
+ require "middleman-core"
2
+
3
+ class AriaCurrent < ::Middleman::Extension
4
+ FILE_EXTENSION = /\.(\w*)$/
5
+
6
+ helpers do
7
+ def current_link_to(*arguments, aria_current: "page", **options, &block)
8
+ if block_given?
9
+ text = capture(&block)
10
+ path = arguments[0]
11
+ else
12
+ text = arguments[0]
13
+ path = arguments[1]
14
+ end
15
+
16
+ link_options = options
17
+ current_path = current_page.url.to_s.gsub(FILE_EXTENSION, "")
18
+
19
+ if current_path == path
20
+ link_options.merge!("aria-current" => aria_current)
21
+ end
22
+
23
+ link_to(text, path, link_options)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "middleman-aria_current"
6
+ s.version = "0.1.0"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Tyson Gach", "Sean Doyle"]
9
+ s.email = ["tyson@thoughtbot.com", "sean@thoughtbot.com"]
10
+ s.homepage = "https://github.com/thoughtbot/middleman-aria_current"
11
+ s.summary = <<-HERE
12
+ A Middleman extension for indicating a current (active) link
13
+ using `aria-current`.
14
+ HERE
15
+ s.license = "MIT"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_runtime_dependency "middleman-core", "~> 4.2"
23
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-aria_current
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tyson Gach
8
+ - Sean Doyle
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2017-03-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: middleman-core
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '4.2'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '4.2'
28
+ description:
29
+ email:
30
+ - tyson@thoughtbot.com
31
+ - sean@thoughtbot.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".gitignore"
37
+ - CHANGELOG.md
38
+ - Gemfile
39
+ - LICENSE.md
40
+ - README.md
41
+ - Rakefile
42
+ - features/aria_current.feature
43
+ - features/support/env.rb
44
+ - fixtures/aria_current-app/build/index.html
45
+ - fixtures/aria_current-app/config.rb
46
+ - fixtures/aria_current-app/source/different-url.html.erb
47
+ - fixtures/aria_current-app/source/foo-bar.html.erb
48
+ - fixtures/aria_current-app/source/with-block.html.erb
49
+ - fixtures/aria_current-app/source/with-params.html.erb
50
+ - fixtures/aria_current-app/source/without-params.html.erb
51
+ - lib/middleman-aria_current.rb
52
+ - lib/middleman-aria_current/extension.rb
53
+ - middleman-aria_current.gemspec
54
+ homepage: https://github.com/thoughtbot/middleman-aria_current
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.5.1
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: A Middleman extension for indicating a current (active) link using `aria-current`.
78
+ test_files:
79
+ - features/aria_current.feature
80
+ - features/support/env.rb