gretel 4.2.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b80e71f865388974401274f84159318e012a5e9e40800888549453e301881bec
4
- data.tar.gz: 06d1a078802e9b8d175f17376c7534ba8004c15327e2fc75b0e01e9386653cb8
3
+ metadata.gz: c1fe62ed99bb8f03e6a00a782f55adc5f6b6fcf84a444d77aa1c771b41d148a9
4
+ data.tar.gz: 1660db0b73ddbf77dac315c8d1466fb66958b9ebab59629c96f999536f17b824
5
5
  SHA512:
6
- metadata.gz: 3b8c092e5e04c48099f0fcad18230b89a6f4c11e760d59f89f629792cb4225eb5db1cf4648c8a6145c6be99bcf104b0d08ee0b74b82d39d1e7b9e366fda6ea37
7
- data.tar.gz: 582e6471d0fa5fb59d490bee9a41b1cdd7b0f419b107c9acb56914832ad5b3a5dfc5c4590918dcb38ea46495a0df2578ceeb5e6384e57c0ed7e37ab8e39ea3e7
6
+ metadata.gz: 4bddd221544196836669a1309c97d536ad2d2b11ef10c74a265e034d0a1463ba5b4955651235ad395b9c37249a9d5eff2ef9ec9b659ab896a8fbca959b199924
7
+ data.tar.gz: ebd6e183dc3597f83c9ac8b22399d0ad52e345da6586b9de59c2386c8b5116d40199fcf494c44cd8d094a25ed543d5ee21397506d1979ebf851a973e23da3ced
@@ -0,0 +1,52 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ schedule:
7
+ - cron: '0 0 * * 0'
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ rails_version: [5.1.0, 5.2.0, 6.0.0, 6.1.0, master]
15
+ ruby_version: [3.0, 2.7, 2.6, 2.5]
16
+ exclude:
17
+ - ruby_version: 2.5
18
+ rails_version: master
19
+ - ruby_version: 2.6
20
+ rails_version: master
21
+ - ruby_version: 3.0
22
+ rails_version: 5.1.0
23
+ - ruby_version: 3.0
24
+ rails_version: 5.2.0
25
+
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+
29
+ - name: Setup Ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby_version }}
33
+
34
+ - name: Run test
35
+ env:
36
+ RAILS_VERSION: ${{ matrix.rails_version }}
37
+ run: |
38
+ bundle update
39
+ cd spec/dummy; rake db:migrate db:test:prepare; cd ../..
40
+ bundle exec rake
41
+
42
+ - name: Upload coverage
43
+ uses: actions/upload-artifact@v2
44
+ if: always()
45
+ with:
46
+ name: coverage-ruby-${{ matrix.ruby_version }}-rails-${{ matrix.rails_version }}
47
+ path: coverage
48
+
49
+ - name: Show coverage
50
+ if: always()
51
+ run: |
52
+ cat coverage/coverage.txt
data/.gitignore CHANGED
@@ -26,3 +26,4 @@ spec/dummy/.sass-cache
26
26
  /coverage/assets
