Skip to content

Commit

Permalink
Upgrade to latest clerk-utils, add template (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
sritchie committed Feb 20, 2023
1 parent 50f0f20 commit d749a5f
Show file tree
Hide file tree
Showing 37 changed files with 2,496 additions and 2,386 deletions.
10 changes: 8 additions & 2 deletions .clj-kondo/nextjournal/clerk/config.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{:config-in-call {nextjournal.clerk.viewer/->viewer-fn {:linters {:unresolved-symbol {:exclude [clj->js]}
:unresolved-namespace {:exclude [js]}}}
:unresolved-namespace {:exclude [nextjournal.clerk.render
nextjournal.clerk.render.code
nextjournal.clerk.render.hooks
js]}}}
nextjournal.clerk.viewer/->viewer-eval {:linters {:unresolved-symbol {:exclude [clj->js]}
:unresolved-namespace {:exclude [js]}}}}
:unresolved-namespace {:exclude [nextjournal.clerk.render
nextjournal.clerk.render.code
nextjournal.clerk.render.hooks
js]}}}}
:hooks {:analyze-call {nextjournal.clerk.viewer/->viewer-fn nextjournal.clerk.viewer/->viewer-fn
nextjournal.clerk.viewer/->viewer-eval nextjournal.clerk.viewer/->viewer-fn}}
:lint-as {nextjournal.clerk/defcached clojure.core/def}}
16 changes: 12 additions & 4 deletions .clj-kondo/org.mentat/clerk-utils/config.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{:config-in-call
{mentat.clerk-utils/cljs
{:linters {:unresolved-symbol {:level :off}
:unresolved-namespace {:level :off}}}}}
{:lint-as
{mentat.clerk-utils/->clerk clojure.test/do
mentat.clerk-utils/->clerk-only clojure.test/do}
:config-in-call
{mentat.clerk-utils.show/show-sci
{:linters
{:unresolved-symbol {:level :off}
:unresolved-namespace {:level :off}}}
mentat.clerk-utils.show/show-cljs
{:linters
{:unresolved-symbol {:level :off}
:unresolved-namespace {:level :off}}}}}
20 changes: 8 additions & 12 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,17 @@ jobs:
steps:
- uses: actions/cache@v3
with:
path: |
.cpcache
.shadow-cljs
~/.m2
key: "1"
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/deps.edn') }}
restore-keys: ${{ runner.os }}-m2

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

- name: Install clojure tools
uses: DeLaGuardo/[email protected]
with:
# Install just one or all simultaneously
cli: 1.10.3.1087 # Clojure CLI based on tools.deps
# (optional) To avoid rate limit errors please provide github token
cli: latest
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install babashka
Expand All @@ -32,11 +29,10 @@ jobs:
version: '0.8.156'

- name: Build static site
run: bb publish-gh-pages
run: bb build-static

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_dir: ./public/build
27 changes: 4 additions & 23 deletions .github/workflows/kondo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- uses: DeLaGuardo/setup-clojure@master
- name: Install babashka
uses: just-sultanov/setup-babashka@v2
with:
cli: latest

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '17'

- name: Install clj-kondo
run: sudo ./bin/install-clj-kondo

- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/deps.edn') }}
restore-keys: ${{ runner.os }}-m2

- name: Install dependencies
run: clojure -P -M:dev:lint
version: '0.8.156'

- name: Cache kondo directory
uses: actions/cache@v2
Expand All @@ -43,5 +25,4 @@ jobs:
restore-keys: ${{ runner.os }}-kondo

- name: Run clj-kondo
run: |
clj-kondo --lint src:dev --config '{:output {:pattern "::{{level}} file={{filename}},line={{row}},col={{col}}::{{message}}"}}'
run: bb lint --config '{:output {:pattern "::{{level}} file={{filename}},line={{row}},col={{col}}::{{message}}"}}'
35 changes: 34 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,40 @@

## [unreleased]

- #31 moves the library to the official JSXGraph 1.5.0 release, off of the mentat-collective fork.
## [0.2.0]

- #32:

- fixes issue where id must start with a letter

