-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/update-rubocop
- Loading branch information
Showing
46 changed files
with
1,023 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.4.1 | ||
3.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,35 @@ | ||
// Avoid "the notch" on iPhones and Pixel phones | ||
@supports (width: env(safe-area-inset-left)) { | ||
@media only screen and (orientation: landscape) { | ||
body main { | ||
padding-left: env(safe-area-inset-left); | ||
padding-right: env(safe-area-inset-right); | ||
} | ||
} | ||
} | ||
|
||
// Rend les formulaires button_to "transparents" pour les styles | ||
// Permet d'utiliser des liens et des boutons dans un btn-group | ||
form.button_to { | ||
display: contents; | ||
} | ||
|
||
// Centre l'icône quand le badge n'a pas de texte visible | ||
.fr-badge[role=tooltip]::before { | ||
margin-right: -.125rem; | ||
cursor: help; | ||
.fr-badge { | ||
// Ajoute un outline quand il contient un lien caché qui a le focus | ||
&:has(a:focus) { | ||
outline-color: #0a76f6; | ||
outline-style: solid; | ||
outline-width: 2px; | ||
a { | ||
outline: none; | ||
} | ||
} | ||
&[role=tooltip] { | ||
outline-offset: 0; | ||
// Centre l'icône quand le badge n'a pas de texte visible | ||
&::before { | ||
margin-right: -.125rem; | ||
cursor: help; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails | ||
import "@hotwired/turbo-rails" | ||
import "@hotwired/stimulus" | ||
import "@gouvfr/dsfr" | ||
import "controllers" | ||
import "application" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
class RunCheckJob < ApplicationJob | ||
def perform | ||
check = params.values_at(:check) | ||
return unless check.runnable? | ||
def perform(check) | ||
return unless check.due? | ||
|
||
check.run | ||
|
||
UpdateAuditStatusJob.with(check.audit).perform_later | ||
check.audit.update(checked_at: Time.zone.now) | ||
|
||
UpdateAuditStatusJob.perform_later(check.audit) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
class UpdateAuditStatusJob < ApplicationJob | ||
def perform | ||
audit = params.values_at(:audit) | ||
def perform(audit) | ||
audit.derive_status_from_checks | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
module Analyzers | ||
class AccessibilityPage | ||
DECLARATION = /Déclaration d('|')accessibilité( RGAA)?/i | ||
ARTICLE = /(?:art(?:icle)?\.? 47|article 47) (?:de la )?loi (?:n[°˚]|num(?:éro)?\.?) ?2005-102 du 11 (?:février|fevrier) 2005/i | ||
DATE_PATTERN = /(?:réalisé(?:e)?(?:\s+le)?|du|en)\s+(?:(\d{1,2})(?:\s+|er\s+)?)?([a-zéû]+)\s+(\d{4})/i | ||
COMPLIANCE_PATTERN = /(?:(?:avec (?:un |une )?)?taux de conformité|conforme à|révèle que).*?(\d+(?:[.,]\d+)?)(?:\s*%| pour cent)/i | ||
STANDARD_PATTERN = /(?:au |des critères )?(?:(RGAA(?:[. ](?:version|v)?[. ]?\d+(?:\.\d+(?:\.\d+)?)?)?|(WCAG)))/i | ||
AUDITOR_PATTERN = /(?:par(?:\s+la)?(?:\s+société)?|par)\s+([^,]+?)(?:,| révèle| sur)/i | ||
|
||
attr_reader :page | ||
delegate :url, :title, :text, to: :page | ||
|
||
class << self | ||
def analyze(crawler) | ||
new(crawler:).data | ||
end | ||
end | ||
|
||
def initialize(crawler: nil, page: nil) | ||
@crawler = crawler | ||
@page = page || (find_page if crawler) # Allow passing a page to simplify testing | ||
end | ||
private_class_method :new | ||
|
||
def data = page ? { url:, title:, audit_date:, compliance_rate:, standard:, auditor: } : {} | ||
|
||
def audit_date | ||
return unless (match = text.match(DATE_PATTERN)) | ||
|
||
day = (match[1] || "1").to_i | ||
month = month_names[match[2].downcase] | ||
year = match[3].to_i | ||
|
||
Date.new(year, month, day) | ||
rescue Date::Error | ||
nil | ||
end | ||
|
||
def compliance_rate | ||
return unless (match = text.match(COMPLIANCE_PATTERN)) | ||
|
||
rate = match[1].tr(",", ".").to_f | ||
rate % 1 == 0 ? rate.to_i : rate | ||
end | ||
|
||
def standard | ||
text.scan(STANDARD_PATTERN).flatten.compact.sort_by(&:length).last | ||
end | ||
|
||
def auditor | ||
text.match(AUDITOR_PATTERN)&.[](1)&.strip | ||
end | ||
|
||
def month_names | ||
@month_names ||= begin | ||
names = I18n.t("date.month_names")[1..] + I18n.t("date.abbr_month_names")[1..] | ||
names.each_with_object({}) do |name, hash| | ||
next if name.blank? | ||
|
||
normalized = name.downcase.tr("éû", "eu") | ||
hash[name.downcase] = names.index(name) % 12 + 1 | ||
hash[normalized] = names.index(name) % 12 + 1 | ||
end | ||
end | ||
end | ||
|
||
# Used by sort_by, most relevant links need to have a negative score to come first in the queue | ||
def likelihood_of(link) | ||
return unless link.is_a?(Link) | ||
|
||
[ | ||
link.text.match?(DECLARATION), | ||
link.href.match?("(declaration-)?accessibilite"), | ||
link.text.match?(Checks::AccessibilityMention::MENTION_REGEX) | ||
].count(&:itself).then { |n| n.zero? ? 1 : -n + 1 } | ||
end | ||
|
||
private | ||
|
||
attr_reader :crawler | ||
|
||
def find_page | ||
crawler.find do |current_page, queue| | ||
return current_page if accessibility_page?(current_page) | ||
|
||
sort_queue_by_likelihood(queue) | ||
end | ||
end | ||
|
||
def accessibility_page?(current_page) | ||
current_page.title.match?(DECLARATION) || | ||
current_page.headings.any?(DECLARATION) || | ||
current_page.text.match?(ARTICLE) | ||
end | ||
|
||
def sort_queue_by_likelihood(queue) | ||
queue.sort_by! { |link| likelihood_of(link) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.