Commit e49021f4 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Export views specification for DbPedia as external package

parent 2e949029410d
......@@ -27,6 +27,7 @@
"react": "^16.2.0"
},
"devDependencies": {
"copy-webpack-plugin": "^4.5.2",
"source-map-loader": "^0.2.3",
"ts-loader": "^4.4.2",
"typescript": "^2.9.2",
......
/*******************************************************************************
* 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 { ViewDescriptors } from "./view-def";
/**
* Module for JSON files containing view descriptors
*/
declare module "*.vd.json" {
const descriptors: ViewDescriptors;
export = descriptors;
}
const path = require("path");
const isProd = process.env.NODE_ENV === "production";
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = [
{
......@@ -21,6 +22,12 @@ module.exports = [
{ test: /\.tsx?$/, loader: "ts-loader" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
}
},
plugins: [
new CopyWebpackPlugin(
[{ from: "src/view-json.d.ts", to: "lib/view-json.d.ts" }],
{}
)
]
}
];
......@@ -6,7 +6,8 @@
"build": "webpack",
"clean": "rm -rf build/*",
"test": "echo \"Error: no test specified\" && exit 1",
"build:production": "NODE_ENV=production webpack"
"build:production": "NODE_ENV=production webpack",
"serve": "webpack && webpack-dev-server"
},
"main": "./build/index.js",
"types": "./build/lib/index.d.ts",
......@@ -28,10 +29,12 @@
"react": "^16.2.0"
},
"devDependencies": {
"copy-webpack-plugin": "^4.5.2",
"source-map-loader": "^0.2.3",
"ts-loader": "^4.4.2",
"typescript": "^2.9.2",
"webpack": "^4.0.1",
"webpack-cli": "^2.0.10"
"webpack-cli": "^2.0.10",
"webpack-dev-server": "^3.0.0"
}
}
[
{
"identifier": "::Logilab::DbPedia::Person",
"name": "DbPedia Person",
"description": "Renders a person from DbPedia",
"entrypoint": "VIEW_DBPEDIA_PERSON",
"location": {
"kind": "embedded"
}
}
]
......@@ -20,12 +20,12 @@
import { definition, application, implementation } from "@logilab/libview";
import * as React from "react";
import { RDF, RdfStore, Term, $rdf } from "rdflib";
import { RdfStore, Term, $rdf } from "rdflib";
/**
* The descritptor for the default Dbpedia person view
*/
export const DESCRIPTOR_PERSON: definition.ViewDescriptor = {
const DESCRIPTOR_PERSON: definition.ViewDescriptor = {
identifier: "::Logilab::DbPedia::Person",
name: "DbPedia Person",
description: "Renders a person from DbPedia",
......@@ -35,15 +35,6 @@ export const DESCRIPTOR_PERSON: definition.ViewDescriptor = {
}
};
/**
* The source for the DbPedia views
*/
export const SOURCE: definition.ViewRegistrySourceInline = {
name: "Source of DbPedia views",
kind: definition.ViewRegistrySourceKind.Inlined,
descriptors: [DESCRIPTOR_PERSON]
};
/**
* Gets the value for the propert of a resource
* @param store The RDF store containing the data
......@@ -86,8 +77,7 @@ function hasTraitDbPediaPerson(store: RdfStore, primaryTopic: string): boolean {
return a != null && a != undefined && a.length > 0;
}
export class DBPediaPersonRendering
implements implementation.ViewImplementation {
class DBPediaPersonRendering implements implementation.ViewImplementation {
descriptor: definition.ViewDescriptor;
constructor() {
this.descriptor = DESCRIPTOR_PERSON;
......@@ -136,6 +126,7 @@ export class DBPediaPersonRendering
}
/**
* Registers the views
* Export the view
*/
implementation.registerImplementation(new DBPediaPersonRendering());
const IMPLEMENTATION: DBPediaPersonRendering = new DBPediaPersonRendering();
export default IMPLEMENTATION;
const path = require("path");
const isProd = process.env.NODE_ENV === "production";
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = [
{
entry: "./src/index.tsx",
entry: "./src/dbpedia_person.tsx",
mode: isProd ? "production" : "development",
output: {
path: path.join(__dirname, "build/"),
publicPath: path.join(__dirname, "build/"),
filename: "index.js"
filename: "dbpedia_person.js"
},
devtool: "source-map",
resolve: {
......@@ -19,6 +20,19 @@ module.exports = [
{ test: /\.tsx?$/, loader: "ts-loader" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},
plugins: [
new CopyWebpackPlugin(
[{ from: "src/dbpedia.vd.json", to: "dbpedia.vd.json" }],
{}
)
],
devServer: {
contentBase: path.join(__dirname, "build"),
compress: true,
historyApiFallback: {
index: "index.html"
}
}
}
];
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