Skip to content

Commit 88fa8c2

Browse files
Fix issues with rick text links
1 parent 8ac6cf1 commit 88fa8c2

File tree

9 files changed

+70
-35
lines changed

9 files changed

+70
-35
lines changed

app/Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@ gem 'omniauth-rails_csrf_protection', '~> 1.0' # prevents forged authentication
8787
# webpack
8888
gem 'pg'
8989
gem 'webpacker'
90+
gem 'nokogiri'

app/Gemfile.lock

+1
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ DEPENDENCIES
434434
image_processing (~> 1.2)
435435
importmap-rails
436436
jbuilder
437+
nokogiri
437438
omniauth-auth0 (~> 3.0)
438439
omniauth-rails_csrf_protection (~> 1.0)
439440
pg

app/app/views/assumptions/_assumption.html.erb

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
<p>
88
<strong>Description:</strong>
9-
<%= assumption.description %>
9+
<% doc = Nokogiri::HTML.fragment(assumption.description.to_s) %>
10+
<% doc.css('a').each do |link| %>
11+
<% link.set_attribute('target', '_blank') %>
12+
<% link.set_attribute('rel', 'noopener noreferrer') %>
13+
<% end %>
14+
<%= doc.to_html.html_safe %>
1015
<%= "No description provided" if assumption.description.empty? %>
1116
</p>
1217

app/app/views/assumptions/_form.html.erb

+29-23
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,45 @@
1212
</div>
1313
<% end %>
1414

15-
<div>
15+
<div class="form-group">
1616
<%= form.label :name, style: "display: block" %>
17-
<%= form.text_field :name %>
17+
<%= form.text_field :name, class: 'form-control' %>
1818
</div>
1919

20-
<br>
20+
<br>
2121

22-
<div>
22+
<div class="form-group">
2323
<%= form.label :description, style: "display: block" %>
2424
<%= form.rich_text_area :description %>
2525
</div>
2626

27-
<br>
28-
29-
<div class="field">
30-
<%= form.label :theory_ids, "Select Theory" %> <br>
31-
<% Theory.all.each do |theory| %>
32-
<%= check_box_tag "assumption[theory_ids][]", theory.id, @assumption.theories.include?(theory), id: "theory_#{theory.id}" %>
33-
<%= label_tag "theory_#{theory.id}", theory.name, for: "theory_#{theory.id}" %> <br>
34-
<% end %>
35-
</div>
36-
37-
<br>
27+
<br>
28+
29+
<div class="field form-group">
30+
<%= form.label :theory_ids, "Select Theory" %>
31+
<% Theory.all.each do |theory| %>
32+
<div class="form-check">
33+
<%= check_box_tag "assumption[theory_ids][]", theory.id, @assumption.theories.include?(theory),
34+
id: "theory_#{theory.id}", class: 'form-check-input' %>
35+
<%= label_tag "theory_#{theory.id}", theory.name, for: "theory_#{theory.id}", class: 'form-check-label' %>
36+
</div>
37+
<% end %>
38+
</div>
3839

39-
<div class="field">
40-
<%= form.label :practice_ids, "Select Practice" %> <br>
41-
<% Practice.all.each do |practice| %>
42-
<%= check_box_tag "assumption[practice_ids][]", practice.id, @assumption.practices.include?(practice), id: "practice_#{practice.id}" %>
43-
<%= label_tag "practice_#{practice.id}", practice.name, for: "practice_#{practice.id}" %> <br>
44-
<% end %>
45-
</div>
40+
<br>
41+
42+
<div class="field form-group">
43+
<%= form.label :practice_ids, "Select Practice" %>
44+
<% Practice.all.each do |practice| %>
45+
<div class="form-check">
46+
<%= check_box_tag "assumption[practice_ids][]", practice.id, @assumption.practices.include?(practice),
47+
id: "practice_#{practice.id}", class: 'form-check-input' %>
48+
<%= label_tag "practice_#{practice.id}", practice.name, for: "practice_#{practice.id}", class: 'form-check-label' %>
49+
</div>
50+
<% end %>
51+
</div>
4652

47-
<br>
53+
<br>
4854

4955
<div>
5056
<%= form.submit %>

app/app/views/practices/_form.html.erb

+10-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,23 @@
1313
<% end %>
1414

1515
<div>
16-
<%= form.label :name, style: "display: block" %>
17-
<%= form.text_field :name %>
16+
<div class="form-group">
17+
<%= form.label :name, style: "display: block" %>
18+
<%= form.text_field :name, class: 'form-control' %>
19+
</div>
1820
</div>
1921

22+
<br>
23+
2024
<div>
2125
<%= form.label :description, style: "display: block" %>
2226
<%= form.rich_text_area :description %>
2327
</div>
2428

29+
<br>
30+
31+
<br>
32+
2533
<div>
2634
<%= form.submit %>
2735
</div>

app/app/views/practices/_practice.html.erb

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55

66
<p>
77
<strong>Description:</strong>
8-
<%= practice.description %>
8+
<% doc = Nokogiri::HTML.fragment(practice.description.to_s) %>
9+
<% doc.css('a').each do |link| %>
10+
<% link.set_attribute('target', '_blank') %>
11+
<% link.set_attribute('rel', 'noopener noreferrer') %>
12+
<% end %>
13+
<%= doc.to_html.html_safe %>
14+
915
<%= "No description provided" if practice.description.empty? %>
1016
</p>
1117

app/app/views/theories/_form.html.erb

+9-6
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,28 @@
1212
</div>
1313
<% end %>
1414

15-
<div>
15+
<div class="form-group">
1616
<%= form.label :name, style: "display: block" %>
17-
<%= form.text_field :name %>
17+
<%= form.text_field :name, class: 'form-control' %>
1818
</div>
1919

2020
<br>
2121

22-
<div>
22+
<div class="form-group">
2323
<%= form.label :description, style: "display: block" %>
2424
<%= form.rich_text_area :description %>
2525
</div>
2626

2727
<br>
2828

29-
<div class="field">
29+
<div class="field form-group">
3030
<%= form.label :assumption_ids, "Select Assumptions" %><br>
3131
<% Assumption.all.each do |assumption| %>
32-
<%= check_box_tag "theory[assumption_ids][]", assumption.id, @theory.assumptions.include?(assumption), id: "assumption_#{assumption.id}" %>
33-
<%= label_tag "assumption_#{assumption.id}", assumption.name, for: "assumption_#{assumption.id}" %> <br>
32+
<div class="form-check">
33+
<%= check_box_tag "theory[assumption_ids][]", assumption.id, @theory.assumptions.include?(assumption),
34+
id: "assumption_#{assumption.id}", class: 'form-check-input' %>
35+
<%= label_tag "assumption_#{assumption.id}", assumption.name, for: "assumption_#{assumption.id}", class: 'form-check-label' %>
36+
</div>
3437
<% end %>
3538
</div>
3639

app/app/views/theories/_theory.html.erb

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55

66
<p>
77
<strong>Description:</strong>
8-
<%= theory.description %>
9-
<%= "No description provided" if theory.description.empty? %>
8+
<% doc = Nokogiri::HTML.fragment(theory.description.to_s) %>
9+
<% doc.css('a').each do |link| %>
10+
<% link.set_attribute('target', '_blank') %>
11+
<% link.set_attribute('rel', 'noopener noreferrer') %>
12+
<% end %>
13+
<%= doc.to_html.html_safe %>
14+
<%= "No description provided" if theory.description.empty? %>
1015
</p>
1116

1217
<% theory.assumptions.each do |assump| %>

app/db/development.sqlite3

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)