dsfr_accessible_skip_links 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 794bc710db3516cb3b73043093d4a8e25c5aa2678897e79d0a4e011ae2367cf9
4
- data.tar.gz: a4d345e260e6557364cc9bffc3931986a1e1755f2604b324afba0f1fecfb8076
3
+ metadata.gz: b4afbed35674b0ec24dfc35c348b73396f4ed4ffba52f4924aec310eb876e0a3
4
+ data.tar.gz: 26577cd195e55cb9e7dc0d732c121b1f6fca3f71dd1bd8a8fed0690082f5ae76
5
5
  SHA512:
6
- metadata.gz: 1e4ffb3bd674953927839fa4957b343d3a5df68ef91166267be12a288ac0a18c0d461adb52ab869d01a7443b80978f43d2614fdd30e4b37c5997618ec209fcf9
7
- data.tar.gz: 6534795c4a521680b1cb06cf4f336f9f0ea767cad92a4c54eab9eda1a2fa6a70882b5b7ed8e9d42e95cccbff6efdce6c5fa656d7f2a518128d86c90e6dea7068
6
+ metadata.gz: c642f22b47fbb7df60a42dbe1c9155792feb0c81243d407f6e8870511d56a07acd66fe0439fb8729562fea46c6351ba3ec2aa1ec13bf477c901ca76d0e71e467
7
+ data.tar.gz: ef4bf61ee5484dd794b73dbcbee89a9f4dd72d06dd4525849bfe34c19d86e32020a2843272e380a13bc31c102256478a2d46304a7e265cc280f2e9ba3051361a
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.2] - 2025-08-27
11
+ ### Added
12
+ - Rails generator `dsfr_accessible_skip_links:install` to copy the skip links partial and inject the render call into the application layout.
13
+ - README updated with installation instructions using the generator.
14
+
10
15
  ## [0.1.0] - 2025-08-27
11
16
 
12
17
  ### Added
@@ -14,4 +19,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
19
  - Skip links helper methods for Rails applications
15
20
  - DSFR-compliant CSS classes and HTML structure
16
21
  - Configuration system for customizing default behavior
17
- - Accessibility features following WCAG 2.2 guidelines
22
+ - Accessibility features following WCAG 2.2 guidelines
data/README.md CHANGED
@@ -10,11 +10,15 @@ Add this line to your application's Gemfile:
10
10
  gem 'dsfr_accessible_skip_links'
