Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
feat: serve ontology as resource
Browse files Browse the repository at this point in the history
  • Loading branch information
vhf committed Oct 28, 2019
1 parent 4415aed commit 1952d00
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 40 deletions.
28 changes: 28 additions & 0 deletions components/admin/AdminConfigForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,31 @@
</div>
</div>

<h2 class="subtitle">2.3. Resources Location</h2>
<p></p>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Ontology Resource Location</label>
</div>
<div class="field-body">
<div class="field">
<p class="control is-expanded">
<input
:disabled="disabled"
class="input"
v-model="ontology.ontologyResourceUrl"
type="text"
required>
</p>
<p class="help">
The ontology will be accessible at <code>{{ ontologyResourceUrl }}</code>
by either specifying the format: <code>{{ ontologyResourceUrl }}?format=ttl</code>
or using content negotiation.
</p>
</div>
</div>
</div>

<div style="display: none">
<hr>

Expand Down Expand Up @@ -527,6 +552,9 @@ export default {
}
},
computed: {
ontologyResourceUrl () {
return `${this.ontology.datasetBaseUrl}${(this.ontology.ontologyResourceUrl).replace(new RegExp('^/', 'g'), '')}`
}
},
watch: {
config () {
Expand Down
65 changes: 39 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"@nuxtjs/feed": "^1.1.0",
"@nuxtjs/sentry": "^2.3.1",
"@nuxtjs/toast": "^3.0.2",
"@octokit/rest": "^16.16.0",
"@octokit/rest": "^16.16.2",
"@rdfjs/serializer-jsonld": "^1.2.0",
"@rdfjs/serializer-ntriples": "^1.0.1",
"@rdfjs/to-ntriples": "^1.0.1",
"apicache": "^1.4.0",
"apollo-cache-inmemory": "^1.4.3",
"apollo-client": "^2.4.13",
"apollo-cache-inmemory": "^1.5.0",
"apollo-client": "^2.5.0",
"apollo-link": "^1.2.8",
"apollo-link-http": "^1.5.11",
"babel-plugin-dynamic-import-node": "^2.2.0",
Expand Down
31 changes: 20 additions & 11 deletions trifid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ app.use(async function (req, res, next) {

if (!middleware) {
debug('new middleware')
const { ontology: ontologyConfig } = await fetchConfig()
middleware = await trifidMiddleware(ontologyConfig)
const config = await fetchConfig()
middleware = await trifidMiddleware(config)
}
else {
debug('cached middleware')
Expand All @@ -45,20 +45,20 @@ export default {
handler: app
}

async function trifidMiddleware (ontologyConfig) {
async function trifidMiddleware (config) {
const trifid = new Trifid()
const config = {
const trifidConfig = {
baseConfig: `${join(__dirname, 'trifid.config-base.json')}`,
datasetBaseUrl: ontologyConfig.datasetBaseUrl,
classBaseUrl: ontologyConfig.classBaseUrl,
propertyBaseUrl: ontologyConfig.propertyBaseUrl,
containersNestingPredicate: ontologyConfig.containersNestingPredicate,
datasetBaseUrl: config.ontology.datasetBaseUrl,
classBaseUrl: config.ontology.classBaseUrl,
propertyBaseUrl: config.ontology.propertyBaseUrl,
containersNestingPredicate: config.ontology.containersNestingPredicate,
handler: {
structure: {
module: 'trifid-handler-fetch',
priority: 100,
options: {
url: ontologyConfig.structureRawUrl,
url: config.ontology.structureRawUrl,
contentType: 'application/n-triples',
split: true
}
Expand All @@ -67,15 +67,24 @@ async function trifidMiddleware (ontologyConfig) {
module: 'trifid-handler-fetch',
priority: 101,
options: {
url: ontologyConfig.ontologyRawUrl,
url: config.ontology.ontologyRawUrl,
contentType: 'application/n-triples',
split: true
}
},
ontologyResource: {
module: 'trifid-handler-fetch',
priority: 10,
options: {
url: config.ontology.ontologyRawUrl,
contentType: 'application/n-triples',
resource: `${config.ontology.datasetBaseUrl}${config.ontology.ontologyResourceUrl.replace(new RegExp('^/', 'g'), '') || ''}`
}
}
}
}

await trifid.init(config)
await trifid.init(trifidConfig)

return trifid.middleware()
}

0 comments on commit 1952d00

Please sign in to comment.