From 58b9135c711d8abd7fc9b7f29113c3e5bb76af86 Mon Sep 17 00:00:00 2001 From: Amaia Castro Date: Mon, 13 Feb 2017 11:18:33 +0100 Subject: [PATCH] Add context to annotation in index view --- app/models/legislation/annotation.rb | 2 +- app/views/legislation/annotations/index.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/legislation/annotation.rb b/app/models/legislation/annotation.rb index 52e784dcf..05eaad6f5 100644 --- a/app/models/legislation/annotation.rb +++ b/app/models/legislation/annotation.rb @@ -35,7 +35,7 @@ class Legislation::Annotation < ActiveRecord::Base selector_end = "/html/body/#{range_end}" el_end = doc.at_xpath(selector_end) - remainder_el_start = el_start.text[0 .. range_start_offset-1] + remainder_el_start = el_start.text[0 .. range_start_offset-1] unless range_start_offset.zero? remainder_el_end = el_end.text[range_end_offset .. -1] self.context = "#{remainder_el_start}#{quote}#{remainder_el_end}" diff --git a/app/views/legislation/annotations/index.html.erb b/app/views/legislation/annotations/index.html.erb index 87efc3614..d7b1ae3fe 100644 --- a/app/views/legislation/annotations/index.html.erb +++ b/app/views/legislation/annotations/index.html.erb @@ -20,7 +20,7 @@ <% end %>
- <%= annotation.quote %> + <%= annotation.context.try(:html_safe).presence || annotation.quote %>
<%= link_to legislation_process_draft_version_annotation_path(@process, @draft_version, annotation) do %> <%= t('.comments_count', count: annotation.comments_count) %>