Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasCARPi committed Oct 8, 2023
0 parents commit 43c3b0b
Show file tree
Hide file tree
Showing 30 changed files with 6,455 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# https://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.js,*.json,*.ts]
indent_size = 2

[*.html]
indent_size = 2
54 changes: 54 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
},
extends: [
'standard',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
parserOptions: {
ecmaVersion: 12,
},
env: {
'browser': true,
'amd': true,
'es6': true,
},
rules: {
'indent': [
'error',
2,
],
'linebreak-style': [
'error',
'unix',
],
'quotes': [
'error',
'single',
],
'semi': [
'error',
'always',
],
'comma-dangle': [
'error',
'always-multiline',
],
'keyword-spacing': [
'error',
{'before': true, 'after': true},
],
'space-before-function-paren': [
'error',
'never',
],
'@typescript-eslint/no-extra-parens': [
'error',
'all',
],
}
}
1 change: 1 addition & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't be a jerk!
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---

name: Bug report
about: If something isn't working as expected.

---

# Describe the bug
<!-- Before reporting an issue please check that you are using the latest malle version! -->

<!-- Please describe precisely your problem here. -->

# Steps to reproduce

<!-- A reproducible bug is always much easier to fix! -->

# Information

<!-- Please make sure to fill this information! -->

- ro-crate2html version:
- Client operating system (e.g: MacOS, Windows, GNU+Linux):
- Browser (e.g. firefox, chrome):
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

name: Feature request
about: I have a suggestion!

---

# Feature request

<!-- Please provide a clear description of what problem you are trying to solve and how would you want it to be solved. -->
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

name: Question / Help
about: I have a question or I need help

---

# Question / free support

<!-- Please provide a clear description of what problem you are trying to solve and how would you want it to be solved. -->
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make sure to run the test suite.
37 changes: 37 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "CodeQL"

on:
push:
branches: [ master, dev ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ dev ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Build javascript file
run: npm run build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
25 changes: 25 additions & 0 deletions .github/workflows/publishing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: publish
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
name: Publish latest release
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Build dist files
run: npm run build
- name: Publish package
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
access: 'public'
22 changes: 22 additions & 0 deletions .github/workflows/validating.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: validate
on: [push, pull_request]
jobs:
run-test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '18', '20' ]
name: Node ${{ matrix.node }} test
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run test
run: npm run test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/*
node_modules/
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
src
tests
tsconfig.json
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog for ro-crate2html

## 0.1.0

* First release
29 changes: 29 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# How to contribute to ro-crate2html

## Branches

The `master` branch corresponds to the latest stable version. You should work from and target the `dev` branch.

## Dev server

First, setup continuous build with `npm run watch` in a spare terminal/tmux pane, so changes in source code are immediatly visible in produced javascript files.

Then, if your user is in the `docker` group, start a dev server with `npm run dev-server`. This will start a webserver and you can then access the demo at http://localhost:4848/demo.

Run `npm run stop-dev` to stop the dev server and remove the container.

## Pre-commit hook

Go into .git/hooks. And `cp pre-commit.sample pre-commit`. Edit it and before the last line with the “exec”, add this:

~~~bash
# pre-commit hook
reset="\e[0m"
red="\e[0;31m"
set -e
if ! npm run pre-commit
then
printf "${red}error${reset} Pre-commit script found a problem!.\n"
exit 1
fi
~~~
1 change: 1 addition & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Documentation for ro-crate2html
3 changes: 3 additions & 0 deletions FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms
liberapay: NicolasCARPi
github: NicolasCARPi
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Nicolas CARPi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ro-crate2html

Convert RO-Crate JSON-LD to HTML elements.

![validate](https://github.com/deltablot/ro-crate2html/workflows/validate/badge.svg)
[![GitHub license](https://img.shields.io/github/license/deltablot/ro-crate2html.svg)](https://github.com/deltablot/ro-crate2html/blob/master/LICENSE)

## Description

WIP

## Installation

~~~bash
npm i @deltablot/ro-crate2html
# or
yarn add @deltablot/ro-crate2html
~~~

## Quickstart

See the [Documentation](./DOCUMENTATION.md) for usage and available options.

See the [demo/](./demo) folder for a full example.

## Contributing

See [contributing documentation](./CONTRIBUTING.md).

## License

This software is open source and licensed under the [MIT License](./LICENSE).
1 change: 1 addition & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See our [Responsible Disclosure Policy](https://www.deltablot.com/security/).
Empty file added demo/favicon.ico
Empty file.
23 changes: 23 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<!--
* This file is part of the "ro-crate2html" library
* Copyright 2023 Nicolas CARPi @ Deltablot
* License MIT
* https://github.com/deltablot/ro-crate2html
-->
<html lang='en'>
<head>
<meta http-equiv='Content-type' content='text/html;charset=UTF-8' />
<link rel='icon' type='image/ico' href='favicon.ico' />
<link rel='stylesheet' type='text/css' href='https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css'>
<link rel='stylesheet' type='text/css' href='styles.css'>
</head>
<body>

<div class='container-fluid'>
<h1>ro-crate2html demo page</h1>

<script src='main.js' type='module'></script>
<div id='ro-crate-div'></div>
</body>
</html>
26 changes: 26 additions & 0 deletions demo/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*!
* This file is part of the "ro-crate2html" library
* Copyright 2023 Nicolas CARPi @ Deltablot
* License MIT
* https://github.com/deltablot/ro-crate2html
*/
import { Builder } from '../dist/main.js';

const jsonLdFilePath = '../example/ro-crate-metadata.json';
fetch(jsonLdFilePath).then((response) => {
if (!response.ok) {
throw new Error(`Failed to fetch ${jsonLdFilePath}`);
}
return response.text();
})
.then(jsonLdData => {
const builder = new Builder();
const result = builder.parse(jsonLdData);
const targetDiv = document.getElementById('ro-crate-div');
result.forEach(el => {
targetDiv.appendChild(el);
});
})
.catch(error => {
console.error(error);
});
21 changes: 21 additions & 0 deletions demo/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This file is part of the "ro-crate2html" library
* Copyright 2023 Nicolas CARPi @ Deltablot
* License MIT
* https://github.com/deltablot/malle
*/
:root {
--main-bg: #f4f6f7;
--border: #cdcdcd;
}

body {
background-color: var(--main-bg);
padding-left: 2vw;
color: #444;
}

.ro-crate2htmlKey {
font-weight: bold;
margin-right: 1em;
}
1 change: 1 addition & 0 deletions example/ro-crate-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@context":"https:\/\/w3id.org\/ro\/crate\/1.1\/context","@graph":[{"@id":"ro-crate-metadata.json","@type":"CreativeWork","about":{"@id":".\/"},"conformsTo":{"@id":"https:\/\/w3id.org\/ro\/crate\/1.1"},"dateCreated":"2023-10-08T20:18:35+02:00","sdPublisher":{"@type":"Organization","name":"eLabFTW","logo":"https:\/\/www.elabftw.net\/img\/elabftw-logo-only.svg","slogan":"A free and open source electronic lab notebook.","url":"https:\/\/www.elabftw.net","parentOrganization":{"@type":"Organization","name":"Deltablot","logo":"https:\/\/www.deltablot.com\/img\/logos\/deltablot.svg","slogan":"Open Source software for research labs.","url":"https:\/\/www.deltablot.com"}},"version":"1.0"},{"@id":"https:\/\/elab.local:3148\/database.php?mode=view&id=51","@type":"Dataset","name":" - Accusantium velit aut earum quia possimus incidunt omnis.","identifier":"20231003-3a1a07bf9fcd057c8a12c04540757c84473d86dc"},{"@id":"https:\/\/elab.local:3148\/database.php?mode=view&id=50","@type":"Dataset","name":" - Totam eum similique natus sed.","identifier":"20231003-cb80589f2bdd309a8e3e95d115dbdb12594f7cf5"},{"@id":"https:\/\/elab.local:3148\/database.php?mode=view&id=159","@type":"Dataset","name":" - Spinning Disk 2","identifier":"20231003-114c2bad043882c477e2f98256f64d17c2b41dd5"},{"@id":"https:\/\/elab.local:3148\/experiments.php?mode=view&id=256","@type":"Dataset","name":" - Test the grouped extra fields","identifier":"20231003-b433ce2a09aaef2c768c2f8ceddb9dc94973e74d"},{"@id":"https:\/\/elab.local:3148\/experiments.php?mode=view&id=257","@type":"Dataset","name":" - An example experiment","identifier":"20231003-b03d783e84b04632a8f1fdbc2b30b9bbb4e2d08d"},{"@id":"https:\/\/elab.local:3148\/experiments.php?mode=view&id=258","@type":"Dataset","name":" - Transfection of p103\u039412-22 into RPE-1 Actin-RFP","identifier":"20231003-7dee196818bb2b0a0adfd340c138e1fec7aaf60c"},{"@id":".\/2025-03-03 - Testing-the-eLabFTW-lab-notebook - 3d53e806\/export-elabftw.json","@type":"File","description":"JSON export","name":"export-elabftw.json","encodingFormat":"application\/json","contentSize":"4802","sha256":"ea6880fde6bcd470d5ed8bd0122593414792fe1fc2110416fc259243730ae50e"},{"@id":"comment:\/\/2023-10-02T23%3A25%3A04%2B02%3A00","@type":"Comment","dateCreated":"2023-10-02T23:25:04+02:00","text":"Well, it&#39;s always reassuring to know that scientists are spending their time and our tax dollars discovering what the rest of us already learned in third-grade science class.","author":{"@id":"person:\/\/a0568e4aa35eec2cf3962db57eec039a205d3b7d7c7132388af976dfaf8f2694?hash_algo=sha256"}},{"@id":".\/2025-03-03 - Testing-the-eLabFTW-lab-notebook - 3d53e806\/ezgif.com-video-to-gif.gif","@type":"File","description":"","name":"ezgif.com-video-to-gif.gif","alternateName":"dc\/dc0c9b2c3cbb9719c1bcb8fb6f45c7c36e23f444457efba266772c0eb36826ce480f976136b1d55ada1c7a9d27e73d1e74335e07365bf820f5f2f079833ce7a6.gif","contentSize":335246,"sha256":"f845481e61b1ac748a302a4e3efbe67331880911918ffa399cf4581daa01dc62"},{"@id":".\/2025-03-03 - Testing-the-eLabFTW-lab-notebook - 3d53e806\/simplescreenrecorder-2023-10-08_04.15.21.mkv","@type":"File","description":"","name":"simplescreenrecorder-2023-10-08_04.15.21.mkv","alternateName":"ae\/aec892b18fbe8ce1b10552fd8fa3fb4216c48cb7a90c862bf439b5b2335b7c91a35aaee172575e0677a37050d3022858fd65f2b54e194784b85fd308c2f665f9.mkv","contentSize":187205,"sha256":"01bedb4bd637fb00a6f2446c77006278ad25bcf299f90ad45c86e5b600022189"},{"@id":".\/2025-03-03 - Testing-the-eLabFTW-lab-notebook - 3d53e806","@type":"Dataset","author":{"@id":"person:\/\/a0568e4aa35eec2cf3962db57eec039a205d3b7d7c7132388af976dfaf8f2694?hash_algo=sha256"},"dateCreated":"2023-10-02T23:25:04+02:00","dateModified":"2023-10-08T19:18:26+02:00","identifier":"20231003-3d53e806089847974ceb9c24fd2b4ad52b098730","comment":[{"@id":"comment:\/\/2023-10-02T23%3A25%3A04%2B02%3A00"}],"keywords":["demo","test"],"name":"Testing the eLabFTW lab notebook","text":"<h1>Goal<\/h1><p>Test the software.<\/p><h1>Procedure<\/h1><p>Click everywhere and explore everything.<\/p><h1>Results<\/h1><p>It's really nice, I think I'll adopt it for our lab.<\/p>","url":"https:\/\/elab.local:3148\/experiments.php?mode=view&id=264","hasPart":[{"@id":".\/2025-03-03 - Testing-the-eLabFTW-lab-notebook - 3d53e806\/export-elabftw.json"},{"@id":".\/2025-03-03 - Testing-the-eLabFTW-lab-notebook - 3d53e806\/ezgif.com-video-to-gif.gif"},{"@id":".\/2025-03-03 - Testing-the-eLabFTW-lab-notebook - 3d53e806\/simplescreenrecorder-2023-10-08_04.15.21.mkv"}],"mentions":[{"@id":"https:\/\/elab.local:3148\/database.php?mode=view&id=51"},{"@id":"https:\/\/elab.local:3148\/database.php?mode=view&id=50"},{"@id":"https:\/\/elab.local:3148\/database.php?mode=view&id=159"},{"@id":"https:\/\/elab.local:3148\/experiments.php?mode=view&id=256"},{"@id":"https:\/\/elab.local:3148\/experiments.php?mode=view&id=257"},{"@id":"https:\/\/elab.local:3148\/experiments.php?mode=view&id=258"}]},{"@id":".\/","@type":["Dataset"],"hasPart":[{"@id":".\/2025-03-03 - Testing-the-eLabFTW-lab-notebook - 3d53e806"}]},{"@id":"person:\/\/a0568e4aa35eec2cf3962db57eec039a205d3b7d7c7132388af976dfaf8f2694?hash_algo=sha256","@type":"Person","familyName":"Le sysadmin","givenName":"Toto"}]}
Loading

0 comments on commit 43c3b0b

Please sign in to comment.