Skip to content

Commit

Permalink
feat: first draft (+ irigenerator)
Browse files Browse the repository at this point in the history
  • Loading branch information
psiotwo committed Jan 3, 2025
0 parents commit a3ffbe4
Show file tree
Hide file tree
Showing 25 changed files with 30,007 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main

jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build website
run: yarn build

- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: build

deploy:
name: Deploy to GitHub Pages
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
24 changes: 24 additions & 0 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test deployment

on:
pull_request:
branches:
- main

jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Test build website
run: yarn build
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

*.iml
.idea
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# SemantiCZ website

This website is built using [Docusaurus](https://docusaurus.io/).

## Adding info about SemantiCZ components
- create a new folder in `docs` with the name of the component
- add a `_category_.json` and `index.md` file to that folder
- add other files as needed. Get inspired in the `irigenerator` folder

## Development

## Installation

```
$ yarn
```

### Local Development

```
$ yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

Using SSH:

```
$ USE_SSH=true yarn deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
4 changes: 4 additions & 0 deletions docs/irigenerator/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "IRI Generator",
"position": 1
}
61 changes: 61 additions & 0 deletions docs/irigenerator/example-usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
sidebar_position: 2
---

# Example Usage

This piece of code

```java
final IriGeneratorCalculator sut = new IriGeneratorCalculator(
"https://example.org/person/tempid/", // base IRI of the temporary resources
new SpelService(), // SpEL interpreter for IRI template
uriGeneratorsResource, // URL of the file/resource with generators configuration
format // JSON-LD or JSON5
);

final Model originalModel = ... // the original Jena Model to transform

final Model convertedModel = sut.convert(
originalModel,
ImmutableMap.of("baseUri", "https://data.cogni.zone/person/") // constant variables for IRI construction
);
```

and the configuration (loaded as `uriGeneratorsResource`)

```json
{
"@context": { ... }, // context omitted for brevity, see https://github.com/cognizone/semanticz-irigenerator/blob/develop/src/main/resources/context.json
"prefixes": [{
"prefix-name": "eczm",
"namespace": "https://example.cogni.zone/model#"
}],
"generators": [
{
"uriSelector": "select ?uri { ?uri a eczm:Person }",
"variableSelector": "select ?id where { <#{[uri]}> eczm:id ?id }",
"uriTemplate": "#{[baseUri]}/#{[id]}"
}
]
}
```


will transform the model

```
@prefix eczm: <https://example.cogni.zone/model#> .
<https://example.org/person/tempid/1> a eczm:Person ;
eczm:ssn "123-456-789" .
```

into

```
@prefix eczm: <https://example.cogni.zone/model#> .
<https://data.cogni.zone/person/123-456-789> a eczm:Person ;
eczm:ssn "123-456-789" .
```
9 changes: 9 additions & 0 deletions docs/irigenerator/features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
sidebar_position: 1
---

# Features
- suitable for generating permanent IRIs from temporary ones (e.g. those generated by the frontend)
- configuration via [JSON-LD](https://json-ld.org/) / [JSON5](https://json5.org/)
- different generators for different resources (selected by SPARQL)
- new IRI is constructed based on the properties of the resource (configurable via SPARQL)
19 changes: 19 additions & 0 deletions docs/irigenerator/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: IRI Generator
slug: /irigenerator
---

[IRI Generator](https://github.com/cognizone/semanticz-irigenerator) renames resource IRIs based on the resource properties.

```mermaid
graph LR
original -.....->|IRI generator| after
subgraph original["original RDF graph"]
R1["https‎://example.org/person/tempid/1"] -->|:ssn| SSN1((<font color=red>123-456-789))
end
subgraph after["generated RDF graph"]
R1a["https‎://data.cogni.zone/person/<font color=red>123-456-789"] -->|:ssn| SSN1a((<font color=red>123-456-789))
end
```
94 changes: 94 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';

// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)

const config: Config = {
title: 'SemantiCZ',
tagline: 'Semantic components by Cognizone',
favicon: 'img/favicon-32x32.png',

// Set the production url of your site here
url: 'https://semanticz.github.com',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/',

// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'cognizone', // Usually your GitHub org/user name.
projectName: 'semanticz', // Usually your repo name.

onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',

// Even if you don't use internationalization, you can use this field to set
// useful metadata like html lang. For example, if your site is Chinese, you
// may want to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'en',
locales: ['en'],
},

presets: [
[
'classic',
{
docs: {
sidebarPath: './sidebars.ts',
},
blog: {
showReadingTime: true,
feedOptions: {
type: ['rss', 'atom'],
xslt: true,
},
onInlineTags: 'warn',
onInlineAuthors: 'warn',
onUntruncatedBlogPosts: 'warn',
},
theme: {
customCss: './src/css/custom.css',
},
} satisfies Preset.Options,
],
],

markdown: {
mermaid: true,
},
themes: ['@docusaurus/theme-mermaid'],

themeConfig: {
// Replace with your project's social card
image: 'img/semantic.svg',
navbar: {
title: 'SemantiCZ',
logo: {
alt: 'SemantiCZ Logo',
src: 'img/semantic-color.png',
},
items: [
{
type: 'docSidebar',
sidebarId: 'componentsSidebar',
position: 'left',
label: 'Components',
}
],
},
footer: {
style: 'dark',
links: [
],
copyright: `Copyright © ${new Date().getFullYear()} <a href="https://cogni.zone">cognizone</a>. Built with Docusaurus</a>.`,
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
},
} satisfies Preset.ThemeConfig,
};

export default config;
Loading

0 comments on commit a3ffbe4

Please sign in to comment.