dsfr_accessible_skip_links 0.1.1 → 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: 463e7169b07cd041b6e60fd1590f865dae3dd3589df63adaff28e3005f504a7a
4
- data.tar.gz: d660e5cb0f9cdd34e58c4db423e5f6a1ae3f6c6749dd7ea57a3e6afbbbdf96ef
3
+ metadata.gz: b4afbed35674b0ec24dfc35c348b73396f4ed4ffba52f4924aec310eb876e0a3
4
+ data.tar.gz: 26577cd195e55cb9e7dc0d732c121b1f6fca3f71dd1bd8a8fed0690082f5ae76
5
5
  SHA512:
6
- metadata.gz: 6a7b721500e9d5e31b190a9e53c2ff232f9f8d722780f10c65543fe23063e9e5e549aa2c2f0233035441c30ca5b4d4573004496b4ddf091ddba0d2819cc445d0
7
- data.tar.gz: a50f6bedb857566c476cf7cd913c17f411f6bb2f384714530b6e629b4b8abcce7443f731ac224eb349ab12507acd6959259269aa1c8a9bc59bc4ab75e26b45d5
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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DsfrAccessibleSkipLinks
4
- VERSION = "0.1.1"
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isabelle Lafont
@@ -115,6 +115,8 @@ files:
115
115
  - lib/dsfr_accessible_skip_links/engine.rb
116
116
  - lib/dsfr_accessible_skip_links/skip_links.rb
117
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
118
120
  homepage: https://github.com/Isalafont/dsfr_accessible_skip_links
119
121
  licenses:
120
122
  - MIT
@@ -124,7 +126,13 @@ metadata:
124
126
  source_code_uri: https://github.com/Isalafont/dsfr_accessible_skip_links
125
127
  changelog_uri: https://github.com/Isalafont/dsfr_accessible_skip_links/blob/main/CHANGELOG.md
126
128
  rubygems_mfa_required: 'true'
127
- 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.
128
136
  rdoc_options: []
129
137
  require_paths:
130
138
  - lib