Browse Source

Implement sanitation for `phil_rep`

pull/112/head
alexdbondoc17 4 years ago
parent
commit
58099bba41
  1. 6
      app/components/doctrine_index_component.rb
  2. 2
      app/components/doctrine_index_component/doctrine_index_component.html.erb
  3. 6
      app/components/document_doctrine_index_component.rb
  4. 2
      app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
  5. 6
      app/components/document_doctrine_show_component.rb
  6. 2
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb

6
app/components/doctrine_index_component.rb

@ -47,6 +47,12 @@ class DoctrineIndexComponent < BaseComponent
doctrine_path(id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?))
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def render?
doctrine.present? && doctrine.persisted?
end

2
app/components/doctrine_index_component/doctrine_index_component.html.erb

@ -18,7 +18,7 @@
<% end %>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %>
<%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ') %>
</p>
<% if annotation.editor_notes.present? %>

6
app/components/document_doctrine_index_component.rb

@ -41,6 +41,12 @@ class DocumentDoctrineIndexComponent < BaseComponent
annotation.document.year
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def render?
doctrine.present? && doctrine.persisted?
end

2
app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb

@ -35,7 +35,7 @@
<% end %>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %>
<%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ') %>
</p>
<% if annotation.editor_notes.present? %>

6
app/components/document_doctrine_show_component.rb

@ -35,4 +35,10 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.document.year
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
end

2
app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb

@ -94,7 +94,7 @@
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %>
<% end %>
<% citing_document_title = [document_title, annotation.document.reference_number, date_or_year, annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
<% citing_document_title = [document_title, annotation.document.reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
<div class="row mb-2">
<div class="col-sm-10">

Loading…
Cancel
Save