Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def full_uri
end

Search::Datastores.each do |datastore|
if datastore.slug == "catalog"
if datastore.slug == "catalog" || datastore.slug == "onlinejournals"
get "/#{datastore.slug}/record/:id" do
# profile = RubyProf::Profile.new
# profile.start
Expand Down Expand Up @@ -127,7 +127,7 @@ def full_uri
rescue
redirect "/#{datastore.slug}/record/:id"
end
get "/catalog" do
get "/#{datastore.slug}" do
if params.any?
@presenter = Search::Presenters.for_datastore_results(slug: datastore.slug, uri: full_uri, patron: @patron)
erb :"datastores/results/layout", layout: :layout do
Expand Down
1 change: 1 addition & 0 deletions lib/search/presenters/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ def self.for_datastore(datastore:, id:, size: "full")
end

require "search/presenters/record/catalog"
require "search/presenters/record/onlinejournals"
50 changes: 50 additions & 0 deletions lib/search/presenters/record/onlinejournals.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
require_relative "catalog"

module Search
module Presenters
module Record
module Onlinejournals
end
end
end
end

module Search
module Presenters
module Record
module Onlinejournals
class Base < Search::Presenters::Record::Catalog::Base
end

class Full < Search::Presenters::Record::Catalog::Full
def url
"#{S.base_url}/onlinejournals/record/#{id}"
end

def method_missing(method, *args, **kwargs, &block)
super unless respond_to_missing?(method)
S.logger.debug("#{method} not defined in Presenters::Record::Onlinejournals::Full")
nil
end

def shelf_browse
@shelf_browse ||= begin
result = nil
end
end
end

class Brief < Search::Presenters::Record::Catalog::Brief
METADATA_METHODS = [
:contributors,
:published,
:summary
]
end

class Field < Search::Presenters::Record::Catalog::Field
end
end
end
end
end
11 changes: 11 additions & 0 deletions lib/search/presenters/record/onlinejournals/email.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "search/presenters/record/catalog/email"

module Search::Presenters::Record::Onlinejournals
class Email < Search::Presenters::Record::Catalog::Email
METADATA_METHODS = [
:main_author,
:published,
:series
]
end
end
23 changes: 23 additions & 0 deletions lib/search/presenters/record/onlinejournals/email_holdings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require "search/presenters/record/catalog/email_holdings"

class Search::Presenters::Record::Onlinejournals::EmailHoldings < Search::Presenters::Record::Catalog::EmailHoldings
#
# <Description>
#
# @param [Search::Models::Record::Catalog] data is the catalog record model
#
def initialize(data)
@data = data
@holdings = Search::Presenters::Record::Onlinejournals::Holdings.new(@data)
end

private

def hathi_trust_list
if non_ht_search_only_item_count == 0
@holdings.hathi_trust
else
Search::Presenters::Record::Onlinejournals::Holdings::HathiTrustFullText.new(@data.holdings.hathi_trust)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "search/presenters/record/catalog/finding_aids_holding"
class Search::Presenters::Record::Onlinejournals::Holdings::FindingAids <
Search::Presenters::Record::Catalog::Holdings::FindingAids

class Item < Search::Presenters::Record::Catalog::Holdings::FindingAids::Item
def action
ItemCell::LinkTo.new(text: "Request from finding aid", url: @item.url)
end
end
end
4 changes: 4 additions & 0 deletions lib/search/presenters/record/onlinejournals/holdings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require "search/presenters/record/catalog/holdings"

class Search::Presenters::Record::Onlinejournals::Holdings < Search::Presenters::Record::Catalog::Holdings
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require "search/presenters/record/catalog/physical_holdings"

class Search::Presenters::Record::Onlinejournals::Holdings::PhysicalBase < Search::Presenters::Record::Catalog::Holdings::PhysicalBase
TableHeading = Search::Presenters::Record::Onlinejournals::Holdings::TableHeading
end

class Search::Presenters::Record::Onlinejournals::Holdings::ItemBase < Search::Presenters::Record::Catalog::Holdings::ItemBase
ItemCell = Search::Presenters::Record::Onlinejournals::Holdings::ItemCell
end

class Search::Presenters::Record::Onlinejournals::Holdings::Physical <
Search::Presenters::Record::Catalog::Holdings::Physical

class Item < Search::Presenters::Record::Catalog::Holdings::Physical::Item
end
end
24 changes: 22 additions & 2 deletions lib/search/presenters/results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ def active_filters
end

def filters
filter_order = self.class::FILTER_ORDER
all_filters.map do |group|
first = group.first
OpenStruct.new(uid: first.uid, name: first.group_name, options: group.reject { |x| x.active? })
end.select { |x| FILTER_ORDER.include?(x.uid) }.sort_by do |f|
FILTER_ORDER.index(f.uid)
end.select { |x| filter_order.include?(x.uid) }.sort_by do |f|
filter_order.index(f.uid)
end
end

Expand Down Expand Up @@ -107,3 +108,22 @@ def selected
end
end
end

class Search::Presenters::Results::Onlinejournals < Search::Presenters::Results::Catalog
FILTER_ORDER = [
"subject",
"language",
"place_of_publication",
"academic_discipline"
]

def boolean_filters
[]
end

def records
@results.records.map do |record|
Search::Presenters::Record::Onlinejournals::Brief.new(record)
end
end
end
1 change: 1 addition & 0 deletions lib/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
S.register(:base_url) { ENV["BASE_URL"] || "http://localhost:4567" }

S.register(:catalog_api_url) { ENV["CATALOG_API_URL"] || "http://catalog-api:8000" }
S.register(:onlinejournals_api_url) { ENV["CATALOG_API_URL"] || "http://catalog-api:8000" }

S.register(:catalog_browse_url) { ENV["CATALOG_BROWSE_URL"] || "https://search.lib.umich.edu/catalog/browse" }

Expand Down
Loading