From e13eb2e84f80e7fe218cfad1a503bb36f29e4717 Mon Sep 17 00:00:00 2001 From: Erez Freiberger Date: Mon, 12 Mar 2018 10:50:39 +0200 Subject: [PATCH] move formating with links to application helper --- app/helpers/application_helper.rb | 6 ++++++ app/views/camps/show.html.erb | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be794..115e2ac0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,8 @@ module ApplicationHelper + def simple_format_with_links(text) + simple_format(sanitize(Rinku.auto_link(text, :all, 'target="_blank"'), + attributes: ['href', 'target']), + {class: "auto-#{@detector.direction(text)}"}, + sanitize: false ) + end end diff --git a/app/views/camps/show.html.erb b/app/views/camps/show.html.erb index 68043734..03a783de 100644 --- a/app/views/camps/show.html.erb +++ b/app/views/camps/show.html.erb @@ -137,49 +137,49 @@ <% if Rails.configuration.x.firestarter_settings["description"] and @camp.description.present? %>
<%=t :form_description_label %> - <%= simple_format(Rinku.auto_link(@camp.description, :all, 'target="_blank"'), class: "auto-#{@detector.direction(@camp.description)}" ) %> + <%= simple_format_with_links(@camp.description) %>
<% end %> <% if @camp.about_the_artist.present? %>
<%=t :form_about_the_artist_label %> - <%= simple_format(Rinku.auto_link(@camp.about_the_artist, :all, 'target="_blank"'), class: "auto-#{@detector.direction(@camp.about_the_artist)}" ) %> + <%= simple_format_with_links(@camp.about_the_artist) %>
<% end %> <% if Rails.configuration.x.firestarter_settings["plan"] and @camp.plan.present? %>
<%=t :form_plan_label %> - <%= simple_format(Rinku.auto_link(@camp.plan, :all, 'target="_blank"'), class: "auto-#{@detector.direction(@camp.plan)}" ) %> + <%= simple_format_with_links(@camp.plan) %>
<% end %> <% if Rails.configuration.x.firestarter_settings["moop"] and @camp.moop.present? %>
<%=t :form_moop_label %> - <%= simple_format(Rinku.auto_link(@camp.moop, :all, 'target="_blank"'), class: "auto-#{@detector.direction(@camp.moop)}" ) %> + <%= simple_format_with_links(@camp.moop) %>
<% end %> <% if Rails.configuration.x.firestarter_settings["recycling"] and @camp.recycling.present? %>
<%=t :form_recycling_label %> - <%= simple_format(Rinku.auto_link(@camp.recycling, :all, 'target="_blank"'), class: "auto-#{@detector.direction(@camp.recycling)}" ) %> + <%= simple_format_with_links(@camp.recycling) %>
<% end %> <% if Rails.configuration.x.firestarter_settings["budgetplan"] and @camp.budgetplan.present? %>
<%=t :form_budgetplan_label %> - <%= simple_format(Rinku.auto_link(@camp.budgetplan, :all, 'target="_blank"'), class: "auto-#{@detector.direction(@camp.budgetplan)}" ) %> + <%= simple_format_with_links(@camp.budgetplan) %>
<% end %> <% if Rails.configuration.x.firestarter_settings["cocreation"] and @camp.cocreation.present? %>
<%=t :form_cocreation_label %> - <%= simple_format(Rinku.auto_link(@camp.cocreation, :all, 'target="_blank"'), class: "auto-#{@detector.direction(@camp.cocreation)}" ) %> + <%= simple_format_with_links(@camp.cocreation) %>
<% end %>