Skip to content

Commit

Permalink
Fix issues with rick text links
Browse files Browse the repository at this point in the history
  • Loading branch information
IsurangaPerera committed Apr 26, 2023
1 parent 8ac6cf1 commit 88fa8c2
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 35 deletions.
1 change: 1 addition & 0 deletions app/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ gem 'omniauth-rails_csrf_protection', '~> 1.0' # prevents forged authentication
# webpack
gem 'pg'
gem 'webpacker'
gem 'nokogiri'
1 change: 1 addition & 0 deletions app/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ DEPENDENCIES
image_processing (~> 1.2)
importmap-rails
jbuilder
nokogiri
omniauth-auth0 (~> 3.0)
omniauth-rails_csrf_protection (~> 1.0)
pg
Expand Down
7 changes: 6 additions & 1 deletion app/app/views/assumptions/_assumption.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

<p>
<strong>Description:</strong>
<%= assumption.description %>
<% doc = Nokogiri::HTML.fragment(assumption.description.to_s) %>
<% doc.css('a').each do |link| %>
<% link.set_attribute('target', '_blank') %>
<% link.set_attribute('rel', 'noopener noreferrer') %>
<% end %>
<%= doc.to_html.html_safe %>
<%= "No description provided" if assumption.description.empty? %>
</p>

Expand Down
52 changes: 29 additions & 23 deletions app/app/views/assumptions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,45 @@
</div>
<% end %>

<div>
<div class="form-group">
<%= form.label :name, style: "display: block" %>
<%= form.text_field :name %>
<%= form.text_field :name, class: 'form-control' %>
</div>

<br>
<br>

<div>
<div class="form-group">
<%= form.label :description, style: "display: block" %>
<%= form.rich_text_area :description %>
</div>

<br>

<div class="field">
<%= form.label :theory_ids, "Select Theory" %> <br>
<% Theory.all.each do |theory| %>
<%= check_box_tag "assumption[theory_ids][]", theory.id, @assumption.theories.include?(theory), id: "theory_#{theory.id}" %>
<%= label_tag "theory_#{theory.id}", theory.name, for: "theory_#{theory.id}" %> <br>
<% end %>
</div>

<br>
<br>

<div class="field form-group">
<%= form.label :theory_ids, "Select Theory" %>
<% Theory.all.each do |theory| %>
<div class="form-check">
<%= check_box_tag "assumption[theory_ids][]", theory.id, @assumption.theories.include?(theory),
id: "theory_#{theory.id}", class: 'form-check-input' %>
<%= label_tag "theory_#{theory.id}", theory.name, for: "theory_#{theory.id}", class: 'form-check-label' %>
</div>
<% end %>
</div>

<div class="field">
<%= form.label :practice_ids, "Select Practice" %> <br>
<% Practice.all.each do |practice| %>
<%= check_box_tag "assumption[practice_ids][]", practice.id, @assumption.practices.include?(practice), id: "practice_#{practice.id}" %>
<%= label_tag "practice_#{practice.id}", practice.name, for: "practice_#{practice.id}" %> <br>
<% end %>
</div>
<br>

<div class="field form-group">
<%= form.label :practice_ids, "Select Practice" %>
<% Practice.all.each do |practice| %>
<div class="form-check">
<%= check_box_tag "assumption[practice_ids][]", practice.id, @assumption.practices.include?(practice),
id: "practice_#{practice.id}", class: 'form-check-input' %>
<%= label_tag "practice_#{practice.id}", practice.name, for: "practice_#{practice.id}", class: 'form-check-label' %>
</div>
<% end %>
</div>

<br>
<br>

<div>
<%= form.submit %>
Expand Down
12 changes: 10 additions & 2 deletions app/app/views/practices/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,23 @@
<% end %>

<div>
<%= form.label :name, style: "display: block" %>
<%= form.text_field :name %>
<div class="form-group">
<%= form.label :name, style: "display: block" %>
<%= form.text_field :name, class: 'form-control' %>
</div>
</div>

<br>

<div>
<%= form.label :description, style: "display: block" %>
<%= form.rich_text_area :description %>
</div>

<br>

<br>

<div>
<%= form.submit %>
</div>
Expand Down
8 changes: 7 additions & 1 deletion app/app/views/practices/_practice.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@

<p>
<strong>Description:</strong>
<%= practice.description %>
<% doc = Nokogiri::HTML.fragment(practice.description.to_s) %>
<% doc.css('a').each do |link| %>
<% link.set_attribute('target', '_blank') %>
<% link.set_attribute('rel', 'noopener noreferrer') %>
<% end %>
<%= doc.to_html.html_safe %>

<%= "No description provided" if practice.description.empty? %>
</p>

Expand Down
15 changes: 9 additions & 6 deletions app/app/views/theories/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,28 @@
</div>
<% end %>

<div>
<div class="form-group">
<%= form.label :name, style: "display: block" %>
<%= form.text_field :name %>
<%= form.text_field :name, class: 'form-control' %>
</div>

<br>

<div>
<div class="form-group">
<%= form.label :description, style: "display: block" %>
<%= form.rich_text_area :description %>
</div>

<br>

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

Expand Down
9 changes: 7 additions & 2 deletions app/app/views/theories/_theory.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@

<p>
<strong>Description:</strong>
<%= theory.description %>
<%= "No description provided" if theory.description.empty? %>
<% doc = Nokogiri::HTML.fragment(theory.description.to_s) %>
<% doc.css('a').each do |link| %>
<% link.set_attribute('target', '_blank') %>
<% link.set_attribute('rel', 'noopener noreferrer') %>
<% end %>
<%= doc.to_html.html_safe %>
<%= "No description provided" if theory.description.empty? %>
</p>

<% theory.assumptions.each do |assump| %>
Expand Down
Binary file modified app/db/development.sqlite3
Binary file not shown.

0 comments on commit 88fa8c2

Please sign in to comment.