-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
321 additions
and
108 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { PrezProperty, PrezTerm } from "prez-lib"; | ||
const fields = [ | ||
'http://purl.org/dc/terms/title', | ||
'http://purl.org/dc/terms/identifier', | ||
// 'http://www.w3.org/ns/dcat#Resource', | ||
'https://www.opengis.net/def/metamodel/ogc-na/doctype', | ||
'http://purl.org/dc/terms/creator', | ||
'http://purl.org/dc/terms/created', | ||
] as const; | ||
|
||
export type CitationFields = typeof fields[number]; | ||
|
||
export type CitationProperties = Partial<Record<CitationFields, PrezProperty>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts" setup> | ||
import { PrezProperty, PrezLiteral, PrezNode } from 'prez-lib'; | ||
import type { CitationProperties } from './CustomCitation' | ||
defineProps<{focusNode: PrezNode, properties: CitationProperties}>(); | ||
const propertyValue = (property:PrezProperty|undefined, dataType?:string) => | ||
property?.objects?.filter(obj => !dataType || (obj.termType == "Literal" && dataType == (obj as PrezLiteral).datatype?.value)) | ||
.map(obj => obj.value).join(', ') || ""; | ||
const firstTruthy = (...args: any[]): any => args.find(Boolean); | ||
</script> | ||
|
||
<template> | ||
|
||
<div v-if="propertyValue(properties['http://purl.org/dc/terms/identifier'], 'http://www.opengis.net/def/metamodel/ogc-na/doc_no')"> | ||
Open Geospatial Consortium, | ||
<em>{{ propertyValue(properties['http://purl.org/dc/terms/title']) }}</em> | ||
(<em>{{ propertyValue(properties['http://purl.org/dc/terms/identifier'], 'http://www.opengis.net/def/metamodel/ogc-na/doc_no') }}</em>) | ||
({{ propertyValue(properties['http://purl.org/dc/terms/created']) }}). | ||
OGC {{ propertyValue(properties['https://www.opengis.net/def/metamodel/ogc-na/doctype']) }}, | ||
Eds. {{ propertyValue(properties["http://purl.org/dc/terms/creator"]) }}. | ||
{{ firstTruthy( | ||
propertyValue(properties['http://purl.org/dc/terms/identifier'], 'http://example.com/datatypes/DOI'), | ||
focusNode?.value | ||
) }} | ||
</div> | ||
|
||
</template> | ||
<style scoped> | ||
div { | ||
float:right; | ||
width:400px; | ||
font-size:small; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script lang="ts" setup> | ||
import { PrezProperty, PrezLiteral, PrezNode, PrezProperties } from 'prez-lib'; | ||
defineProps<{focusNode: PrezNode, properties: PrezProperties}>(); | ||
const propertyValue = (property:PrezProperty|undefined, dataType?:string) => | ||
property?.objects?.filter(obj => !dataType || (obj.termType == "Literal" && dataType == (obj as PrezLiteral).datatype?.value)) | ||
.map(obj => obj.value).join(', ') || ""; | ||
</script> | ||
|
||
<template> | ||
|
||
<h1>Properties</h1> | ||
|
||
<div v-for="(value, key) in properties" :key="key"> | ||
<p v-if="value">{{ key }}: {{ propertyValue(value) }}</p> | ||
</div> | ||
|
||
Focus Node = {{ focusNode?.value }} | ||
|
||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import type { Meta, StoryObj } from "@storybook/vue3"; | ||
import CustomCitation from "../custom-components/CustomCitation.vue"; | ||
import type { CitationFields } from '../custom-components/CustomCitation' | ||
import { node, literal, PrezTerm } from "prez-lib"; | ||
import { setProperties } from "../util/helpers"; | ||
|
||
type CitationInputFields = Record<CitationFields, string|PrezTerm[]> | ||
|
||
//{ | ||
|
||
// title: { description: "Doc Title", value: "object"}, | ||
// docId: { description: "Doc Id", value: "string"}, | ||
// year: { description: "Year", value: "number"}, | ||
// docType: { description: "Doc Type", value: "string"}, | ||
// // 'https://www.opengis.net/def/metamodel/ogc-na/doctype': | ||
// // { description: "Doc Type", value: "string"}, | ||
// creatorNames: { description: "Creator Names", value: "string"}, | ||
// url: { description: "url", value: "string"}, | ||
// doi: { description: "doi", value: "string"}, | ||
//} | ||
|
||
const argTypeProps:Record<CitationFields, object> = { | ||
"http://purl.org/dc/terms/creator": { description: "Creator Names"}, | ||
"https://www.opengis.net/def/metamodel/ogc-na/doctype": { description: "Doc Type"}, | ||
"http://purl.org/dc/terms/created": { description: "Date created"}, | ||
"http://purl.org/dc/terms/identifier": { description: "Doc Identifier"}, | ||
"http://purl.org/dc/terms/title": { description: "Title" } | ||
}; | ||
|
||
const meta = { | ||
title: "CustomCitation", | ||
component: CustomCitation, | ||
tags: ["autodocs"], | ||
argTypes: { properties: argTypeProps, focusNode: { "description": "Focus Node URI"} } | ||
} satisfies Meta<typeof CustomCitation>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
// export const Default: Story = { | ||
// render: (args)=> ({ | ||
// components: { CustomCitation }, | ||
// setup() { | ||
// return {args} | ||
// }, | ||
// template: `<CustomCitation :properties="args"></CustomCitation>` | ||
// }), | ||
// args: { | ||
// properties: { | ||
// title: "Sensor Collection Service", | ||
// docId: "02-028", | ||
// year: 2002, | ||
// docType: "Interoperability Program Report", | ||
// creatorNames: "Tom McCarthy", | ||
// url: "http://www.opengis.net/def/docs/02-028", | ||
// } | ||
// } | ||
// }; | ||
|
||
export const WithoutDOI: Story = { | ||
args: { | ||
properties: setProperties( | ||
{ | ||
"http://purl.org/dc/terms/creator": "Tom McCarthy", | ||
"http://purl.org/dc/terms/created": "2002-04-19", | ||
"http://purl.org/dc/terms/identifier": [ | ||
literal({datatype: node('http://www.opengis.net/def/metamodel/ogc-na/doc_no'), value: "02-028"})], | ||
"http://purl.org/dc/terms/title": "Sensor Collection Service", | ||
"https://www.opengis.net/def/metamodel/ogc-na/doctype": "Interoperability Program Report" | ||
} as CitationInputFields | ||
), | ||
focusNode: node('http://www.opengis.net/def/docs/02-028') | ||
} | ||
}; | ||
|
||
export const WithDOI: Story = { | ||
args: { | ||
properties: setProperties( | ||
{ | ||
"http://purl.org/dc/terms/creator": "Tom McCarthy", | ||
"http://purl.org/dc/terms/created": "2002-04-19", | ||
"http://purl.org/dc/terms/identifier": [ | ||
literal({datatype: node('http://www.opengis.net/def/metamodel/ogc-na/doc_no'), value: "02-028"}), | ||
literal({datatype: node('http://example.com/datatypes/DOI'), value: 'https://doi.org/ogc-02-028'}) | ||
], | ||
"http://purl.org/dc/terms/title": "Sensor Collection Service", | ||
"https://www.opengis.net/def/metamodel/ogc-na/doctype": "Interoperability Program Report" | ||
} as CitationInputFields | ||
), | ||
focusNode: node('http://www.opengis.net/def/docs/02-028') | ||
} | ||
}; | ||
|
||
export const WithNoDocNo: Story = { | ||
args: { | ||
properties: setProperties( | ||
{ | ||
"http://purl.org/dc/terms/creator": "Tom McCarthy", | ||
"http://purl.org/dc/terms/created": "2002-04-19", | ||
"http://purl.org/dc/terms/identifier": [ | ||
literal({datatype: node('http://example.com/datatypes/DOI'), value: 'https://doi.org/ogc-02-028'}) | ||
], | ||
"http://purl.org/dc/terms/title": "Sensor Collection Service", | ||
"https://www.opengis.net/def/metamodel/ogc-na/doctype": "Interoperability Program Report" | ||
} as CitationInputFields | ||
), | ||
focusNode: node('http://www.opengis.net/def/docs/02-028') | ||
} | ||
}; | ||
|
||
|
||
// export const WithDOI: Story = { | ||
// args: { | ||
// title: "Sensor Collection Service", | ||
// docId: "02-028", | ||
// year: 2002, | ||
// docType: "Interoperability Program Report", | ||
// creatorNames: "Tom McCarthy", | ||
// url: "http://www.opengis.net/def/docs/02-028", | ||
// doi: "https://doi.org/ogc-00-029" | ||
// } | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters