Skip to content

Commit

Permalink
deploy: 224ba45
Browse files Browse the repository at this point in the history
  • Loading branch information
white-gecko committed Aug 4, 2024
1 parent 3b8c5a9 commit 8db0374
Show file tree
Hide file tree
Showing 30 changed files with 44,012 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
docs
.git
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

.package-lock.json
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:12-alpine

# Check https://vuejs.org/v2/cookbook/dockerize-vuejs-app.html

RUN npm install -g http-server
RUN apk add git

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build

RUN npm prune --production

ENV SPARQL_QUERY="http://localhost:5000/sparql"
ENV SPARQL_UPDATE="http://localhost:5000/sparql"
ENV PRESELECTED_GRAPH_IRI="http://example.org/"
ENV PRESELECTED_RESOURCE_IRI="http://example.org/Resource"

EXPOSE 8080
ENTRYPOINT [ "/bin/sh" ]
CMD [ "docker-entrypoint.sh" ]
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# OntoPad

OntoPad is a simple editor for RDF data, e.g. Resources, Classes, and Properties. On top of the simple RDF layer it provides ways to visually interact with SHACL shapes.

OntoPad is designed to run in you web browser (with JavaScript support) and to be connected to a SPARQL Endpoint. To be able to share the data you create it works best with the [Quit Store](https://github.com/AKSW/QuitStore) (actually currently only supported SPARQL Endpoint cf. [#18](https://github.com/AKSW/OntoPad/issues/18)).

To build the code and get it running in your development environment you need a recent version of `node` (node.js) and `npm` (https://nodejs.org/).
You can also get it running in a docker environment with our docker image [`aksw/ontopad`](https://hub.docker.com/r/aksw/ontopad).

## Project setup
```
npm install
```

### Compiles and hot-reloads for development
```
npm run serve
```

Now the OntoPad should be locally available at `http://localhost:8080/` or some other port, if port `8080` is used already.

### Compiles and minifies for production
```
npm run build
```

This will set `APP_CONFIG` to `null`. To set `APP_CONFIG` now the configuration can be injected. If `APP_CONFIG` remains `null` OntoPad will fail to load, this might change in the future ([#19](https://github.com/AKSW/OntoPad/issues/19)).

#### Inject configuration

You can adjust `src/config/config.json` or set the following environment variables

- `QUIT_URL` the URL of a running [Quit Store](https://github.com/AKSW/QuitStore)
- `SPARQL_QUERY` the URL of a SPARQL Query Endpoint (currently only Quit Store cf. [#18](https://github.com/AKSW/OntoPad/issues/18))
- `SPARQL_UPDATE` the URL of a SPARQL Update Endpoint (currently only Quit Store cf. [#18](https://github.com/AKSW/OntoPad/issues/18))
- `PRESELECTED_GRAPH_IRI` the IRI of the RDF Graph to select per default
- `PRESELECTED_RESOURCE_IRI` the IRI of the RDF Resource to select per default

Now run the following to inject the configuration:

```
node docker-inject-config.js
```

### Compile and build for serving locally
```
NODE_ENV=dev npm run build
```

(`NODE_ENV` just must not be `production`.)
This includes the default configuration from `src/config/config.json` to set `APP_CONFIG`.
This configuration expects the SPARQL-Endpoint to be a [Quit Store](https://github.com/AKSW/QuitStore) running at `http://localhost:5000`.

The result can be served with a local HTTP server

```
cd dist
python3 -m http.server 8080
```

### Run your tests
```
npm run test
```

### Lints and fixes files
```
npm run lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
2 changes: 2 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node docker-inject-config.js
http-server dist
44 changes: 44 additions & 0 deletions docker-inject-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* The script is used in preparation to statically serve the application in /dist
*
* Injects front-end configuration properties in dist/index.html after building. This is used for Docker Images where the configuration file is provided only after the Vue app is compiled.
* Adapted from <https://medium.com/@marius.dras/dockerize-a-vue-app-with-a-configuration-file-a77cd98c879b>
*/
const fs = require('fs');
const htmlFile = './dist/index.html';
const configFile = './src/config/config.json';

if (!fs.existsSync(htmlFile)) {
console.warn(`The project is not compiled (${htmlFile} is missing for post-compilation config injection)`);
return;
}

const html = fs.readFileSync(htmlFile).toString();
let config;
if ('QUIT_URL' in process.env || 'SPARQL_QUERY' in process.env){
console.log('Environment found construct config from environment variables.');
const endpoint = {}
if ('QUIT_URL' in process.env) {
endpoint.quit_url = process.env.QUIT_URL
} else {
endpoint.query_url = process.env.SPARQL_QUERY
if ('SPARQL_UPDATE' in process.env) {
endpoint.update_url = process.env.SPARQL_UPDATE
}
}
config = {
"endpoint": endpoint,
"graph_iri": process.env.PRESELECTED_GRAPH_IRI,
"resource_iri": process.env.PRESELECTED_RESOURCE_IRI
}
} else if (fs.existsSync(configFile)) {
console.log(`Local config file found use it: ${configFile}`);
config = require(configFile);
} else {
console.warn(`Configuration is missing for post-compilation config injection. Provide ${configFile} or QUIT_UPDATE and QUIT_QUERY environment variables.`);
}
const configVariablePattern = /<script>const APP_CONFIG = null;<\/script>/g;
const newConfigVariable = '<script>const APP_CONFIG = ' + JSON.stringify(config) + ';</script>';
const injectedHtml = html.replace(configVariablePattern, newConfigVariable);

fs.writeFileSync(htmlFile, injectedHtml);
2 changes: 2 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
theme: jekyll-theme-cayman
demo_url: https://demo.ontopad.aksw.org/#/voc
41 changes: 41 additions & 0 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="{{ site.lang | default: "en-US" }}">
<head>
<meta charset="UTF-8">

{% seo %}
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#157878">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">
</head>
<body>
<a id="skip-to-content" href="#content">Skip to the content.</a>

<header class="page-header" role="banner">
<h1 class="project-name">{{ page.title | default: site.title | default: site.github.repository_name }}</h1>
<h2 class="project-tagline">{{ page.description | default: site.description | default: site.github.project_tagline }}</h2>
{% if site.github.is_project_page %}
<a href="{{ site.github.repository_url }}" class="btn">View on GitHub</a>
{% endif %}
{% if site.show_downloads %}
<a href="{{ site.github.zip_url }}" class="btn">Download .zip</a>
<a href="{{ site.github.tar_url }}" class="btn">Download .tar.gz</a>
{% endif %}
{% if site.demo_url %}
<a href="{{ site.demo_url }}" class="btn">Demo</a>
{% endif %}
</header>

<main id="content" class="main-content" role="main">
{{ content }}

<footer class="site-footer">
{% if site.github.is_project_page %}
<span class="site-footer-owner"><a href="{{ site.github.repository_url }}">{{ site.github.repository_name }}</a> is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a>.</span>
{% endif %}
<span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a>.</span>
</footer>
</main>
</body>
</html>
9 changes: 9 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## OntoPad

The OntoPad is a simple RDF editor written in JavaScript.
With the Vocabulary module it provides the possibility to generate a simple RDFS vocabulary and visually compose SHACL shapes based on the vocabulary.
The OntoPad is setup on a [Quit Store](https://quit.aksw.org/) which makes the system collaborative by providing the possibility to exchange data via Git.

The demo installation is available at [https://demo.ontopad.aksw.org/](https://demo.ontopad.aksw.org/), the Vocabulary module at [https://demo.ontopad.aksw.org/#/voc](https://demo.ontopad.aksw.org/#/voc).

Feel free to send us a [pull-requestst](https://github.com/AKSW/OntoPad/pulls) if you want to fix something or provide additions.
Loading

0 comments on commit 8db0374

Please sign in to comment.