Skip to content

Commit

Permalink
Update examples with new LDkit version (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
karelklima authored Mar 10, 2023
1 parent 0e0c6de commit 67f18d4
Show file tree
Hide file tree
Showing 41 changed files with 316 additions and 196 deletions.
8 changes: 8 additions & 0 deletions examples/basic/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,26 @@ console.log(ada?.birthDate); // Date object of 1815-12-10
const count = await Persons.count();
console.log(count); // number

// The following code will not work on DBPedia as it needs write permissions

// Insert a new person
/*
Persons.insert({
$id: "http://dbpedia.org/resource/Alan_Turing",
name: "Alan Turing",
birthDate: new Date("1912-06-23"),
});
*/

// Modify a person's name
/*
Persons.update({
$id: "http://dbpedia.org/resource/Alan_Turing",
name: "Not Alan Turing",
});
*/

// Delete a person
/*
Persons.delete("http://dbpedia.org/resource/Alan_Turing");
*/
15 changes: 15 additions & 0 deletions examples/react-bulletin-boards/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Úřední desky</title>
</head>

<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
28 changes: 16 additions & 12 deletions examples/react-bulletin-boards/package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
{
"author": "Karel Klima <[email protected]> (https://karelklima.com)",
"license": "MIT",
"source": "src/index.html",
"type": "module",
"scripts": {
"start": "parcel src/index.html"
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@comunica/query-sparql": "^2.4.3",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@mui/icons-material": "^5.10.6",
"@mui/material": "^5.10.7",
"ldkit": "^0.6.3",
"@comunica/query-sparql": "^2.6.9",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.11.12",
"ldkit": "^0.8.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^3.1.4",
"react-router-dom": "^6.4.1"
"react-router-dom": "^6.8.2"
},
"devDependencies": {
"events": "^3.3.0",
"parcel": "^2.7.0",
"process": "^0.11.10"
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"typescript": "^4.9.3",
"vite": "^4.1.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { Board } from "./Board";
import { Form } from "./Form";

import { CssBaseline, AppBar, Toolbar, Typography, Box } from "@mui/material";
import { AppBar, Box, CssBaseline, Toolbar, Typography } from "@mui/material";
import { BrowserRouter } from "react-router-dom";

export const App = () => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import React, { useState, useEffect } from "react";
import React, { useEffect, useState } from "react";
import styled from "@emotion/styled";

import {
InformationInterface,
createInfosResource,
DEFAULT_BOARD_IRI,
} from "../store";
InformationInterface,
} from "./store";
import {
TableContainer,
Alert,
Box,
IconButton,
Paper,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
TableCell,
TableBody,
Paper,
IconButton,
Alert,
Box,
} from "@mui/material";
import LinkIcon from "@mui/icons-material/Link";
import { useSearchParams } from "react-router-dom";
Expand Down Expand Up @@ -81,9 +81,7 @@ const BoardContent: React.FC<{ iri: string }> = ({ iri }) => {
</TableRow>
</TableHead>
<TableBody>
{informations.map((item, index) => (
<Item item={item} key={index} />
))}
{informations.map((item, index) => <Item item={item} key={index} />)}
</TableBody>
</Table>
</TableContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FormEvent, useEffect, useRef } from "react";

import { DEFAULT_BOARD_IRI } from "../store";
import { Grid, TextField, Button } from "@mui/material";
import { DEFAULT_BOARD_IRI } from "./store";
import { Button, Grid, TextField } from "@mui/material";
import { useSearchParams } from "react-router-dom";

type Inputs = {
Expand Down
12 changes: 0 additions & 12 deletions examples/react-bulletin-boards/src/index.html

This file was deleted.

8 changes: 0 additions & 8 deletions examples/react-bulletin-boards/src/index.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions examples/react-bulletin-boards/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import ReactDOM from "react-dom/client";

import { App } from "./App";

ReactDOM.createRoot(document.getElementById("app") as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
61 changes: 36 additions & 25 deletions examples/react-bulletin-boards/src/store.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
import { type Context, type SchemaInterface, createResource, createNamespace } from "ldkit";
import {
type Context,
createNamespace,
createResource,
type SchemaInterface,
} from "ldkit";
import { dcterms, schema, xsd } from "ldkit/namespaces";
import { QueryEngine as Comunica } from "@comunica/query-sparql";

const time = createNamespace({
iri: "http://www.w3.org/2006/time#",
prefix: "time:",
terms: ["Instant", "inXSDDate", "inXSDDateTimeStamp"],
} as const);
const time = createNamespace(
{
iri: "http://www.w3.org/2006/time#",
prefix: "time:",
terms: ["Instant", "inXSDDate", "inXSDDateTimeStamp"],
} as const,
);

const desky = createNamespace({
iri: "https://slovník.gov.cz/datový/ofn-úřední-desky/pojem/",
prefix: "desky:",
terms: [
"úřední-deska",
"stránka-zveřejnění",
"informace-zveřejněná-na-úřední-desce",
"vyvěšení-informace",
"schválení-informace",
"relevantní-do",
"číslo-jednací",
"spisová-značka-spisu",
],
} as const);
const desky = createNamespace(
{
iri: "https://slovník.gov.cz/datový/ofn-úřední-desky/pojem/",
prefix: "desky:",
terms: [
"úřední-deska",
"stránka-zveřejnění",
"informace-zveřejněná-na-úřední-desce",
"vyvěšení-informace",
"schválení-informace",
"relevantní-do",
"číslo-jednací",
"spisová-značka-spisu",
],
} as const,
);

const sb504_2004 = createNamespace({
iri: "https://slovník.gov.cz/legislativní/sbírka/500/2004/pojem/",
prefix: "sb504_2004:",
terms: ["vyvěšení-informace"],
} as const);
const sb504_2004 = createNamespace(
{
iri: "https://slovník.gov.cz/legislativní/sbírka/500/2004/pojem/",
prefix: "sb504_2004:",
terms: ["vyvěšení-informace"],
} as const,
);

const InstantSchema = {
"@type": time.Instant,
Expand Down
19 changes: 16 additions & 3 deletions examples/react-bulletin-boards/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"esModuleInterop": true
"jsx": "react-jsx"
},
"include": ["src"]
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
9 changes: 9 additions & 0 deletions examples/react-bulletin-boards/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
7 changes: 7 additions & 0 deletions examples/react-bulletin-boards/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
15 changes: 15 additions & 0 deletions examples/react-dbpedia-actors/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>LDkit | React DBpedia Actors example</title>
</head>

<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
23 changes: 14 additions & 9 deletions examples/react-dbpedia-actors/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{
"author": "Karel Klima <[email protected]> (https://karelklima.com)",
"license": "MIT",
"source": "src/index.html",
"type": "module",
"scripts": {
"start": "parcel src/index.html"
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@mui/material": "^5.10.5",
"ldkit": "^0.6.3",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@mui/material": "^5.11.12",
"ldkit": "^0.8.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"events": "^3.3.0",
"parcel": "^2.7.0",
"process": "^0.11.10"
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"typescript": "^4.9.3",
"vite": "^4.1.0",
"vite-plugin-node-polyfills": "^0.7.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import React, { useEffect, useState } from "react";

import { createLocalizedActorResource, ActorInterface } from "../store";
import { ActorInterface, createLocalizedActorResource } from "./store";
import { Grid, Typography } from "@mui/material";

type ActorProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from "react";
import { Container, Grid, TextField, MenuItem } from "@mui/material";
import React, { useEffect, useState } from "react";
import { Container, Grid, MenuItem, TextField } from "@mui/material";

import { favouriteActors, languages } from "../store";
import { favouriteActors, languages } from "./store";
import { Actor } from "./Actor";

export const Actors: React.FC = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import React from "react";
import { Actors } from "./Actors";

import {
CssBaseline,
AppBar,
Toolbar,
Typography,
Box,
Button,
CssBaseline,
Toolbar,
Typography,
} from "@mui/material";

export const App = () => (
Expand Down
12 changes: 0 additions & 12 deletions examples/react-dbpedia-actors/src/index.html

This file was deleted.

Loading

0 comments on commit 67f18d4

Please sign in to comment.