-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add map service Add route and controller for maps Add service controller to refactor the rest of the controllers Co-authored-by: Jane Sandberg <[email protected]>
- Loading branch information
1 parent
fe0b560
commit 19cb275
Showing
14 changed files
with
294 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,4 @@ | |
/config/master.key | ||
|
||
.byebug_history | ||
solr | ||
/solr/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class ArtMuseumController < ApplicationController | ||
class ArtMuseumController < ServiceController | ||
rescue_from ActionController::ParameterMissing, with: :show_query_errors | ||
def show | ||
@art_museum_query = ArtMuseum.new(query_terms: query_params) | ||
|
||
render json: art_museum_query.our_response | ||
def initialize | ||
super | ||
@service = ArtMuseum | ||
end | ||
|
||
private | ||
|
||
def query_params | ||
params.require(:query) | ||
end | ||
|
||
def show_query_errors(exception) | ||
render json: { error: exception.message }, status: :bad_request | ||
end | ||
|
||
attr_reader :art_museum_query | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class CatalogController < ApplicationController | ||
class CatalogController < ServiceController | ||
rescue_from ActionController::ParameterMissing, with: :show_query_errors | ||
def show | ||
@catalog_query = Catalog.new(query_terms: query_params) | ||
|
||
render json: catalog_query.our_response | ||
def initialize | ||
super | ||
@service = Catalog | ||
end | ||
|
||
private | ||
|
||
def query_params | ||
params.require(:query) | ||
end | ||
|
||
def show_query_errors(exception) | ||
render json: { error: exception.message }, status: :bad_request | ||
end | ||
|
||
attr_reader :catalog_query | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class DpulController < ApplicationController | ||
class DpulController < ServiceController | ||
rescue_from ActionController::ParameterMissing, with: :show_query_errors | ||
def show | ||
@dpul_query = Dpul.new(query_terms: query_params) | ||
|
||
render json: dpul_query.our_response | ||
def initialize | ||
super | ||
@service = Dpul | ||
end | ||
|
||
private | ||
|
||
def query_params | ||
params.require(:query) | ||
end | ||
|
||
def show_query_errors(exception) | ||
render json: { error: exception.message }, status: :bad_request | ||
end | ||
|
||
attr_reader :dpul_query | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class FindingaidsController < ApplicationController | ||
class FindingaidsController < ServiceController | ||
rescue_from ActionController::ParameterMissing, with: :show_query_errors | ||
def show | ||
@findingaids_query = Findingaids.new(query_terms: query_params) | ||
|
||
render json: findingaids_query.our_response | ||
def initialize | ||
super | ||
@service = Findingaids | ||
end | ||
|
||
private | ||
|
||
def query_params | ||
params.require(:query) | ||
end | ||
|
||
def show_query_errors(exception) | ||
render json: { error: exception.message }, status: :bad_request | ||
end | ||
|
||
attr_reader :findingaids_query | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class PulmapController < ServiceController | ||
rescue_from ActionController::ParameterMissing, with: :show_query_errors | ||
|
||
def initialize | ||
super | ||
@service = Pulmap | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class ServiceController < ApplicationController | ||
def show | ||
@query = service.new(query_terms: query_params) | ||
|
||
render json: query.our_response | ||
end | ||
|
||
private | ||
|
||
attr_reader :query, :service | ||
|
||
def query_params | ||
params.require(:query) | ||
end | ||
|
||
def show_query_errors(exception) | ||
render json: { error: exception.message }, status: :bad_request | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
# This class is responsible for querying Findingaids (aka PULFAlight) | ||
class Pulmap | ||
include ActiveModel::API | ||
include Parsed | ||
include Solr | ||
attr_reader :query_terms, :service, :service_response | ||
|
||
def initialize(query_terms:) | ||
@query_terms = query_terms | ||
@service = 'pulmap' | ||
@service_response = solr_service_response(query_terms:) | ||
end | ||
|
||
def solr_collection | ||
'pulmap' | ||
end | ||
|
||
def solr_fields | ||
%w[uuid dc_title_s dc_creator_sm dc_publisher_s dc_format_s dc_description_s dc_rights_s layer_geom_type_s] | ||
end | ||
|
||
def solr_sort | ||
'score desc' | ||
end | ||
|
||
def more_link | ||
@service = 'maps' | ||
super | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
# This class is responsible for getting relevant | ||
# metadata from Pulmap's JSON | ||
class PulmapDocument < Document | ||
private | ||
|
||
def id | ||
json[:uuid] | ||
end | ||
|
||
def url | ||
"https://maps.princeton.edu/catalog/#{id}" | ||
end | ||
|
||
def title | ||
json[:dc_title_s] | ||
end | ||
|
||
def creator | ||
json[:dc_creator_sm]&.first | ||
end | ||
|
||
def publisher | ||
json[:dc_publisher_s] | ||
end | ||
|
||
def type | ||
json[:dc_format_s] | ||
end | ||
|
||
def description | ||
json[:dc_description_s] | ||
end | ||
|
||
def doc_keys | ||
[:rights, :layer_geom_type] | ||
end | ||
|
||
def rights | ||
json[:dc_rights_s] | ||
end | ||
|
||
def layer_geom_type | ||
json[:layer_geom_type_s] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"responseHeader":{ | ||
"zkConnected":true, | ||
"status":0, | ||
"QTime":0, | ||
"params":{ | ||
"ps":"0", | ||
"indent":"2", | ||
"echoParams":"all", | ||
"fl":"uuid,dc_title_s,dc_creator_sm,dc_publisher_s,dc_format_s,dc_description_s,dc_rights_s,layer_geom_type_s", | ||
"publisher_qf":"\n dc_publisher_ti^5\n dc_creator_tmi\n ", | ||
"subject_qf":"\n dc_subject_tmi\n dct_spatial_tmi\n ", | ||
"_forwardedCount":"1", | ||
"tie":"0.01", | ||
"defType":"edismax", | ||
"qf":"\n text^1\n dc_description_ti^2\n dc_creator_tmi^3\n dc_publisher_ti^3\n dct_isPartOf_tmi^4\n dc_subject_tmi^5\n dct_spatial_tmi^5\n dct_temporal_tmi^5\n dc_title_ti^6\n dc_rights_ti^7\n dct_provenance_ti^8\n layer_geom_type_ti^9\n layer_slug_ti^10\n dc_identifier_ti^10\n ", | ||
"title_qf":"\n dc_title_ti^10\n dct_isPartOf_tmi\n ", | ||
"wt":"json", | ||
"mm":"1<-1 3<50% 6<90%", | ||
"qs":"1", | ||
"q.alt":"*:*", | ||
"facet.field":["dct_isPartOf_sm", | ||
"dct_provenance_s", | ||
"dct_spatial_sm", | ||
"dc_creator_sm", | ||
"dc_format_s", | ||
"dc_language_s", | ||
"dc_publisher_s", | ||
"dc_rights_s", | ||
"dc_subject_sm", | ||
"layer_geom_type_s", | ||
"solr_year_i"], | ||
"publisher_pf":"\n dc_publisher_ti^5\n dc_creator_tmi\n ", | ||
"subject_pf":"\n dc_subject_tmi\n dct_spatial_tmi\n ", | ||
"start":"0", | ||
"sort":"score desc", | ||
"rows":"3", | ||
"q":"scribner", | ||
"facet.limit":"10", | ||
"spellcheck":"true", | ||
"pf":"\n text^1\n dc_description_ti^2\n dc_creator_tmi^3\n dc_publisher_ti^3\n dct_isPartOf_tmi^4\n dc_subject_tmi^5\n dct_spatial_tmi^5\n dct_temporal_tmi^5\n dc_title_ti^6\n dc_rights_ti^7\n dct_provenance_ti^8\n layer_geom_type_ti^9\n layer_slug_ti^10\n dc_identifier_ti^10\n ", | ||
"title_pf":"\n dc_title_ti^10\n dct_isPartOf_tmi\n ", | ||
"facet.mincount":"1", | ||
"facet":"false"}}, | ||
"response":{"numFound":16,"start":0,"docs":[ | ||
{ | ||
"dc_rights_s":"Public", | ||
"dc_title_s":"Indiana.", | ||
"dc_description_s":"Shows railroads and canals.; Compiled according to Census of 1880 and latest surveys.; From: Encyclopaedia Britannica, 9th ed. Vol. XII, plate VII. Scale approximately 1:2,000,000", | ||
"dc_format_s":"JPEG", | ||
"dc_publisher_s":"Scribner"}, | ||
{ | ||
"uuid":"princeton-6682x6396", | ||
"dc_title_s":"South America : wall-atlas", | ||
"dc_rights_s":"Public", | ||
"dc_description_s":"\"Card series.\" Relief shown by hachures and form lines. \"Entered according to Act of Congress in the year 1865 by Charles Scribner & Co. ...\" Inset: Profiles from west to east. Wall map. Scribner, Armstrong, & Co. flourished ca. 1871-1879. cf. Tooley's dictionary of mapmakers.", | ||
"dc_creator_sm":["Guyot, A. (Arnold), 1807-1884"], | ||
"dc_publisher_s":"New York : Published by Scribner, Armstrong & Co. ... [between 1871 and 1879].", | ||
"layer_geom_type_s":"Image", | ||
"dc_format_s":"TIFF"}, | ||
{ | ||
"uuid":"princeton-2b88qf00b", | ||
"dc_title_s":"Africa : wall-atlas", | ||
"dc_rights_s":"Public", | ||
"dc_description_s":"\"Card series.\" Relief shown by hachures and form lines. \"Entered according to Act of Congress in the year 1865 by Charles Scribner & Co. ...\" Insets: Profiles from north to south -- Profiles from east to west. Wall map. Scribner, Armstrong, & Co. flourished ca. 1871-1879. cf. Tooley's dictionary of mapmakers.", | ||
"dc_creator_sm":["Guyot, A. (Arnold), 1807-1884"], | ||
"dc_publisher_s":"New York : Scribner, Armstrong, & Co. [between 1871 and 1879].", | ||
"layer_geom_type_s":"Image", | ||
"dc_format_s":"TIFF"}] | ||
}, | ||
"spellcheck":{ | ||
"suggestions":[]}} |
Oops, something went wrong.