-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10137 from colinux/faqs
Internalisation de la FAQ
- Loading branch information
Showing
144 changed files
with
2,044 additions
and
71 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.37 KB
app/assets/images/faq/administrateur-repetition-view-usager-empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.4 KB
app/assets/images/faq/administrateur-test-instruction-dossiers-list.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.markdown-content { | ||
img { | ||
max-width: 100%; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); | ||
|
||
display: block; | ||
|
||
// In markdown img are always wrapped in p, | ||
// which already contains vertical margin. | ||
// We only add margin when there are siblings. | ||
// NOTE: CSS consider the img is only-child even | ||
// when there are only text node siblings, but it's still fine for us. | ||
margin: 1.5rem auto; | ||
|
||
&:only-child { | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
class FAQController < ApplicationController | ||
before_action :load_faq_data, only: :show | ||
|
||
def index | ||
@faqs = loader_service.all | ||
end | ||
|
||
def show | ||
@renderer = Redcarpet::Markdown.new(Redcarpet::TrustedRenderer.new(view_context), autolink: true) | ||
|
||
@siblings = loader_service.faqs_for_category(@metadata[:category]) | ||
end | ||
|
||
private | ||
|
||
def loader_service | ||
@loader_service ||= begin | ||
substitutions = { | ||
application_base_url: Current.application_base_url, | ||
application_name: Current.application_name, | ||
contact_email: Current.contact_email | ||
} | ||
|
||
FAQsLoaderService.new(substitutions) | ||
end | ||
end | ||
|
||
def load_faq_data | ||
path = "#{params[:category]}/#{params[:slug]}" | ||
faq_data = loader_service.find(path) | ||
|
||
@content = faq_data.content | ||
@metadata = faq_data.front_matter.symbolize_keys | ||
rescue KeyError | ||
raise ActionController::RoutingError.new("FAQ not found: #{path}") | ||
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Redcarpet | ||
class TrustedRenderer < Redcarpet::Render::HTML | ||
include ActionView::Helpers::TagHelper | ||
include Sprockets::Rails::Helper | ||
include ApplicationHelper | ||
|
||
attr_reader :view_context | ||
|
||
def initialize(view_context, extensions = {}) | ||
@view_context = view_context | ||
|
||
super extensions | ||
end | ||
|
||
def link(href, title, content) | ||
html_options = { | ||
href: href | ||
} | ||
|
||
unless href.starts_with?('/') | ||
html_options.merge!(title: new_tab_suffix(title), **external_link_attributes) | ||
end | ||
|
||
content_tag(:a, content, html_options, false) | ||
end | ||
|
||
def autolink(link, link_type) | ||
case link_type | ||
when :url | ||
link(link, nil, link) | ||
when :email | ||
# NOTE: As of Redcarpet 3.6.0, autolinking email containing underscore is broken https://github.com/vmg/redcarpet/issues/402 | ||
content_tag(:a, link, { href: "mailto:#{link}" }) | ||
end | ||
end | ||
|
||
def image(link, title, alt) | ||
view_context.image_tag(link, title:, alt:, loading: :lazy) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# frozen_string_literal: true | ||
|
||
class FAQsLoaderService | ||
PATH = Rails.root.join('doc', 'faqs').freeze | ||
ORDER = ['usager', 'instructeur', 'administrateur'].freeze | ||
|
||
attr_reader :substitutions | ||
|
||
def initialize(substitutions) | ||
@substitutions = substitutions | ||
|
||
@faqs_by_path ||= Rails.cache.fetch(["faqs_data", ApplicationVersion.current, substitutions], expires_in: 1.week) do | ||
load_faqs | ||
end | ||
end | ||
|
||
def find(path) | ||
Rails.cache.fetch(["faq", path, ApplicationVersion.current, substitutions], expires_in: 1.week) do | ||
file_path = @faqs_by_path.fetch(path).fetch(:file_path) | ||
|
||
parse_with_substitutions(file_path) | ||
end | ||
end | ||
|
||
def faqs_for_category(category) | ||
@faqs_by_path.values | ||
.filter { |faq| faq[:category] == category } | ||
.group_by { |faq| faq[:subcategory] } | ||
end | ||
|
||
def all | ||
@faqs_by_path.values | ||
.group_by { |faq| faq.fetch(:category) } | ||
.sort_by { |category, _| ORDER.index(category) || ORDER.size } | ||
.to_h | ||
.transform_values do |faqs| | ||
faqs.group_by { |faq| faq.fetch(:subcategory) } | ||
end | ||
end | ||
|
||
private | ||
|
||
def load_faqs | ||
Dir.glob("#{PATH}/**/*.md").each_with_object({}) do |file_path, faqs_by_path| | ||
parsed = parse_with_substitutions(file_path) | ||
front_matter = parsed.front_matter.symbolize_keys | ||
|
||
faq_data = front_matter.slice(:slug, :title, :category, :subcategory, :locale, :keywords).merge(file_path: file_path) | ||
|
||
path = front_matter.fetch(:category) + '/' + front_matter.fetch(:slug) | ||
faqs_by_path[path] = faq_data | ||
end | ||
end | ||
|
||
# Substitute all string before front matter parser so metadata are also substituted. | ||
# using standard ruby formatting, ie => `%{my_var} % { my_var: 'value' }` | ||
# We have to escape % chars not used for substitutions, ie. not preceeded by { | ||
def parse_with_substitutions(file_path) | ||
substituted_content = File.read(file_path).gsub(/%(?!{)/, '%%') % substitutions | ||
|
||
FrontMatterParser::Parser.new(:md).call(substituted_content) | ||
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
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,13 @@ | ||
%nav.fr-breadcrumb{ role: "navigation", 'aria-label': t('you_are_here', scope: [:layouts, :breadcrumb]) } | ||
%button.fr-breadcrumb__button{ 'aria-expanded' => "false", 'aria-controls' => "breadcrumb-1" } | ||
= t('show', scope: [:layouts, :breadcrumb]) | ||
.fr-collapse#breadcrumb-1 | ||
%ol.fr-breadcrumb__list | ||
%li= link_to t('root', scope: [:layouts, :breadcrumb]), root_path, class: 'fr-breadcrumb__link' | ||
|
||
%li | ||
%a.fr-breadcrumb__link{ **(defined?(faq_title) ? { href: faq_index_path } : { "aria-current": "page" }) }= t('faq', scope: [:layouts, :breadcrumb]) | ||
|
||
- if defined?(faq_title) | ||
%li | ||
%a.fr-breadcrumb__link{ 'aria-current' => "page" }= faq_title |
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,20 @@ | ||
%nav.fr-sidemenu.fr-sidemenu--sticky{ role: "navigation", 'aria-labelledby': "fr-sidemenu-title" } | ||
.fr-sidemenu__inner | ||
%button.fr-sidemenu__btn{ 'aria-controls': "fr-sidemenu-wrapper", 'aria-expanded': "false" } | ||
= t(:sidebar_button, scope: [:faq]) | ||
.fr-collapse#fr-sidemenu-wrapper | ||
.fr-sidemenu__title#fr-sidemenu-title | ||
= t(:name, scope: [:faq, :categories, current[:category]]) | ||
%ul.fr-sidemenu__list | ||
- faqs.each_with_index do |(subcategory, faqs), index| | ||
%li{ class: class_names("fr-sidemenu__item", "fr-sidemenu__item--active" => subcategory == current[:subcategory]) } | ||
%button.fr-sidemenu__btn{ aria: { 'expanded': subcategory == current[:subcategory] ? "true" : "false", | ||
'controls': "fr-sidemenu-item-#{index}", | ||
'current' => subcategory == current[:subcategory] ? "true" : nil } } | ||
= t(:name, scope: [:faq, :subcategories, subcategory]) | ||
.fr-collapse{ id: "fr-sidemenu-item-#{index}" } | ||
%ul.fr-sidemenu__list | ||
- faqs.each do |faq| | ||
%li{ class: class_names("fr-sidemenu__item", "fr-sidemenu__item--active" => faq[:slug] == current[:slug]) } | ||
= link_to faq[:title], faq_path(category: faq[:category], slug: faq[:slug]), | ||
class: 'fr-sidemenu__link', target: "_self", "aria-current" => current[:slug] == faq[:slug] ? "page" : nil |
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,26 @@ | ||
- content_for(:title, t('.meta_title')) | ||
|
||
.fr-container.fr-my-4w | ||
= render partial: "breadcrumb" | ||
.fr-grid-row | ||
.fr-col-12.fr-col-md-10 | ||
%h1= t('.title', app_name: Current.application_name) | ||
|
||
- @faqs.each do |category, subcategories| | ||
%h2= t(:name, scope: [:faq, :categories, category], raise: true) # i18n-tasks-use t("faq.categories.#{category}.name") | ||
%p= t(:description, scope: [:faq, :categories, category], raise: true) # i18n-tasks-use t("faq.categories.#{category}.description") | ||
|
||
.fr-accordions-group.fr-mb-6w | ||
- subcategories.each_with_index do |(subcategory, faqs), index| | ||
%section.fr-accordion | ||
%h3.fr-accordion__title | ||
%button.fr-accordion__btn{ 'aria-expanded': "false", 'aria-controls': "accordion-#{category}-#{index}" } | ||
= t(:name, scope: [:faq, :subcategories, subcategory], raise: true) # i18n-tasks-use t("faq.subcategories.#{subcategory}.name") | ||
|
||
.fr-collapse{ id: "accordion-#{category}-#{index}" } | ||
- description = t(:description, scope: [:faq, :subcategories, subcategory], default: nil) # i18n-tasks-use t("faq.subcategories.#{subcategory}.description") | ||
%p= description if description.present? | ||
|
||
%ul | ||
- faqs.each do |faq| | ||
%li= link_to faq[:title], faq_path(category: faq[:category], slug: faq[:slug]), class: "fr-link" |
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,13 @@ | ||
- content_for(:title, @metadata[:title]) | ||
|
||
.fr-container.fr-my-4w | ||
|
||
.fr-grid-row | ||
.fr-col-12.fr-col-md-4 | ||
= render partial: "sidebar", locals: { faqs: @siblings, current: @metadata } | ||
.fr-col-12.fr-col-md-8 | ||
-# i18n-tasks-use t("faq.categories.#{@metadata[:category]}.short_name") | ||
= render partial: "breadcrumb", locals: { faq_title: "#{t(:short_name, scope: [:faq, :categories, @metadata[:category]])} : #{@metadata[:title]}" } | ||
|
||
.markdown-content | ||
= @renderer.render(@content).html_safe |
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
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
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.