Commit 63a4427f authored by Élodie Thiéblin's avatar Élodie Thiéblin
Browse files

[BlogPost] Move Blog schema in blogpostschema.ts

parent 388a7364ce28
......@@ -28,7 +28,9 @@ import {
rdfEntities
} from "@logilab/libview";
import * as $rdf from "rdflib";
import { ONTOLOGY } from "../common/schema";
import { BlogPostComponent } from "./BlogPostView";
import { loadBlogPost } from "./blogpostschema";
/**
* The descriptor for the default blog post view
......@@ -92,11 +94,12 @@ class BlogPostRendering implements implementation.ViewImplementation {
target: application.Resource
): implementation.ViewRendering {
let blogpost = loadBlogPost(renderer, context, target);
let externals = [application.cloneResource(blogpost.container.__resource)];
let result = document.createElement("div");
ReactDOM.render(<BlogPostComponent blogpost={blogpost} />, result);
return {
suggestedResources: []
dom: result,
suggestedResources: externals
};
}
}
......
import { rdfMeta, application } from "@logilab/libview";
import { ONTOLOGY } from "../common/schema";
import { DCE_METACLASS, DublinCoreElement } from "../dublincore/dcschema";
/**
* The data for a blog
*/
export interface Weblog extends DublinCoreElement {
containerOf: BlogPost[];
}
/**
* The data for a blog post
*/
export interface BlogPost extends DublinCoreElement {
modified: string;
container: Weblog;
}
/**
* The metaclass for BlogPost
*/
export const WEBLOG_METACLASS = new rdfMeta.MetaClass();
/**
* The metaclass for BlogPost
*/
export const BLOGPOST_METACLASS = new rdfMeta.MetaClass();
WEBLOG_METACLASS.properties = DCE_METACLASS.properties.concat([
new rdfMeta.MetaPropertyObject(
"containerOf",
"http://rdfs.org/sioc/ns#container",
BLOGPOST_METACLASS,
true
)
]);
BLOGPOST_METACLASS.properties = DCE_METACLASS.properties.concat([
new rdfMeta.MetaPropertyData("modified", "http://purl.org/dc/terms/modified"),
new rdfMeta.MetaPropertyObject(
"container",
"http://rdfs.org/sioc/ns#container",
WEBLOG_METACLASS
)
]);
/**
* Loads the data for the entity of interest
* @param renderer The current renderer
* @param context The current rendering context
* @param target The current RDF entity to be rendered
*/
export function loadBlogPost(
renderer: application.ViewRenderer,
context: application.RenderingContext,
target: application.Resource
): BlogPost {
return rdfMeta.loadEntity(
renderer,
context,
ONTOLOGY,
BLOGPOST_METACLASS,
target
);
}
......@@ -30,28 +30,6 @@ export const ONTOLOGY: rdfMeta.Ontology = {
inverses: INVERSES
};
/**
* The data for a blog
*/
export interface Weblog extends rdfMeta.Loadable {
description: string;
title: string;
containerOf: BlogPost[];
hasCreator: Person;
}
/**
* The data for a blog post
*/
export interface BlogPost extends rdfMeta.Loadable {
date: string;
modified: string;
title: string;
container: Weblog;
content: string;
hasCreator: Person;
}
/**
* The data for a person
*/
......@@ -133,13 +111,13 @@ export interface Talk extends rdfMeta.Loadable {
/**
* The metaclass for simple links
*/
const LINK_METACLASS = new rdfMeta.MetaClass();
export const LINK_METACLASS = new rdfMeta.MetaClass();
LINK_METACLASS.probeEntity = true;
/**
* The metaclass for Person
*/
const PERSON_METACLASS = new rdfMeta.MetaClass();
export const PERSON_METACLASS = new rdfMeta.MetaClass();
/**
* The metaclass for an ical date
......@@ -166,25 +144,6 @@ const TALK_METACLASS = new rdfMeta.MetaClass();
*/
const BOOK_METACLASS = new rdfMeta.MetaClass();
const BLOGPOST_METACLASS = new rdfMeta.MetaClass();
BLOGPOST_METACLASS.properties = [
new rdfMeta.MetaPropertyData("date", "http://purl.org/dc/terms/date"),
new rdfMeta.MetaPropertyData("modified", "http://purl.org/dc/terms/modified"),
new rdfMeta.MetaPropertyData("title", "http://purl.org/dc/terms/title"),
new rdfMeta.MetaPropertyData("content", "http://rdfs.org/sioc/types#content"),
new rdfMeta.MetaPropertyObject(
"hasCreator",
"http://rdfs.org/sioc/types#has_creator",
PERSON_METACLASS
),
new rdfMeta.MetaPropertyObject(
"container",
"http://rdfs.org/sioc/types#container",
LINK_METACLASS
)
];
PERSON_METACLASS.properties = [
new rdfMeta.MetaPropertyData("title", "http://xmlns.com/foaf/0.1/title"),
new rdfMeta.MetaPropertyData("gender", "http://xmlns.com/foaf/0.1/gender"),
......@@ -378,26 +337,6 @@ TALK_METACLASS.properties = [
)
];
/**
* Loads the data for the entity of interest
* @param renderer The current renderer
* @param context The current rendering context
* @param target The current RDF entity to be rendered
*/
export function loadBlogPost(
renderer: application.ViewRenderer,
context: application.RenderingContext,
target: application.Resource
): BlogPost {
return rdfMeta.loadEntity(
renderer,
context,
ONTOLOGY,
BLOGPOST_METACLASS,
target
);
}
/**
* Loads the data for the entity of interest
* @param renderer The current renderer
......
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