Skip to content

Commit

Permalink
Merge pull request #106 from crosscite/disable_nondc
Browse files Browse the repository at this point in the history
Remove support for non DC
  • Loading branch information
richardhallett authored Feb 8, 2022
2 parents 8834f2c + 0b52f73 commit 2f0af6e
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions app/controllers/index_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,10 @@ def show
if response.status == 200
@metadata = Bolognese::Metadata.new(input: response.body.fetch("data", nil), from: "datacite_json")
else
url = "https://api.crossref.org/works/#{@doi}/transform/application/[email protected]"
response = Maremma.get(url, accept: "text/xml", raw: true, timeout: 2)

if response.status == 200
string = response.body.fetch("data", nil)
string = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks).to_s if string.present?
@metadata = Bolognese::Metadata.new(input: string, from: "crossref")
else
ra = get_doi_ra(@doi)

if %w(mEDRA JaLC).include?(ra)
# we fetch the Citeproc JSON from DOI content negotiation for the other RAs that support this
url = "https://doi.org/#{@doi}"
response = Maremma.get(url, accept: "application/vnd.citationstyles.csl+json", raw: true)
fail AbstractController::ActionNotFound if response.status != 200

string = response.body.fetch("data", nil)
@metadata = Bolognese::Metadata.new(input: string, from: "citeproc")
else
fail AbstractController::ActionNotFound
end
end
# Non DataCite DOIs i.e. crossref are not supported.
# Requests should go via doi.org to be redirected to the appropriate RA
# content negotiation service
fail AbstractController::ActionNotFound
end

fail AbstractController::ActionNotFound unless @metadata.exists?
Expand Down

0 comments on commit 2f0af6e

Please sign in to comment.