Skip to content

Added release context to series jsonld #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: dluhc-integration
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion consumer-wireframes/_includes/dataset-series.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ <h2 class="pt-5">About this dataset</h2>
});

populatePage = data => {
console.log(data)
const humanReadableDate = new Date(data["dcterms:modified"]).toLocaleString('en-GB', {
day: 'numeric',
month: 'long',
Expand Down Expand Up @@ -199,7 +200,6 @@ <h2 class="pt-5">About this dataset</h2>
});

populateReleases = data => {
console.log(data)
let contents = data.contents
let list = document.getElementById("releases")
if (contents.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
(matcha/index-triples)
(triples->ld-resource))]
(as-json-ld {:status 200
:body (-> (json-ld/compact series (json-ld/context system-uris))
:body (-> (json-ld/compact series (json-ld/context system-uris series-slug))
(.toString))})
(errors/not-found-response request)))

Expand Down
13 changes: 10 additions & 3 deletions datahost-ld-openapi/src/tpximpact/datahost/ldapi/json_ld.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
(com.apicatalog.jsonld.document JsonDocument)
(java.io StringReader)))

(defn context [system-uris]
(defn context
([system-uris]
;; Serve the context file with an application/json header from jsdelvir (free CDN)
;; See here for instructions: https://www.jsdelivr.com/?docs=gh
;;
Expand All @@ -14,8 +15,14 @@
;; the file has the correct header.
;;
;; NOTE: This should be updated to track the dluhc-integration branch
["https://cdn.jsdelivr.net/gh/Swirrl/datahost-prototypes@1282114/datahost-ld-openapi/resources/jsonld-context.json"
{"@base" (su/rdf-base-uri system-uris)}])
["https://cdn.jsdelivr.net/gh/Swirrl/datahost-prototypes@1282114/datahost-ld-openapi/resources/jsonld-context.json"
{"@base" (su/rdf-base-uri system-uris)}]
)
([system-uris series-slug]
["https://cdn.jsdelivr.net/gh/Swirrl/datahost-prototypes@1282114/datahost-ld-openapi/resources/jsonld-context.json"
{"@base" (su/rdf-base-uri system-uris)
"@dh:hasRelease" {"@context" {"@base" (su/release-uri-base system-uris series-slug)}}}])
)

(defn ->json-document
^JsonDocument [edn]
Expand Down
5 changes: 5 additions & 0 deletions datahost-ld-openapi/src/tpximpact/datahost/system_uris.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

(dataset-series-uri* [this api-params])

(release-uri-base [this series-slug])

(dataset-release-uri [this ^URI series-uri release-slug])

(dataset-release-uri* [this api-params])
Expand Down Expand Up @@ -65,6 +67,9 @@
(dataset-series-uri* [this {:keys [series-slug] :as _api-params}]
(dataset-series-uri this series-slug))

(release-uri-base [_ series-slug]
(str "/data/" series-slug "/release/"))

(dataset-release-uri [_ series-uri release-slug]
(URI. (format "%s/release/%s" series-uri release-slug)))

Expand Down