Updated JS dependencies; fixed the problem with pluggable extensions.

This commit is contained in:
Simon Brooke 2022-01-07 11:59:53 +00:00
parent 9f66ccf6ab
commit 96fa9c7033
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
7 changed files with 55 additions and 44 deletions

View file

@ -54,15 +54,15 @@
[lein-npm "0.6.2"]
[lein-ring "0.12.5" :exclusions [org.clojure/clojure]]]
:npm {:dependencies [[simplemde "1.11.2"]
[vega "5.9.0"]
[vega-embed "6.2.2"]
[vega-lite "4.1.1"]
[mermaid "8.4.6"]
:npm {:dependencies [[geocsv-js "simon-brooke/geocsv-js#3a34ba7"]
[mermaid "8.13.8"]
[photoswipe "4.1.3"]
[simplemde "1.11.2"]
[showdown "1.9.1"]
[tablesort "5.2.0"]
[geocsv-js "simon-brooke/geocsv-js#3a34ba7"]]
[tablesort "5.3.0"]
[vega "5.21.0"]
[vega-embed "6.20.5"]
[vega-lite "5.2.0"]]
:root "resources/public/vendor"}
:docker {:image-name "simonbrooke/smeagol"

View file

@ -146,7 +146,9 @@ followed by three backticks on a line by themselves. There is an [[Example galle
## Writing your own custom formatters
A custom formatter is simply a Clojure function which takes a string and an integer as arguments and produces a string as output. The string is the text the user has typed into their markdown; the integer is simply a number you can use to keep track of which addition to the page this is, in order, for example, to fix up some JavaScript to render it.
A custom formatter is simply a Clojure function which takes a string and an integer as arguments and produces a string as output. The string argument is the text the user has typed into their markdown; the integer is simply a number you can use to keep track of which addition to the page this is, in order, for example, to fix up some JavaScript to render it.
The string returned should just be the necessary HTML text to add to the page to invoke the formatter.
For example, here's the formatter which handles the Vega charts:
@ -166,6 +168,10 @@ For example, here's the formatter which handles the Vega charts:
index
");\n//]]\n</script>"))
In order to allow pluggable extensions -- that is, extensions which are not compiled as part of Smeagol but are added as additional classes on the classpath at run time -- every extension function must be written in a namespace which has the `(:gen-class)` directive.
In principal it should be possible to write extensions in Java, or in other languages which compile for the JVM, but this has not yet been demonstrated.
### Configuring Smeagol to use your formatter
To add your own formatter, compile it into a jar file which is on the classpath - it does *not* have to be part of the Smeagol project directly - and then edit the value of the key `:formatters` in the file `config.edn`; whose standard definition is:

View file

@ -3,7 +3,8 @@
smeagol.extensions.geocsv
(:require [smeagol.configuration :refer [config]]
[smeagol.extensions.utils :refer [resource-url-or-data->data]]
[taoensso.timbre :as log]))
[taoensso.timbre :as log])
(:gen-class))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;

View file

@ -2,7 +2,8 @@
:author "Simon Brooke"}
smeagol.extensions.mermaid
(:require [smeagol.extensions.utils :refer [resource-url-or-data->data]]
[taoensso.timbre :as log]))
[taoensso.timbre :as log])
(:gen-class))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;

View file

@ -14,7 +14,8 @@
[smeagol.configuration :refer [config]]
[smeagol.extensions.utils :refer [resource-url-or-data->data uploaded?]]
[smeagol.util :refer [content-dir upload-dir]]
[taoensso.timbre :as log]))
[taoensso.timbre :as log])
(:gen-class))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
@ -155,7 +156,7 @@
{:slides (map
process-simple-slide
(simplify (simple-grammar spec)))
:options { :timeToIdle 100 }
:options {:timeToIdle 100}
:openImmediately true}) index))))

View file

@ -1,6 +1,7 @@
(ns ^{:doc "Very simple extension for testing the extension processing flow."
:author "Simon Brooke"}
smeagol.extensions.test)
smeagol.extensions.test
(:gen-class))
(def process-test-return-value "<!-- The test extension has run and this is its output -->")

View file

@ -2,7 +2,8 @@
:author "Simon Brooke"}
smeagol.extensions.vega
(:require [smeagol.extensions.utils :refer [resource-url-or-data->data yaml->json]]
[taoensso.timbre :as log]))
[taoensso.timbre :as log])
(:gen-class))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;