Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
SemWeb
libview
Commits
e2033710ea11
Commit
e49021f4
authored
Jul 19, 2018
by
Laurent Wouters
Browse files
Export views specification for DbPedia as external package
parent
2e949029410d
Changes
7
Hide whitespace changes
Inline
Side-by-side
libview/package.json
View file @
e2033710
...
...
@@ -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"
,
...
...
libview/src/view-json.d.ts
0 → 100644
View file @
e2033710
/*******************************************************************************
* 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
;
}
libview/webpack.config.js
View file @
e2033710
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
"
}],
{}
)
]
}
];
views-dbpedia/package.json
View file @
e2033710
...
...
@@ -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"
}
}
views-dbpedia/src/dbpedia.vd.json
0 → 100644
View file @
e2033710
[
{
"identifier"
:
"::Logilab::DbPedia::Person"
,
"name"
:
"DbPedia Person"
,
"description"
:
"Renders a person from DbPedia"
,
"entrypoint"
:
"VIEW_DBPEDIA_PERSON"
,
"location"
:
{
"kind"
:
"embedded"
}
}
]
views-dbpedia/src/
index
.tsx
→
views-dbpedia/src/
dbpedia_person
.tsx
View file @
e2033710
...
...
@@ -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 view
s
*
Export
the view
*/
implementation
.
registerImplementation
(
new
DBPediaPersonRendering
());
const
IMPLEMENTATION
:
DBPediaPersonRendering
=
new
DBPediaPersonRendering
();
export
default
IMPLEMENTATION
;
views-dbpedia/webpack.config.js
View file @
e2033710
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
"
}
}
}
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment