Module: Warclight::SolrDocument

Extended by:
Blacklight::Solr::Document
Defined in:
app/models/concerns/warclight/solr_document.rb

Overview

Extends Blacklight::Solr::Document to provide Warclight specific behavior

Instance Method Summary collapse

Instance Method Details



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/concerns/warclight/solr_document.rb', line 9

def replay_link
  time_travel_base_url = 'http://timetravel.mementoweb.org/api/json/'
  time_travel_request_url = time_travel_base_url + first(:wayback_date).to_s + '/' + first(:url).to_s
  time_travel_request = URI(time_travel_request_url)
  time_travel_response = Net::HTTP.get(time_travel_request)
  if time_travel_response.present?
    time_travel_response_json = JSON.parse(time_travel_response)
    replay_url = time_travel_response_json['mementos']['closest']['uri'][0]
    replay_url_link = '<a href="' + "#{replay_url}" '" target="_blank">'"#{replay_url}"'</a> 🔗'
    replay_url_link.html_safe
  else
    replay_url = 'Not Available.'
  end
end