Merge pull request #1967 from betagouv/fix-1801
Format links in procedure description (❤️ temps de review ~ 1 minute ❤️)
This commit is contained in:
commit
c38705a890
10 changed files with 17 additions and 16 deletions
|
@ -2,10 +2,4 @@ module ChampHelper
|
|||
def is_not_header_nor_explication?(champ)
|
||||
!['header_section', 'explication'].include?(champ.type_champ)
|
||||
end
|
||||
|
||||
def html_formatted_description(description)
|
||||
html_formatted = simple_format(description)
|
||||
with_links = html_formatted.gsub(URI.regexp, '<a target="_blank" href="\0">\0</a>')
|
||||
sanitize(with_links, attributes: %w(href target))
|
||||
end
|
||||
end
|
||||
|
|
7
app/helpers/string_to_html_helper.rb
Normal file
7
app/helpers/string_to_html_helper.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
module StringToHtmlHelper
|
||||
def string_to_html(str)
|
||||
html_formatted = simple_format(str)
|
||||
with_links = html_formatted.gsub(URI.regexp, '<a target="_blank" href="\0">\0</a>')
|
||||
sanitize(with_links, attributes: %w(href target))
|
||||
end
|
||||
end
|
|
@ -68,7 +68,7 @@
|
|||
%h4.text-info
|
||||
= procedure.libelle
|
||||
|
||||
= h sanitize(procedure.description)
|
||||
= h string_to_html(procedure.description)
|
||||
|
||||
.champs.col-xs-6.col-md-3
|
||||
%h4.text-info
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
= @facade.procedure.libelle
|
||||
|
||||
#description_procedure{ style: 'width: 95%;', class: (@facade.etablissement.nil? ? '' : 'mask') }
|
||||
= h simple_format(@facade.procedure.description)
|
||||
= h string_to_html(@facade.procedure.description)
|
||||
|
||||
- if @facade.procedure.lien_site_web.present?
|
||||
.center
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
%h2.procedure-title
|
||||
= @dossier.procedure.libelle
|
||||
.procedure-description
|
||||
= h simple_format(@dossier.procedure.description)
|
||||
= h string_to_html(@dossier.procedure.description)
|
||||
|
||||
.column
|
||||
= form_for @dossier.individual, url: update_identite_dossier_path(@dossier), html: { class: "form" } do |f|
|
||||
|
|
|
@ -8,4 +8,4 @@
|
|||
= "modifié le #{champ.updated_at.strftime('%d/%m/%Y à %H:%M')}"
|
||||
|
||||
- if champ.description.present?
|
||||
%span.notice= html_formatted_description(champ.description)
|
||||
%span.notice= string_to_html(champ.description)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
%h2.explication-libelle= champ.libelle
|
||||
.explication
|
||||
= html_formatted_description(champ.description)
|
||||
= string_to_html(champ.description)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
%h2#titre-procedure.text-info
|
||||
= @dossier.procedure.libelle
|
||||
%p.procedure-description
|
||||
= h sanitize(@dossier.procedure.description)
|
||||
= h string_to_html(@dossier.procedure.description)
|
||||
|
||||
- else
|
||||
#logo_procedure.flag
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
= @procedure.libelle
|
||||
|
||||
%div
|
||||
= simple_format(@procedure.description)
|
||||
= h string_to_html(@procedure.description)
|
||||
|
||||
%br
|
||||
= form_tag(url_for({ controller: :dossiers, action: :create }), class: 'form-inline', method: 'POST') do |f|
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
RSpec.describe ChampHelper, type: :helper do
|
||||
describe "#html_formatted_description" do
|
||||
subject { html_formatted_description(description) }
|
||||
RSpec.describe StringToHtmlHelper, type: :helper do
|
||||
describe "#string_to_html" do
|
||||
subject { string_to_html(description) }
|
||||
|
||||
context "with some simple texte" do
|
||||
let(:description) { "1er ligne \n 2ieme ligne" }
|
Loading…
Reference in a new issue