app/service_adaptors/hathi_trust.rb in umlaut-3.3.1 vs app/service_adaptors/hathi_trust.rb in umlaut-4.0.0.beta1
- old
+ new
@@ -147,24 +147,25 @@
def create_fulltext_service_response(request, items)
return nil if items.empty?
- display_name = @display_name
count = 0
items.each do |item|
next if is_serial_part?(item)
next unless full_view?(item)
request.add_service_response(
:service=>self,
- :display_text=>display_name,
+ :display_text=> @display_name,
+ :display_text_i18n => "display_name",
:url=> direct_url_to(item),
- :notes=> note_for(item),
+ :add_i18n_notes => "single_volume", # signal for transform_view_data
+ :source_for_i18n => item['orig'],
:service_type_value => :fulltext
)
count += 1
break if count == @num_full_views
end
@@ -181,16 +182,20 @@
end.compact.uniq
full_ids.each do |recordId|
record = ht_json.values.first["records"][recordId]
next unless record && record["recordURL"]
-
+
+ record_title = record["titles"].first if record["titles"].kind_of?(Array)
+
request.add_service_response(
:service=>self,
- :display_text=>@display_name,
+ :display_text=> @display_name,
+ :display_text_i18n => "display_name",
:url=> record["recordURL"],
- :notes => excerpt_note_for(record),
+ :add_i18n_notes => "partial_volume", # signal for transform_view_data
+ :title_for_i18n => record_title,
:service_type_value => :excerpts
)
end
if full_ids.empty?
@@ -202,11 +207,12 @@
record = ht_json.values.first["records"][recordId]
next unless record && record["recordURL"]
request.add_service_response(
:service=>self,
- :display_text=>"Search inside some volumes",
+ :display_text=> "Search inside some volumes",
+ :display_text_i18n => "search_inside_some_vols",
:url=> record["recordURL"],
:service_type_value => :highlighted_link
)
end
@@ -229,11 +235,12 @@
direct_url = search_url_to(item)
return unless direct_url
request.add_service_response(
:service => self,
- :display_text=>@display_name,
+ :display_text=> @display_name,
+ :display_text_i18n => "display_name",
:url=> direct_url,
:service_type_value => :search_inside
)
end
@@ -246,22 +253,20 @@
@direct_link_base + "pt?id=" + CGI.escape(item_json['htid'])
else
item['itemURL']
end
end
-
- def note_for(item)
- if item['orig']
- "Digitized from #{item['orig']}"
- else
- nil
+
+ def transform_view_data(hash)
+ if hash[:add_i18n_notes] == "single_volume"
+ hash[:notes] = translate("note_for_single_vol", :source => (hash[:source_for_i18n] || ""))
+ elsif hash[:add_i18n_notes] == "partial_volume"
+ hash[:notes] = translate("note_for_multi_vol", :title => (hash[:title_for_i18n] || ""))
end
+
+ return hash
end
- def excerpt_note_for(record)
- return nil unless record["titles"].kind_of?(Array)
- "Some volumes of: #{record["titles"].first}"
- end
def is_serial_part?(item)
# if it's got enumCron, then it's just part of a serial,
# we don't want to say the serial title as a whole has full text
# or can be searched, skip it.