Commit 390d2613 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Implementing the views for the conferences

parent 858d9c5522df
......@@ -117,7 +117,21 @@ export const ONTOLOGY: rdfMeta.Ontology = {
"http://dbpedia.org/ontology/publisher",
"http://purl.org/dc/elements/1.1/publisher"
],
["http://dbpedia.org/property/releaseDate"]
["http://dbpedia.org/property/releaseDate"],
["http://data.semanticweb.org/ns/swc/ontology#ConferenceEvent"],
["http://data.semanticweb.org/ns/swc/ontology#TrackEvent"],
["http://data.semanticweb.org/ns/swc/ontology#TalkEvent"],
["http://data.semanticweb.org/ns/swc/ontology#hasAcronym"],
["http://data.semanticweb.org/ns/swc/ontology#isSuperEventOf"],
["http://data.semanticweb.org/ns/swc/ontology#isPartOf"],
["http://data.semanticweb.org/ns/swc/ontology#abstract"],
["http://data.semanticweb.org/ns/swc/ontology#author"],
["http://data.semanticweb.org/ns/swc/ontology#hasRelatedDocument"],
["http://purl.org/dc/elements/1.1/title"],
["http://www.w3.org/2002/12/cal/ical#dtstart"],
["http://www.w3.org/2002/12/cal/ical#date"],
["http://www.w3.org/2002/12/cal/ical#dtend"],
["http://www.w3.org/2002/12/cal/ical#url"]
],
inverses: {
"http://dbpedia.org/ontology/influenced":
......@@ -166,6 +180,38 @@ export interface Book extends rdfMeta.Loadable {
releaseDate: string;
}
/**
* The data for a conference
*/
export interface Conference extends rdfMeta.Loadable {
title: string;
label: string;
acronym: string;
startDate: string;
endDate: string;
tracks: Track[];
}
/**
* The data for a track in a conference
*/
export interface Track extends rdfMeta.Loadable {
title: string;
conferences: Conference[];
talks: Talk[];
}
/**
* The data for a talk in a conference
*/
export interface Talk extends rdfMeta.Loadable {
title: string;
abstract: string;
authors: string[];
docs: string[];
trackOrConferences: (Track | Conference)[];
}
/**
* The metaclass for simple links
*/
......@@ -176,6 +222,21 @@ const LINK_METACLASS = new rdfMeta.MetaClass();
*/
const PERSON_METACLASS = new rdfMeta.MetaClass();
/**
* The metaclass for a conference
*/
const CONFERENCE_METACLASS = new rdfMeta.MetaClass();
/**
* The metaclass for a track in a conference
*/
const TRACK_METACLASS = new rdfMeta.MetaClass();
/**
* The metaclass for a talk in a conference
*/
const TALK_METACLASS = new rdfMeta.MetaClass();
/**
* The metaclass for Book
*/
......@@ -281,6 +342,83 @@ BOOK_METACLASS.properties = [
)
];
CONFERENCE_METACLASS.properties = [
new rdfMeta.MetaPropertyData(
"title",
"http://purl.org/dc/elements/1.1/title"
),
new rdfMeta.MetaPropertyData(
"label",
"http://www.w3.org/2000/01/rdf-schema#label"
),
new rdfMeta.MetaPropertyData(
"acronym",
"http://data.semanticweb.org/ns/swc/ontology#hasAcronym"
),
new rdfMeta.MetaPropertyData(
"startDate",
"http://www.w3.org/2002/12/cal/ical#dtstart"
),
new rdfMeta.MetaPropertyData(
"endDate",
"http://www.w3.org/2002/12/cal/ical#dtend"
),
new rdfMeta.MetaPropertyObject(
"tracks",
"http://data.semanticweb.org/ns/swc/ontology#isSuperEventOf",
TRACK_METACLASS,
true
)
];
TRACK_METACLASS.properties = [
new rdfMeta.MetaPropertyData(
"title",
"http://purl.org/dc/elements/1.1/title"
),
new rdfMeta.MetaPropertyObject(
"talks",
"http://data.semanticweb.org/ns/swc/ontology#isSuperEventOf",
TALK_METACLASS,
true
),
new rdfMeta.MetaPropertyObject(
"conferences",
"http://data.semanticweb.org/ns/swc/ontology#isPartOf",
CONFERENCE_METACLASS,
true
)
];
TALK_METACLASS.properties = [
new rdfMeta.MetaPropertyData(
"title",
"http://purl.org/dc/elements/1.1/title"
),
new rdfMeta.MetaPropertyData(
"abstract",
"http://data.semanticweb.org/ns/swc/ontology#abstract"
),
new rdfMeta.MetaPropertyObject(
"authors",
"http://data.semanticweb.org/ns/swc/ontology#author",
LINK_METACLASS,
true
),
new rdfMeta.MetaPropertyObject(
"docs",
"http://data.semanticweb.org/ns/swc/ontology#hasRelatedDocument",
LINK_METACLASS,
true
),
new rdfMeta.MetaPropertyObject(
"trackOrConferences",
"http://data.semanticweb.org/ns/swc/ontology#isPartOf",
TRACK_METACLASS,
true
)
];
/**
* Loads the data for the entity of interest
* @param renderer The current renderer
......@@ -320,3 +458,63 @@ export function loadBook(
target
);
}
/**
* 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 loadConference(
renderer: application.ViewRenderer,
context: application.RenderingContext,
target: application.Resource
): Conference {
return rdfMeta.loadEntity(
renderer,
context,
ONTOLOGY,
CONFERENCE_METACLASS,
target
);
}
/**
* 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 loadTrack(
renderer: application.ViewRenderer,
context: application.RenderingContext,
target: application.Resource
): Track {
return rdfMeta.loadEntity(
renderer,
context,
ONTOLOGY,
TRACK_METACLASS,
target
);
}
/**
* 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 loadTalk(
renderer: application.ViewRenderer,
context: application.RenderingContext,
target: application.Resource
): Talk {
return rdfMeta.loadEntity(
renderer,
context,
ONTOLOGY,
TALK_METACLASS,
target
);
}
<template>
<div>
<h1>
{{conference.title}}
<span v-if="conference.__warnings['title'] != undefined" style="color: yellow; font-size: 8pt;" :title="conference.__warnings['title']">
&#x26A0;
</span>
</h1>
<table class="table table-bordered table-hover">
<tbody>
<tr>
<td><b>Acronym</b></td>
<td>
{{conference.acronym}}
<span v-if="conference.__warnings['acronym'] != undefined" style="color: yellow; font-size: 8pt;" :title="conference.__warnings['acronym']">
&#x26A0;
</span>
</td>
</tr>
<tr>
<td><b>Start date</b></td>
<td>
{{conference.startDate}}
<span v-if="conference.__warnings['startDate'] != undefined" style="color: yellow; font-size: 8pt;" :title="conference.__warnings['startDate']">
&#x26A0;
</span>
</td>
</tr>
<tr>
<td><b>End date</b></td>
<td>
{{conference.endDate}}
<span v-if="conference.__warnings['endDate'] != undefined" style="color: yellow; font-size: 8pt;" :title="conference.__warnings['endDate']">
&#x26A0;
</span>
</td>
</tr>
<tr>
<td><b>Tracks</b></td>
<td>
<div v-for="track in conference.tracks" v-bind:key="track.__resource.uri" class="card">
<div className="card-body">
<span>Track: </span>
<a v-on:click="(event) => {event.preventDefault(); context.event.onRequestNavigateTo(track.__resource);}" :href=track.__resource.uri>{{track.title != null ? track.title : track.__resource.uri}}</a>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<hr/>
<div class="row" style="color: darkgrey; font-size: 8pt; margin-top: 15pt;">
<span>Root: {{context.root}}</span>
<span style="margin-left: 10pt;">
Selected language:
<span v-if="context.options[context.root.uri].language != null || context.options[context.root.uri].language ==''">{{context.options[context.root.uri].language.name}}</span>
<span v-else>=&gt;</span>
</span>
<span style="margin-left: 10pt;">
Browser language:
<span v-if="context.browserLanguage != null">{{context.browserLanguage.name}}</span>
<span v-else>=&gt;</span>
</span>
</div>
</div>
</template>
<script>
export default {
props: ["context", "conference"]
};
</script>
<style>
.view-header {
width: 75%;
margin-left: 12.5%;
margin-top: 2vh;
margin-bottom: 2vh;
}
</style>
\ No newline at end of file
/*******************************************************************************
* Copyright 2003-2018 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
* contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
*
* This file is part of CubicWeb.
*
* CubicWeb is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 2.1 of the License, or (at your option)
* any later version.
*
* CubicWeb is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
import {
application,
definition,
implementation,
rdfEntities
} from "@logilab/libview";
import * as $rdf from "rdflib";
import Vue from "vue";
/// <reference path="../common/vue.d.ts" />
import ConferenceImpl from "./ConferenceImpl.vue";
import { ONTOLOGY, loadConference, Track } from "../common/schema";
/**
* The descritptor for the default Dbpedia Conference view
*/
const DESCRIPTOR_CONFERENCE: definition.ViewDescriptor = {
identifier: "::Logilab::Conference",
name: "Logilab: Conference View",
description: "Renders a conference from a dataset",
entrypoint: "VIEW_CONFERENCE_ENTRYPOINT",
resourceCss: [
{
location: "remote",
uri:
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
} as definition.ViewResourceRemote
],
resourceJs: [],
resourceMain: {
location: "remote",
uri: "http://localhost:8080/view_conference.js"
} as definition.ViewResourceRemote
};
class ConferenceRendering implements implementation.ViewImplementation {
descriptor: definition.ViewDescriptor;
constructor() {
this.descriptor = DESCRIPTOR_CONFERENCE;
this.priorityFor = this.priorityFor.bind(this);
this.render = this.render.bind(this);
}
priorityFor(store: $rdf.Formula, target: application.Resource): number {
if (target == null || target == undefined) return -1;
let repo = new rdfEntities.RdfEntityStore(
store,
ONTOLOGY.aliases,
ONTOLOGY.inverses
);
let entity = repo.entityForUri(target.uri);
let focus = entity.getEntityForS("http://xmlns.com/foaf/0.1/focus");
if (focus != null) entity = focus;
let entityTypes = entity.getEntitiesForS(
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
);
if (entityTypes.length > 0) {
let x = entityTypes.find(
(entity: rdfEntities.RdfEntity) =>
entity.uris.indexOf(
"http://data.semanticweb.org/ns/swc/ontology#ConferenceEvent"
) >= 0
);
if (x != null && x != undefined)
// The entity is a Conference
return 10;
}
return implementation.VIEW_PRIORITY_INAPPROPRIATE;
}
render(
renderer: application.ViewRenderer,
context: application.RenderingContext,
target: application.Resource
): application.ViewRendering {
let conference = loadConference(renderer, context, target);
let externals = conference.tracks.map((track: Track) =>
application.cloneResource(track.__resource)
);
let errors: string[] = [];
let previous = Vue.config.errorHandler;
Vue.config.errorHandler = function(err, vm, info) {
errors.push(err.message);
};
let vm = new Vue({
data: {
descriptor: this.descriptor,
conference: conference
},
components: { ConferenceImpl },
render: function(createElement) {
return createElement(
"ConferenceImpl",
{
props: {
context: context,
conference: conference
}
},
[]
);
}
});
let result = document.createElement("div");
vm.$mount(result);
vm.$forceUpdate();
Vue.config.errorHandler = previous;
if (errors.length > 0) throw errors[0];
return {
dom: vm.$el,
viewId: this.descriptor.identifier,
suggestedResources: externals
};
}
}
/**
* Export the view
*/
export const VIEW_CONFERENCE_ENTRYPOINT: ConferenceRendering = new ConferenceRendering();
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