Skip to content

Commit

Permalink
remove custom content negotiation
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 11, 2020
1 parent 6749c62 commit 4cb93a1
Show file tree
Hide file tree
Showing 110 changed files with 2,201 additions and 7,251 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ gem "oj_mimic_json", "~> 1.0", ">= 1.0.1"
gem "equivalent-xml", "~> 0.6.0"
gem "nokogiri", ">= 1.10.8"
gem "iso8601", "~> 0.9.0"
gem "maremma", "4.6.1"
gem "faraday", "0.17.0"
gem "maremma", "~> 4.7.1"
gem "faraday", "~> 0.17.3"
gem "bolognese", "~> 1.0", ">= 1.6.6"
gem "dalli", "~> 2.7.6"
gem "lograge", "~> 0.11.2"
Expand Down
36 changes: 18 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ GEM
latex-decode (~> 0.0)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
bolognese (1.6.7)
bolognese (1.6.12)
activesupport (>= 4.2.5)
benchmark_methods (~> 0.7)
bibtex-ruby (>= 5.1.0)
Expand All @@ -65,13 +65,13 @@ GEM
concurrent-ruby (~> 1.1, >= 1.1.5)
csl-styles (~> 1.0, >= 1.0.1.8)
edtf (~> 3.0, >= 3.0.4)
faraday (= 0.17.0)
faraday (~> 0.17.3)
gender_detector (~> 0.1.2)
iso8601 (~> 0.9.1)
json-ld (~> 3.1, >= 3.1.4)
jsonlint (~> 0.3.0)
loofah (~> 2.0, >= 2.0.3)
maremma (>= 4.3, < 5)
maremma (>= 4.7, < 5)
namae (~> 1.0)
nokogiri (~> 1.10.4)
oj (~> 3.10)
Expand Down Expand Up @@ -106,7 +106,7 @@ GEM
csl (~> 1.0)
dalli (2.7.10)
debug_inspector (0.0.3)
diff-lcs (1.4.2)
diff-lcs (1.4.4)
docile (1.3.2)
dotenv (2.7.5)
ebnf (1.2.0)
Expand All @@ -118,11 +118,11 @@ GEM
nokogiri (>= 1.4.3)
erubi (1.9.0)
excon (0.71.1)
faraday (0.17.0)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
faraday-encoding (0.0.5)
faraday
faraday_middleware (0.13.1)
faraday_middleware (0.14.0)
faraday (>= 0.7.4, < 1.0)
ffi (1.13.1)
gender_detector (0.1.2)
Expand All @@ -142,7 +142,7 @@ GEM
concurrent-ruby (~> 1.0)
iso8601 (0.9.1)
jaro_winkler (1.5.4)
json (2.3.0)
json (2.3.1)
json-canonicalization (0.2.0)
json-ld (3.1.4)
htmlentities (~> 4.3)
Expand Down Expand Up @@ -174,14 +174,14 @@ GEM
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
maremma (4.6.1)
maremma (4.7.1)
activesupport (>= 4.2.5)
addressable (>= 2.3.6)
builder (~> 3.2, >= 3.2.2)
excon (~> 0.71.0)
faraday (= 0.17.0)
faraday (~> 0.17.3)
faraday-encoding (~> 0.0.4)
faraday_middleware (~> 0.13.1)
faraday_middleware (~> 0.14.0)
nokogiri (~> 1.10.4)
oj (>= 2.8.3)
oj_mimic_json (~> 1.0, >= 1.0.1)
Expand All @@ -190,11 +190,11 @@ GEM
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
multi_json (1.14.1)
multi_json (1.15.0)
multipart-post (2.1.1)
namae (1.0.1)
nio4r (2.5.2)
nokogiri (1.10.9)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
oj (3.10.6)
oj_mimic_json (1.0.1)
Expand Down Expand Up @@ -242,12 +242,12 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
rchardet (1.8.0)
rdf (3.1.3)
rdf (3.1.4)
hamster (~> 3.0)
link_header (~> 0.0, >= 0.0.8)
rdf-aggregate-repo (3.1.0)
rdf (~> 3.1)
rdf-rdfa (3.1.1)
rdf-rdfa (3.1.2)
haml (~> 5.1)
htmlentities (~> 4.3)
rdf (~> 3.1, >= 3.1.2)
Expand All @@ -262,7 +262,7 @@ GEM
rdf-turtle (3.1.1)
ebnf (~> 1.2)
rdf (~> 3.1, >= 3.1.2)
rdf-vocab (3.1.5)
rdf-vocab (3.1.7)
rdf (~> 3.1, >= 3.1.2)
rdf-xsd (3.1.0)
rdf (~> 3.1)
Expand Down Expand Up @@ -334,7 +334,7 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.7.2)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
Expand All @@ -351,15 +351,15 @@ DEPENDENCIES
dalli (~> 2.7.6)
dotenv
equivalent-xml (~> 0.6.0)
faraday (= 0.17.0)
faraday (~> 0.17.3)
gender_detector (~> 0.1.2)
git (~> 1.5)
iso8601 (~> 0.9.0)
listen (~> 3.0.5)
lograge (~> 0.11.2)
logstash-event (~> 1.2, >= 1.2.02)
logstash-logger (~> 0.26.1)
maremma (= 4.6.1)
maremma (~> 4.7.1)
nokogiri (>= 1.10.8)
oj (>= 3.1.0)
oj_mimic_json (~> 1.0, >= 1.0.1)
Expand Down
13 changes: 0 additions & 13 deletions app/controllers/concerns/helpable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ def get_handle_url(id: nil)
response.headers["location"]
end

# content-types registered for that DOI
def get_registered_content_types(id)
doi = doi_from_url(id)
url = "#{ENV['API_URL']}/dois/#{doi}"
response = Maremma.get url
Array.wrap(response.body.fetch("included", nil)).select { |m| m["type"] == "media" }.reduce({}) do |sum, media|
content_type = media.dig("attributes", "mediaType")
url = media.dig("attributes", "url")
sum[content_type.strip] = url.strip if content_type.present? && url.present?
sum
end.to_h
end

def available_content_types
content_types = Mime::LOOKUP.map { |k, v| [k, v.to_sym] }.to_h
content_types.except("text/html", "application/xhtml+xml", "text/plain", "application/json", "text/x-json", "application/jsonrequest")
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/index_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def index

def show
url = "#{ENV['API_URL']}/dois/#{@doi}"
response = Maremma.get(url, accept: "application/vnd.datacite.datacite+json", raw: true, headers: { "Accept-Encoding"=> "gzip" })
response = Maremma.get(url, accept: "application/vnd.datacite.datacite+json", raw: true)

if response.status == 200
@metadata = Bolognese::Metadata.new(input: response.body.fetch("data", nil), from: "datacite_json")
Expand Down
Loading

0 comments on commit 4cb93a1

Please sign in to comment.