middleman-aria_current 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +14 -1
- data/CONTRIBUTING.md +43 -0
- data/README.md +62 -4
- data/lib/middleman-aria_current/extension.rb +5 -8
- data/middleman-aria_current.gemspec +8 -4
- metadata +7 -20
- data/fixtures/aria_current-app/build/index.html +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 84cffdd4bf9c52cc6c394ef1b0359cacef0860deff164eb18d43c307fd519631
|
4
|
+
data.tar.gz: aaa0047527f7840a38f6622b87665359f09d56df7bf3db487a38d558730fc732
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc70df7f9e9745b15e1209da470cc432767d4c5dd12502df0a39e30956618016b88f794e80d89e971acf1b5efc2acc21207aac57ccd576be04d88615eb77ff8b
|
7
|
+
data.tar.gz: e693d2d735fdbf732df9d0d74388b8857732f3d5eb66c881c6ed912c36a9da12388942cb6c1305f79e2069b5d7dec37ff131f6cc2a2f2a0d886b73b0e07a4bd7
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.5
|
data/CHANGELOG.md
CHANGED
@@ -8,13 +8,26 @@ The format is loosely based on [Keep a Changelog] and this project adheres to
|
|
8
8
|
[Keep a Changelog]: http://keepachangelog.com/
|
9
9
|
[Semantic Versioning]: http://semver.org/
|
10
10
|
|
11
|
+
## master
|
12
|
+
|
13
|
+
## [0.1.2] - 2020-04-03
|
14
|
+
|
15
|
+
- Yield block as contents
|
16
|
+
|
17
|
+
- Instead of determining the "current" resource through `String` comparison
|
18
|
+
(including incorporating the resource file's extension), make use of the
|
19
|
+
[`sitemap`][sitemap].
|
20
|
+
|
21
|
+
[sitemap]: [sitemap]: https://middlemanapp.com/advanced/sitemap/#accessing-the-sitemap-from-code
|
22
|
+
|
23
|
+
|
11
24
|
## [0.1.1] - 2017-03-19
|
12
25
|
|
13
26
|
### Changed
|
14
27
|
|
15
28
|
- Relaxed `middleman-core` dependency from `~> 4.2` to `~> 4.0`. ([#13])
|
16
29
|
|
17
|
-
[0.1.1]: https://github.com/thoughtbot/middleman-aria_current/compare/
|
30
|
+
[0.1.1]: https://github.com/thoughtbot/middleman-aria_current/compare/0.1.0...v0.1.1
|
18
31
|
[#13]: https://github.com/thoughtbot/middleman-aria_current/pull/13
|
19
32
|
|
20
33
|
## 0.1.0 - 2017-03-17
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
We love contributions from everyone.
|
4
|
+
By participating in this project,
|
5
|
+
you agree to abide by the thoughtbot [code of conduct].
|
6
|
+
|
7
|
+
[code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
|
8
|
+
|
9
|
+
We expect everyone to follow the code of conduct
|
10
|
+
anywhere in thoughtbot's project codebases,
|
11
|
+
issue trackers, chatrooms, and mailing lists.
|
12
|
+
|
13
|
+
## Contributing Code
|
14
|
+
|
15
|
+
1. Fork the repo.
|
16
|
+
|
17
|
+
1. Install dependencies:
|
18
|
+
|
19
|
+
```
|
20
|
+
bundle install
|
21
|
+
```
|
22
|
+
|
23
|
+
1. Make sure the tests pass:
|
24
|
+
|
25
|
+
```
|
26
|
+
bundle exec rake test
|
27
|
+
```
|
28
|
+
|
29
|
+
1. Make your change, with new passing tests. Follow the [style guide][style].
|
30
|
+
|
31
|
+
1. Mention how your changes affect the project to other developers and users in
|
32
|
+
the `CHANGELOG.md` file.
|
33
|
+
|
34
|
+
1. Write a [good commit message][commit]. Push to your fork. Submit a pull
|
35
|
+
request.
|
36
|
+
|
37
|
+
Others will give constructive feedback.
|
38
|
+
This is a time for discussion and improvements,
|
39
|
+
and making the necessary changes will be required before we can
|
40
|
+
merge the contribution.
|
41
|
+
|
42
|
+
[style]: https://github.com/thoughtbot/guides/tree/master/style
|
43
|
+
[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
data/README.md
CHANGED
@@ -32,16 +32,74 @@ detailing its usage][article].
|
|
32
32
|
|
33
33
|
## Usage
|
34
34
|
|
35
|
+
middleman-aria_current provides a `current_link_to` helper, which wraps the
|
36
|
+
built-in `link_to` helper. It checks the URL of the current visited page and
|
37
|
+
outputs an `aria-current` attribute if it matches the URL in the link.
|
38
|
+
|
39
|
+
As an example, below is a typical website navigation where we use
|
40
|
+
`current_link_to` for each link (using ERB):
|
41
|
+
|
35
42
|
```erb
|
36
|
-
|
37
|
-
<%= current_link_to "
|
43
|
+
<nav>
|
44
|
+
<%= current_link_to "Home", "/" %>
|
45
|
+
<%= current_link_to "About", "/about" %>
|
46
|
+
</nav>
|
38
47
|
```
|
39
48
|
|
49
|
+
Now, when you visit `/about`, the link for that page will be given the
|
50
|
+
`aria-current` attribute:
|
51
|
+
|
40
52
|
```html
|
41
|
-
<
|
42
|
-
<a href="/
|
53
|
+
<nav>
|
54
|
+
<a href="/">Home</a>
|
55
|
+
<a href="/about" aria-current="page">About</a>
|
56
|
+
</nav>
|
43
57
|
```
|
44
58
|
|
59
|
+
---
|
60
|
+
|
61
|
+
By default, `current_link_to` will output the `page` value for `aria-current`.
|
62
|
+
You can also pass it one of `aria-current`’s other accepted values: `step`,
|
63
|
+
`location`, `date`, `time`, `true`, or `false`:
|
64
|
+
|
65
|
+
```erb
|
66
|
+
<%= current_link_to "Step 1", "/step-1", aria_current: "step" %>
|
67
|
+
<%= current_link_to "Step 2", "/step-2", aria_current: "step" %>
|
68
|
+
<%= current_link_to "Step 3", "/step-3", aria_current: "step" %>
|
69
|
+
```
|
70
|
+
|
71
|
+
Provided that you are currently visiting `/step-2`, the output will be:
|
72
|
+
|
73
|
+
```html
|
74
|
+
<a href="/step-1">Step 1</a>
|
75
|
+
<a href="/step-2" aria-current="step">Step 2</a>
|
76
|
+
<a href="/step-3">Step 3</a>
|
77
|
+
```
|
78
|
+
|
79
|
+
---
|
80
|
+
|
81
|
+
For styling current links, you can use a [CSS attribute selector][selector_mdn]:
|
82
|
+
|
83
|
+
```css
|
84
|
+
[aria-current]:not([aria-current="false"]) {
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
```
|
88
|
+
|
89
|
+
Note that we _exclude_ styling the link if `aria-current` has a value of
|
90
|
+
`false`. This is because `false` is a valid and useful value for denoting a link
|
91
|
+
that does not represent the current item within a set.
|
92
|
+
|
93
|
+
[selector_mdn]: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
|
94
|
+
|
95
|
+
## Contributing
|
96
|
+
|
97
|
+
See the [contributing document].
|
98
|
+
Thank you, [contributors]!
|
99
|
+
|
100
|
+
[contributing document]: CONTRIBUTING.md
|
101
|
+
[contributors]: https://github.com/thoughtbot/middleman-aria_current/graphs/contributors
|
102
|
+
|
45
103
|
## License
|
46
104
|
|
47
105
|
middleman-aria_current is copyright © 2017 Tyson Gach and thoughtbot, inc.
|
@@ -1,26 +1,23 @@
|
|
1
1
|
require "middleman-core"
|
2
2
|
|
3
3
|
class AriaCurrent < ::Middleman::Extension
|
4
|
-
FILE_EXTENSION = /\.(\w*)$/
|
5
|
-
|
6
4
|
helpers do
|
7
5
|
def current_link_to(*arguments, aria_current: "page", **options, &block)
|
8
6
|
if block_given?
|
9
|
-
text = capture(&block)
|
10
7
|
path = arguments[0]
|
11
8
|
else
|
12
|
-
text = arguments[0]
|
13
9
|
path = arguments[1]
|
14
10
|
end
|
15
11
|
|
16
|
-
link_options = options
|
17
|
-
|
12
|
+
link_options = options.dup
|
13
|
+
|
14
|
+
uri = URI.parse(path.to_s)
|
18
15
|
|
19
|
-
if
|
16
|
+
if current_resource == sitemap.find_resource_by_path(uri.path)
|
20
17
|
link_options.merge!("aria-current" => aria_current)
|
21
18
|
end
|
22
19
|
|
23
|
-
link_to(
|
20
|
+
link_to(*arguments, link_options, &block)
|
24
21
|
end
|
25
22
|
end
|
26
23
|
end
|
@@ -3,15 +3,20 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "middleman-aria_current"
|
6
|
-
s.version = "0.1.
|
6
|
+
s.version = "0.1.2"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Tyson Gach", "Sean Doyle"]
|
9
9
|
s.email = ["tyson@thoughtbot.com", "sean@thoughtbot.com"]
|
10
10
|
s.homepage = "https://github.com/thoughtbot/middleman-aria_current"
|
11
|
-
s.summary = <<-
|
11
|
+
s.summary = <<-SUM
|
12
12
|
A Middleman extension for indicating a current (active) link
|
13
13
|
using `aria-current`.
|
14
|
-
|
14
|
+
SUM
|
15
|
+
s.summary = <<-DESC
|
16
|
+
middleman-aria_current provides a `current_link_to` helper, which wraps the
|
17
|
+
built-in `link_to` helper. It checks the URL of the current visited page and
|
18
|
+
outputs an `aria-current` attribute if it matches the URL in the link.
|
19
|
+
DESC
|
15
20
|
s.license = "MIT"
|
16
21
|
|
17
22
|
s.files = `git ls-files`.split("\n")
|
@@ -19,7 +24,6 @@ using `aria-current`.
|
|
19
24
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
25
|
s.require_paths = ["lib"]
|
21
26
|
|
22
|
-
s.add_development_dependency "aruba", "~> 0.14"
|
23
27
|
s.add_development_dependency "capybara", "~> 2.13"
|
24
28
|
s.add_development_dependency "cucumber", "~> 2.4"
|
25
29
|
s.add_development_dependency "middleman-cli", "~> 4.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-aria_current
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyson Gach
|
@@ -9,22 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: aruba
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '0.14'
|
21
|
-
type: :development
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '0.14'
|
28
14
|
- !ruby/object:Gem::Dependency
|
29
15
|
name: capybara
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,6 +107,7 @@ files:
|
|
121
107
|
- ".hound.yml"
|
122
108
|
- ".ruby-version"
|
123
109
|
- CHANGELOG.md
|
110
|
+
- CONTRIBUTING.md
|
124
111
|
- Gemfile
|
125
112
|
- LICENSE.md
|
126
113
|
- README.md
|
@@ -128,7 +115,6 @@ files:
|
|
128
115
|
- circle.yml
|
129
116
|
- features/aria_current.feature
|
130
117
|
- features/support/env.rb
|
131
|
-
- fixtures/aria_current-app/build/index.html
|
132
118
|
- fixtures/aria_current-app/config.rb
|
133
119
|
- fixtures/aria_current-app/source/different-url.html.erb
|
134
120
|
- fixtures/aria_current-app/source/foo-bar.html.erb
|
@@ -157,11 +143,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
143
|
- !ruby/object:Gem::Version
|
158
144
|
version: '0'
|
159
145
|
requirements: []
|
160
|
-
|
161
|
-
rubygems_version: 2.6.8
|
146
|
+
rubygems_version: 3.0.3
|
162
147
|
signing_key:
|
163
148
|
specification_version: 4
|
164
|
-
summary:
|
149
|
+
summary: middleman-aria_current provides a `current_link_to` helper, which wraps the
|
150
|
+
built-in `link_to` helper. It checks the URL of the current visited page and outputs
|
151
|
+
an `aria-current` attribute if it matches the URL in the link.
|
165
152
|
test_files:
|
166
153
|
- features/aria_current.feature
|
167
154
|
- features/support/env.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
<a href="/" aria_current="page">Home</a>
|