Skip to content

Commit

Permalink
When retrieving schema_org data via URL, pass Host header, required b…
Browse files Browse the repository at this point in the history
…y some servers.
  • Loading branch information
richardhallett committed Jan 10, 2019
1 parent e1f4c1c commit e7beefd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/bolognese/readers/schema_org_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_schema_org(id: nil, **options)
return { "string" => nil, "state" => "not_found" } unless id.present?

id = normalize_id(id)
response = Maremma.get(id)
response = Maremma.get(id, host: true)
doc = Nokogiri::XML(response.body.fetch("data", nil), nil, 'UTF-8')

# workaround for xhtml documents
Expand Down Expand Up @@ -68,7 +68,7 @@ def read_schema_org(string: nil, **options)
ct = (schema_org == "Dataset") ? "includedInDataCatalog" : "Periodical"
container = if meta.fetch(ct, nil).present?
url = parse_attributes(from_schema_org(meta.fetch(ct, nil)), content: "url", first: true)

{
"type" => (schema_org == "Dataset") ? "DataRepository" : "Periodical",
"title" => parse_attributes(from_schema_org(meta.fetch(ct, nil)), content: "name", first: true),
Expand Down Expand Up @@ -114,7 +114,7 @@ def read_schema_org(string: nil, **options)
dates << { "date" => meta.fetch("dateCreated"), "dateType" => "Created" } if meta.fetch("dateCreated", nil).present?
dates << { "date" => meta.fetch("dateModified"), "dateType" => "Updated" } if meta.fetch("dateModified", nil).present?
publication_year = meta.fetch("datePublished")[0..3] if meta.fetch("datePublished", nil).present?

state = meta.present? || read_options.present? ? "findable" : "not_found"
geo_locations = Array.wrap(meta.fetch("spatialCoverage", nil)).map do |gl|
if gl.dig("geo", "box")
Expand Down

0 comments on commit e7beefd

Please sign in to comment.