Commit 0ce519c0 authored by Élodie Thiéblin's avatar Élodie Thiéblin
Browse files

[DublinCore] Add dublincore view

parent 5b7671d560b9
import * as React from "react";
import { DublinCoreElement } from "./dcschema";
export const DublinCoreElementComponent: React.FC<{ title: string }> = ({
title
}) => <h1>{title}</h1>;
export const DublinCoreElementComponent: React.FC<{
dcelement: DublinCoreElement;
}> = ({ dcelement }) => (
<>
<h1>{dcelement.title}</h1>
<div>{dcelement.creator}</div>
<div>{dcelement.date}</div>
<div>{dcelement.description}</div>
</>
);
<template>
<div>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1>
{{blogpost.title}}
</h1>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
props: ["context", "blogpost"]
};
</script>
......@@ -21,13 +21,16 @@
import * as React from "react";
import * as ReactDOM from "react-dom";
import { application, definition, implementation } from "@logilab/libview";
import {
application,
definition,
implementation,
rdfEntities
} from "@logilab/libview";
import * as $rdf from "rdflib";
import { DublinCoreElementComponent } from "./DublinCoreImpl";
import {
loadDublinCoreElement,
DublinCoreElement
} from "../common/schema";
import { ONTOLOGY } from "../common/schema";
import { loadDublinCoreElement } from "./dcschema";
/**
* The descriptor for the default blog post view
......@@ -60,25 +63,18 @@ class DCElementRendering implements implementation.ViewImplementation {
}
priorityFor(store: $rdf.Formula, target: application.Resource): number {
const DC = $rdf.Namespace("http://purl.org/dc/elements/1.1/");
const DCTERMS = $rdf.Namespace("http://purl.org/dc/terms/1.1/");
const dcTitleStatements = store.any(
target.uri,
DC("title"),
undefined,
undefined
);
const dcTermsTitleStatements = store.any(
target.uri,
DCTERMS("title"),
undefined,
undefined
let repo = new rdfEntities.RdfEntityStore(
store,
ONTOLOGY.aliases,
ONTOLOGY.inverses
);
console.log(dcTitleStatements);
if (dcTitleStatements !== null || dcTermsTitleStatements !== null) {
return 11;
const entity = repo.entityForUri(target.uri);
const dctitles = entity.getValuesForS("http://purl.org/dc/terms/title");
if (dctitles.length !== 0) {
return 10;
}
return implementation.VIEW_PRIORITY_INAPPROPRIATE;
}
......@@ -89,9 +85,12 @@ class DCElementRendering implements implementation.ViewImplementation {
target: application.Resource
): implementation.ViewRendering {
let dcelement = loadDublinCoreElement(renderer, context, target);
console.log(dcelement);
let result = document.createElement("div");
console.log("TARGET : ", target, context, renderer);
ReactDOM.render(<DublinCoreElementComponent title={"toto"} />, result);
ReactDOM.render(
<DublinCoreElementComponent dcelement={dcelement} />,
result
);
return {
dom: result,
suggestedResources: []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment