diff --git a/.codespellignore b/.codespellignore new file mode 100644 index 0000000..c018b9d --- /dev/null +++ b/.codespellignore @@ -0,0 +1 @@ +sade diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..5984f44 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,9 @@ +[codespell] +skip = + *.po, + *.ts, + tests/* +count = +quiet-level = 3 +ignore-words-list = + cips diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6e092a3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# EditorConfig: https://EditorConfig.org. Provides sensible defaults for +# non vscode editors. + +# top-most EditorConfig file +root = true + +# Every file. +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true + +indent_style = space +indent_size = 4 + +trim_trailing_whitespace = true diff --git a/.github/workflows/.pre-commit.yml b/.github/workflows/.pre-commit.yml new file mode 100644 index 0000000..03a2abb --- /dev/null +++ b/.github/workflows/.pre-commit.yml @@ -0,0 +1,15 @@ +--- +name: pre-commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.0 diff --git a/.gitignore b/.gitignore index 79518f7..915b023 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ Thumbs.db # Vite vite.config.js.timestamp-* vite.config.ts.timestamp-* + +# PNPM +package-lock.json diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..55127f1 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,15 @@ + +--- +default: true + +# Exceptions, example given, MD045 +# MD045: false # allow image with no tag + +# In-line HTML. +MD033: false +# Line lengths +MD013: + line_length: 80 + tables: false +# First line in a file should be a top-level heading +MD041: false diff --git a/.markdownlintignore b/.markdownlintignore new file mode 100644 index 0000000..4836046 --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1,3 @@ +drafts/* +LICENSE.md +SECURITY.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..89cec38 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-yaml + - id: check-json + - id: check-toml + - id: end-of-file-fixer + exclude: ".svg" + - id: trailing-whitespace + - id: check-case-conflict +- repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.42.0 + hooks: + - id: markdownlint +- repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: [-I .codespellignore] diff --git a/README.md b/README.md index 54aac05..6c9df67 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,40 @@ # Orcfax Archive Viewer -Orcfax Archive Viewer is a Svelte app that compiles everything needed to explore a single Orcfax Fact Statement archive from Arweave into a single static `index.html` file that is intended to be used locally and offline. +Orcfax Archive Viewer is a Svelte app that compiles everything needed to explore +a single Orcfax Fact Statement archive from Arweave into a single static +`index.html` file that is intended to be used locally and offline. -The compiled static `index.html` file is packaged along with the [Orcfax Explorer](https://github.com/orcfax/explorer.orcfax.io) as a static asset so that it can be downloaded and packaged along with a full Fact Statement archive folder which is fetched from Arweave. +The compiled static `index.html` file is packaged along with the +[Orcfax Explorer](https://github.com/orcfax/explorer.orcfax.io) as a static +asset so that it can be downloaded and packaged along with a full Fact Statement +archive folder which is fetched from Arweave. -The viewer does not access the folder of archived files directly, instead, on download from the Explorer, a JSON representation of the archive's contents are injected into a global window variable so it can be used internally. +The viewer does not access the folder of archived files directly, instead, on +download from the Explorer, a JSON representation of the archive's contents are +injected into a global window variable so it can be used internally. An example JSON file is included in the repo for local development purposes. ## Developing -Once you've cloned the repo and installed dependencies with `pnpm i`, start a development server: +Clone the repository and install the dependencies: -```bash -pnpm run dev +```sh +git clone git@github.com:orcfax/orcfax-archive-viewer.git +cd orcfax-archive-viewer +pnpm i ``` -To run the viewer with local test data, copy the contents of `example-archive.json` and paste it in place of `'DATA_PLACEHOLDER'` at the bottom of `/index.html` located at the project's root. - ## Building -Before creating a new build, it is recommended to run formatting and linting first: +To run the viewer with local test data, copy the contents of +`example-archive.json` and paste it in place of `'DATA_PLACEHOLDER'` (NB. +replace the single-quotation marks as well) at the bottom of `/index.html` +located at the root of this repository. + +Once you have replaced the `'DATA_PLACEHOLDER'` (including quotes) it is +recommended to run formatting and linting first. This will prettify the source +data. ```bash pnpm run format @@ -33,4 +47,16 @@ To create a new production version of the viewer, run: pnpm run build ``` -After building, you will see `index.html` under the build folder. The contents of this file are then to be copied and pasted over the contents of `/static/archive-viewer.html` in the [Explorer](https://github.com/orcfax/explorer.orcfax.io/blob/main/static/archive-viewer.html). +After building, you will find `index.html` under the build folder. + +## Viewing + +Start a development server with: + +```bash +pnpm run dev +``` + +The local archive will be visible at the server location and port on your +localhost, e.g. `http://:/`. Alternatively, open the +`build/index.html` file in your choice of web-browser. diff --git a/justfile b/justfile new file mode 100644 index 0000000..bac11b7 --- /dev/null +++ b/justfile @@ -0,0 +1,20 @@ +ROOT := `git rev-parse --show-toplevel` +# Get help +help: + just -l + +# (Re-)build the glossary +build: + node {{ROOT}}/builder/index.js --input {{ROOT}}/content > {{ROOT}}/docs/index.html + +# Run all pre-commit checks +all-checks: + pre-commit run --all-files + +# Run pre-commit spelling check +spell: + pre-commit run codespell --all-files + +# Run pre-commit makdown-lint +markdown: + pre-commit run markdownlint --all-files