- Adds a `deps-new` template that sets up a basic Clerk project with
`JSXGraph.cljs` installed as a dependency. [The template lives
here](https://github.com/mentat-collective/JSXGraph.cljs/tree/main/resources/jsxgraph/clerk).

- Adds a `provided` dependency on SCI to `pom.xml`, so that cljdoc builds
succeed.

- Adds `jsxgraph.sci` with SCI namespace objects for all namespaces, plus a
`namespaces` map and a `config` for easy installation into SCI. The
namespaces follows the patterns set by the
https://github.com/babashka/sci.configs repo.

- `jsxgraph.sci/install!` allows the user to install `JSXGraph.cljs` into
SCI's shared context with one mutating call.

- Migrates the project over to `clerk-utils` and all of its new custom build
stuff. This let me simplify development, update the README and DEVELOPING
pages and kill my shadow-cljs.edn file. `user.clj` gets quite a bit simpler
too.

- Adds notes to the interactive docs guide about using the library with SCI
and with Clerk

- Upgrades to Clerk version `fad499407d979916d21b33cc7e46e73f7a485e37` for the
template and project docs notebook

- #31 moves the library to the official JSXGraph 1.5.0 release, off of the
mentat-collective fork.

- #29:

Expand Down
33 changes: 16 additions & 17 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Dev Dependencies

`clj`, `shadow-cljs`, `node` and `babashka`.
- [node.js](https://nodejs.org/en/)
- The [clojure command line tool](https://clojure.org/guides/install_clojure)
- [Babashka](https://github.com/babashka/babashka#installation)

## Github Pages, Docs Notebook

Expand All @@ -10,29 +12,28 @@ the library's use.

### Local Notebook Dev

To start a shadow-cljs process watcher for the JS required to run the Clerk
notebook, run
Start a Clojure process however you like, and run `(user/serve!)` to run the
Clerk server. This command should open up `localhost:7777`.

```
bb dev-notebook
```
Alternatively, run

Then start a Clojure process however you like, and run `(user/start!)` to run
the Clerk server. This command should open up `localhost:7777`.
```sh
bb clerk-watch
```

### Github Pages Static Build
### Static Build

To test the Pages build locally:
To test the static build locally:

```
bb publish-local
```

This will generate the static site in `public`, start a development http server
and open up a browser window (http://127.0.0.1:8080/) with the production build
of the documentation notebook.
This will generate the static site in `public/build`, start a development http
server and open up a browser window (http://127.0.0.1:8080/) with the production
build of the documentation notebook.

### Pages Build
### GitHub Pages

To build and release to Github Pages:

Expand Down Expand Up @@ -66,9 +67,7 @@ The new release will appear on Clojars.

## Linting

Code is linted with `clj-kondo`. [Install
`clj-kondo`](https://github.com/clj-kondo/clj-kondo/blob/master/doc/install.md)
then run
Code is linted with [`clj-kondo`](https://github.com/clj-kondo/clj-kondo):

```
bb lint
Expand Down
76 changes: 46 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
# JSXGraph.cljs

[![Build Status](https://github.com/mentat-collective/jsxgraph.cljs/actions/workflows/kondo.yml/badge.svg?branch=main)](https://github.com/mentat-collective/jsxgraph.cljs/actions/workflows/kondo.yml)
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/mentat-collective/jsxgraph.cljs/blob/main/LICENSE)
[![cljdoc badge](https://cljdoc.org/badge/org.mentat/jsxgraph.cljs)](https://cljdoc.org/d/org.mentat/jsxgraph.cljs/CURRENT)
[![Clojars Project](https://img.shields.io/clojars/v/org.mentat/jsxgraph.cljs.svg)](https://clojars.org/org.mentat/jsxgraph.cljs)
[![Build Status][build-status]][build-status-url]
[![License][license]][license-url]
[![cljdoc badge][cljdoc]][cljdoc-url]
[![Clojars Project][clojars]][clojars-url]
[![Discord Shield][discord]][discord-url]

[JSXGraph][JSXGraph] is a JavaScript library that lets you build 2-dimensional
scenes full of geometric objects, function curves and interactive UI elements,
potentially with many complex constraints defined between these objects.
[JSXGraph][jsxgraph-url] is a JavaScript library that lets you build
2-dimensional scenes full of geometric objects, function curves and interactive
UI elements, potentially with many complex constraints defined between these
objects.

[JSXGraph.cljs](https://github.com/mentat-collective/jsxgraph.cljs) extends
JSXGraph with a [React][REACT] / [Reagent][REAGENT] component that makes it easy to define
JSXGraph constructions inside of a user interface built with Clojurescript.
[JSXGraph.cljs][github-url] extends JSXGraph with a [React][react-url] /
[Reagent][reagent-url] component that makes it easy to define JSXGraph
constructions inside of a user interface built with Clojurescript.

## Quickstart

Install `jsxgraph.cljs` into your Clojurescript project using the instructions
Install `JSXGraph.cljs` into your Clojurescript project using the instructions
at its Clojars page:

[![Clojars Project](https://img.shields.io/clojars/v/org.mentat/jsxgraph.cljs.svg)](https://clojars.org/org.mentat/jsxgraph.cljs)
[![Clojars Project][clojars]][clojars-url](https://clojars.org/org.mentat/jsxgraph.cljs)

Require `jsxgraph.core` in your namespace:

Expand Down Expand Up @@ -61,31 +63,32 @@ If you run into trouble, [see the `canvas` docs page on
compilation](https://github.com/Automattic/node-canvas#compiling) for
instructions on how to install the dependencies for this process.

## Clerk Support

If you want to use `JSXGraph.cljs` with [Clerk][clerk-url], check out the
[`jsxgraph/clerk` template][jsxgraph-clerk-template-url]. This
[`deps-new`][deps-new-url] template will generate a Clerk project for you, fully
configured to use `JSXGraph.cljs` in your Clerk notebooks.

## Interactive Documentation via Clerk

The project's [interactive documentation](https://jsxgraph.mentat.org) was
generated using Nextjournal's [Clerk](https://github.com/nextjournal/clerk). If
generated using Nextjournal's [Clerk][clerk-url]. If
you'd like to edit or play with the documentation, you'll need to install

- [node.js](https://nodejs.org/en/)
- The [clojure command line tool](https://clojure.org/guides/install_clojure)
- [Babashka](https://github.com/babashka/babashka#installation)

Once this is done, run this command in one terminal window to build and serve the custom JS required by the notebook:
Once this is done, run this command:

```
bb dev-notebook
```

In another terminal window, run

```
bb start-clerk
```sh
bb clerk-watch
```

This should open a browser window to `http://localhost:7777` with the contents
of the documentation notebook. Any edits you make to `dev/jsxgraph/notebook.clj`
will be picked up and displayed in the browser on save.
This will open a browser window to `http://localhost:7777` with the contents of
the documentation notebook. Any edits you make to `dev/jsxgraph/notebook.clj` will
be picked up and displayed in the browser on save.

## Thanks and Support

Expand All @@ -100,11 +103,24 @@ projects like it.

## License

Copyright © 2022 Sam Ritchie.
Copyright © 2022-2023 Sam Ritchie.

Distributed under the [MIT License](LICENSE). See [LICENSE](LICENSE).

[CLJS]: https://clojurescript.org/
[JSXGRAPH]: https://jsxgraph.org/
[REACT]: https://reactjs.org/
[REAGENT]: https://reagent-project.github.io/
[build-status-url]: https://github.com/mentat-collective/jsxgraph.cljs/actions/workflows/kondo.yml
[build-status]: https://github.com/mentat-collective/jsxgraph.cljs/actions/workflows/kondo.yml/badge.svg?branch=main
[cljdoc-url]: https://cljdoc.org/d/org.mentat/jsxgraph.cljs/CURRENT
[cljdoc]: https://cljdoc.org/badge/org.mentat/jsxgraph.cljs
[clojars-url]: https://clojars.org/org.mentat/jsxgraph.cljs
[clojars]: https://img.shields.io/clojars/v/org.mentat/jsxgraph.cljs.svg
[discord-url]: https://discord.gg/hsRBqGEeQ4
[discord]: https://img.shields.io/discord/731131562002743336?style=flat&colorA=000000&colorB=000000&label=&logo=discord
[license-url]: LICENSE
[license]: https://img.shields.io/badge/license-MIT-brightgreen.svg
[github-url]: https://github.com/mentat-collective/jsxgraph.cljs
[jsxgraph-url]: https://jsxgraph.org/
[react-url]: https://reactjs.org/
[reagent-url]: https://reagent-project.github.io
[deps-new-url]: https://github.com/seancorfield/deps-new
[jsxgraph-clerk-template-url]: https://github.com/mentat-collective/jsxgraph.cljs/tree/main/resources/jsxgraph/clerk
[clerk-url]: https://clerk.vision
Loading

0 comments on commit d749a5f

Please sign in to comment.