11
11
  ```
12
12
 
13
- And then execute:
13
+ Then install the gem:
14
14
 
15
15
  $ bundle install
16
16
 
17
- Or install it yourself as:
17
+ Run the installer to set up the skip links in your Rails app (copies the partial and injects the render in your layout):
18
+
19
+ $ bin/rails g dsfr_accessible_skip_links:install
20
+
21
+ You can also install the gem itself directly as:
18
22
 
19
23
  $ gem install dsfr_accessible_skip_links
20
24
 
@@ -131,6 +135,69 @@ This gem implements skip links following WCAG 2.2 guidelines and DSFR specificat
131
135
  - Focus management
132
136
  - Compatible with DSFR CSS for visual styling
133
137
 
138
+ ## How to test this gem
139
+
140
+ There are two main ways to test this gem:
141
+
142
+ 1) Run the gem's test suite locally (fast, no Rails app needed)
143
+ - Install dependencies:
144
+ ```bash
145
+ bundle install
146
+ ```
147
+ - Run RSpec:
148
+ ```bash
149
+ bundle exec rake spec
150
+ ```
151
+ - Run RuboCop:
152
+ ```bash
153
+ bundle exec rake rubocop
154
+ ```
155
+ - Run both (default task):
156
+ ```bash
157
+ bundle exec rake
158
+ ```
159
+
160
+ 2) Try it inside a real Rails app (to test the generator and integration)
161
+ - Create a new Rails app (or use an existing one):
162
+ ```bash
163
+ rails new demo_app --skip-javascript --skip-hotwire --skip-action-mailbox --skip-action-text --skip-active-storage --skip-active-job --skip-system-test
164
+ cd demo_app
165
+ ```
166
+ - Point the app to your local copy of this gem. In demo_app/Gemfile add:
167
+ ```ruby
168
+ gem 'dsfr_accessible_skip_links', path: '../path/to/your/dsfr_accessible_skip_links'
169
+ ```
170
+ Then run:
171
+ ```bash
172
+ bundle install
173
+ ```
174
+ - Run the installer (copies the partial and injects a render line into your layout):
175
+ ```bash
176
+ bin/rails g dsfr_accessible_skip_links:install
177
+ ```
178
+ - Verify changes:
179
+ - The partial should exist at: app/views/shared/_skip_links.html.erb
180
+ - Your app layout (app/views/layouts/application.html.erb) should include:
181
+ ```erb
182
+ <%= render partial: 'shared/skip_links' %>
183
+ ```
184
+ - Ensure your layout has the anchor targets used by default links:
185
+ ```erb
186
+ <header id="header"></header>
187
+ <main id="content"><%= yield %></main>
188
+ <footer id="footer"></footer>
189
+ ```
190
+ - Start the server and check the skip links at the top of the page:
191
+ ```bash
192
+ bin/rails s
193
+ ```
194
+ Visit http://localhost:3000 and look for the skip links markup
195
+ ("Aller au contenu", "Menu", "Pied de page").
196
+
197
+ Notes
198
+ - The generator is idempotent: it won’t insert the render line twice if it already exists.
199
+ - You can customize the skip links in any view using `content_for :skip_links` as described below in Usage.
200
+
134
201
  ## Development
135
202
 
136
203
  After checking out the repo, run `bundle install` to install dependencies.
@@ -154,7 +221,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
154
221
 
155
222
  ## Contributing
156
223
 
157
- Bug reports and pull requests are welcome on GitHub at https://github.com/etalab/dsfr_accessible_skip_links.
224
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Isalafont/dsfr_accessible_skip_links.
158
225
 
159
226
  ## License
160
227
 
@@ -4,6 +4,16 @@ module DsfrAccessibleSkipLinks
4
4
  class Engine < ::Rails::Engine
5
5
  isolate_namespace DsfrAccessibleSkipLinks
6
6
 
7
+ initializer "dsfr_accessible_skip_links.view_paths" do
8
+ ActiveSupport.on_load(:action_controller) do
9
+ prepend_view_path Engine.root.join("app", "views")
10
+ end
11
+
12
+ ActiveSupport.on_load(:action_mailer) do
13
+ prepend_view_path Engine.root.join("app", "views")
14
+ end
15
+ end
16
+
7
17
  config.to_prepare do
8
18
  ApplicationController.include(DsfrAccessibleSkipLinks::SkipLinks) if defined?(ApplicationController)
9
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DsfrAccessibleSkipLinks
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module DsfrAccessibleSkipLinks
6
+ module Generators
7
+ class InstallGenerator < Rails::Generators::Base
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ desc(
11
+ "Installs DsfrAccessibleSkipLinks by copying the skip links partial " \
12
+ "and injecting the render call into the application layout."
13
+ )
14
+ def copy_partial
15
+ template "_skip_links.html.erb", "app/views/shared/_skip_links.html.erb"
16
+ end
17
+
18
+ # rubocop:disable Metrics/MethodLength
19
+ def inject_into_layout
20
+ layout_path = "app/views/layouts/application.html.erb"
21
+ return unless File.exist?(layout_path)
22
+
23
+ render_snippet = " <%= render partial: 'shared/skip_links' %>\n"
24
+
25
+ content = File.read(layout_path)
26
+ if content.include?("render partial: 'shared/skip_links'") || content.include?("render 'shared/skip_links'")
27
+ return
28
+ end
29
+
30
+ if content =~ /<body[^>]*>/
31
+ insert_into_file layout_path, after: /<body[^>]*>\s*\n?/ do
32
+ render_snippet
33
+ end
34
+ else
35
+ # If <body> tag is not found, append at the beginning of the file as a fallback
36
+ prepend_to_file layout_path, render_snippet
37
+ end
38
+ end
39
+ # rubocop:enable Metrics/MethodLength
40
+
41
+ def readme
42
+ say <<~MSG
43
+ DsfrAccessibleSkipLinks installed.
44
+
45
+ - A copy of the skip links partial has been placed at app/views/shared/_skip_links.html.erb
46
+ - Your application layout has been updated to render the skip links.
47
+
48
+ Ensure your layout contains elements with ids: #header, #content, and #footer for the default links.
49
+ MSG
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,7 @@
1
+ <div class="fr-skiplinks">
2
+ <nav class="fr-container" role="navigation" aria-label="Accès rapide">
3
+ <ul class="fr-skiplinks__list">
4
+ <%= skip_links_content %>
5
+ </ul>
6
+ </nav>
7
+ </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsfr_accessible_skip_links
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isabelle Lafont
@@ -111,11 +111,12 @@ files:
111
111
  - README.md
112
112
  - Rakefile
113
113
  - app/views/shared/_skip_links.html.erb
114
- - dsfr_accessible_skip_links.gemspec
115
114
  - lib/dsfr_accessible_skip_links.rb
116
115
  - lib/dsfr_accessible_skip_links/engine.rb
117
116
  - lib/dsfr_accessible_skip_links/skip_links.rb
118
117
  - lib/dsfr_accessible_skip_links/version.rb
118
+ - lib/generators/dsfr_accessible_skip_links/install_generator.rb
119
+ - lib/generators/dsfr_accessible_skip_links/templates/_skip_links.html.erb
119
120
  homepage: https://github.com/Isalafont/dsfr_accessible_skip_links
120
121
  licenses:
121
122
  - MIT
@@ -125,7 +126,13 @@ metadata:
125
126
  source_code_uri: https://github.com/Isalafont/dsfr_accessible_skip_links
126
127
  changelog_uri: https://github.com/Isalafont/dsfr_accessible_skip_links/blob/main/CHANGELOG.md
127
128
  rubygems_mfa_required: 'true'
128
- post_install_message:
129
+ post_install_message: |
130
+ Thank you for installing dsfr_accessible_skip_links (v0.1.2)!
131
+
132
+ To complete setup in your Rails app, run:
133
+ bin/rails g dsfr_accessible_skip_links:install
134
+
135
+ This will copy the skip links partial and inject the render call into your application layout.
129
136
  rdoc_options: []
130
137
  require_paths:
131
138
  - lib
@@ -140,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
147
  - !ruby/object:Gem::Version
141
148
  version: '0'
142
149
  requirements: []
143
- rubygems_version: 3.5.9
150
+ rubygems_version: 3.3.3
144
151
  signing_key:
145
152
  specification_version: 4
146
153
  summary: Accessible skip links implementation following DSFR (Système de design de
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/dsfr_accessible_skip_links/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "dsfr_accessible_skip_links"
7
- spec.version = DsfrAccessibleSkipLinks::VERSION
8
- spec.authors = ["Isabelle Lafont"]
9
- spec.email = ["isalafont@gmail.com"]
10
- spec.summary = "Accessible skip links implementation following DSFR (Système de design de l'État français) guidelines"
11
- spec.description = "A Ruby gem that helps projects implement accessible skip links according to " \
12
- "the French government design system (DSFR). Provides helpers and utilities " \
13
- "for creating navigation skip links that improve accessibility."
14
- spec.homepage = "https://github.com/Isalafont/dsfr_accessible_skip_links"
15
- spec.license = "MIT"
16
- spec.required_ruby_version = ">= 2.6.0"
17
-
18
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/Isalafont/dsfr_accessible_skip_links"
21
- spec.metadata["changelog_uri"] = "https://github.com/Isalafont/dsfr_accessible_skip_links/blob/main/CHANGELOG.md"
22
- spec.metadata["rubygems_mfa_required"] = "true"
23
-
24
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
- `git ls-files -z 2>/dev/null`.split("\x0").reject do |f|
26
- (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
- end
28
- end
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
32
-
33
- spec.add_development_dependency "bundler", "~> 2.0"
34
- spec.add_development_dependency "rake", "~> 13.0"
35
- spec.add_development_dependency "rspec", "~> 3.0"
36
- spec.add_development_dependency "rubocop", "~> 1.0"
37
- spec.add_development_dependency "rubocop-rake", "~> 0.6"
38
- spec.add_development_dependency "rubocop-rspec", "~> 2.0"
39
- end