27
27
  /coverage/*.json
28
28
  /coverage/*.json.lock
29
+ /.ruby-version
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 4.3.0
4
+ * Support generating `aria-current` attribute. It's disabled by default. See the readme for more info
5
+
3
6
  ## Version 4.2.0
4
7
  * Support generating JSON-LD structured data. See the readme for more info (via #26, thanks @dkniffin)
5
8
 
data/Gemfile CHANGED
@@ -3,4 +3,6 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  rails_version = ENV['RAILS_VERSION'] || '>= 0'
6
+ rails_version = "~> #{rails_version}" if rails_version =~ /^\d/
7
+
6
8
  gem 'rails', rails_version == 'master' ? { github: 'rails/rails' } : rails_version
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/gretel.svg)](http://badge.fury.io/rb/gretel)
2
- [![Build Status](https://travis-ci.org/kzkn/gretel.svg?branch=master)](https://travis-ci.org/kzkn/gretel)
2
+ ![](https://github.com/kzkn/gretel/workflows/CI/badge.svg)
3
3
 
4
4
  <img src="http://i.imgur.com/CAKEaBM.png" alt="Handle breadcrumb trails... like a boss :)" />
5
5
 
@@ -98,6 +98,7 @@ Option | Description
98
98
  :posttext_class | CSS class for the posttext, if given. Can be set to `nil` for no class. | `"posttext"`
99
99
  :container_tag | Tag type that contains the breadcrumbs. | `:div`
100
100
  :fragment_tag | Tag type to contain each breadcrumb fragment/link. | None
101
+ :aria_current | Value of `aria-current` attribute. | None
101
102
 
102
103
  ### Styles
103
104
 
@@ -202,6 +203,11 @@ end
202
203
  crumb :user do |user|
203
204
  link user_name_for(user), user
204
205
  end
206
+
207
+ # I18n
208
+ crumb :home do
209
+ link t("breadcrumbs.home"), root_path
210
+ end
205
211
  ```
206
212
 
207
213
  ## Building the breadcrumbs manually
@@ -224,7 +230,7 @@ add them back is to use JSON-LD structured data:
224
230
 
225
231
  ```erb
226
232
  <script type="application/ld+json">
227
- <%= breadcrumbs.structured_data(url_base: "https://example.com")) %>
233
+ <%= breadcrumbs.structured_data(url_base: "https://example.com") %>
228
234
  </script>
229
235
  ```
230
236
 
@@ -232,7 +238,7 @@ Or, you can infer `url_base` from `request`:
232
238
 
233
239
  ```erb
234
240
  <script type="application/ld+json">
235
- <%= breadcrumbs.structured_data(url_base: "#{request.protocol}#{request.host_with_port}")) %>
241
+ <%= breadcrumbs.structured_data(url_base: "#{request.protocol}#{request.host_with_port}") %>
236
242
  </script>
237
243
  ```
238
244
 
@@ -309,6 +315,25 @@ breadcrumbs do |links|
309
315
  end
310
316
  ```
311
317
 
318
+ ### ARIA support
319
+
320
+ You can improve the accessibility of your page with the markup that specified in [ARIA](https://www.w3.org/TR/wai-aria-practices/examples/breadcrumb/index.html). Gretel supports generating `aria-current` attribute:
321
+
322
+ ```erb
323
+ <% breadcrumb :issue, @issue %>
324
+ <%= breadcrumbs aria_current: "page" %>
325
+ ```
326
+
327
+ This will generate the following HTML (indented for readability):
328
+
329
+ ```html
330
+ <div class="breadcrumbs">
331
+ <a href="/">Home</a> &rsaquo;
332
+ <a href="/issues">All issues</a> &rsaquo;
333
+ <span class="current" aria-current="page">My Issue</span>
334
+ </div>
335
+ ```
336
+
312
337
  ## Documentation
313
338
 
314
339
  * [Full documentation](https://rubydoc.info/gems/gretel)
@@ -17,7 +17,8 @@ module Gretel
17
17
  current_class: "current",
18
18
  pretext_class: "pretext",
19
19
  posttext_class: "posttext",
20
- id: nil
20
+ id: nil,
21
+ aria_current: nil
21
22
  }
22
23
 
23
24
  DEFAULT_STYLES = {
@@ -197,7 +198,7 @@ module Gretel
197
198
  # The current link is handled a little differently, and is only linked if specified in the options
198
199
  current_link = links.last
199
200
  position = links.size
200
- fragments << render_fragment(options[:fragment_tag], current_link.text, (options[:link_current] ? current_link.url : nil), options[:semantic], position, fragment_class: options[:fragment_class], class: options[:current_class], current_link: current_link.url)
201
+ fragments << render_fragment(options[:fragment_tag], current_link.text, (options[:link_current] ? current_link.url : nil), options[:semantic], position, fragment_class: options[:fragment_class], class: options[:current_class], current_link: current_link.url, aria_current: options[:aria_current])
201
202
 
202
203
  # Build the final HTML
203
204
  html_fragments = []
@@ -239,15 +240,17 @@ module Gretel
239
240
  fragment_tag = fragment_tag || 'span'
240
241
  text = content_tag(:span, text, itemprop: "name")
241
242
 
243
+ aria_current = options[:aria_current]
242
244
  if url.present?
243
- text = breadcrumb_link_to(text, url, itemprop: "item")
245
+ text = breadcrumb_link_to(text, url, itemprop: "item", "aria-current": aria_current)
246
+ aria_current = nil
244
247
  elsif options[:current_link].present?
245
248
  current_url = "#{root_url}#{options[:current_link].gsub(/^\//, '')}"
246
249
  text = text + tag(:meta, itemprop: "item", content: current_url)
247
250
  end
248
251
 
249
252
  text = text + tag(:meta, itemprop:"position", content: "#{position}")
250
- content_tag(fragment_tag.to_sym, text, class: fragment_class, itemprop: "itemListElement", itemscope: "", itemtype: "https://schema.org/ListItem")
253
+ content_tag(fragment_tag.to_sym, text, class: fragment_class, itemprop: "itemListElement", itemscope: "", itemtype: "https://schema.org/ListItem", "aria-current": aria_current)
251
254
  end
252
255
 
253
256
  # Renders regular, non-semantic fragment HTML.
@@ -256,12 +259,16 @@ module Gretel
256
259
  fragment_class = nil if fragment_class.blank?
257
260
 
258
261
  if fragment_tag
259
- text = breadcrumb_link_to(text, url) if url.present?
260
- content_tag(fragment_tag, text, class: fragment_class)
262
+ if url.present?
263
+ text = breadcrumb_link_to(text, url, "aria-current": options[:aria_current])
264
+ content_tag(fragment_tag, text, class: fragment_class)
265
+ else
266
+ content_tag(fragment_tag, text, class: fragment_class, "aria-current": options[:aria_current])
267
+ end
261
268
  elsif url.present?
262
- breadcrumb_link_to(text, url, class: fragment_class)
269
+ breadcrumb_link_to(text, url, class: fragment_class, "aria-current": options[:aria_current])
263
270
  elsif options[:class].present?
264
- content_tag(:span, text, class: fragment_class)
271
+ content_tag(:span, text, class: fragment_class, "aria-current": options[:aria_current])
265
272
  else
266
273
  text
267
274
  end
@@ -1,3 +1,3 @@
1
1
  module Gretel
2
- VERSION = "4.2.0"
2
+ VERSION = "4.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gretel
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lasse Bunk
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-11-04 00:00:00.000000000 Z
12
+ date: 2021-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -115,8 +115,8 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - ".github/workflows/ci.yml"
118
119
  - ".gitignore"
119
- - ".travis.yml"
120
120
  - CHANGELOG.md
121
121
  - Gemfile
122
122
  - LICENSE.txt
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  - !ruby/object:Gem::Version
156
156
  version: '0'
157
157
  requirements: []
158
- rubygems_version: 3.0.3
158
+ rubygems_version: 3.2.15
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: Flexible Ruby on Rails breadcrumbs plugin.
data/.travis.yml DELETED
@@ -1,17 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- - 2.7
5
- - 2.6
6
- - 2.5
7
- env:
8
- - RAILS_VERSION="~> 5.1.0"
9
- - RAILS_VERSION="~> 5.2.0"
10
- - RAILS_VERSION="~> 6.0.0"
11
- - RAILS_VERSION="master"
12
- before_script:
13
- - "cd spec/dummy; rake db:migrate; rake db:test:prepare; cd ../.."
14
- after_script:
15
- - "cat coverage/coverage.txt"
16
- notifications:
17
- email: false