diff --git a/.gitignore b/.gitignore
index cf11b31..98bc2f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+.clj-kondo/
+.lsp/
/target
/lib
/classes
@@ -5,12 +7,17 @@
pom.xml
*.jar
*.class
+/.calva/
/.lein-*
/.env
*.log
+.nrepl-port
+
# Links to other places:
resources/public/docs/mw-*/uberdoc.html
# Artefacts:
mw_ui.log
pom.xml
+
+buildall.tmp.*/
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..afcd747
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,3 @@
+FROM tomcat:alpine
+COPY target/microworld.war $CATALINA_HOME/webapps/
+
diff --git a/README.md b/README.md
index 2e99c39..68bca8d 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,13 @@
-## Part of the overall MicroWorld system
+## Part of the overall Microworld system
*mw-ui* is not a stand-alone project. To use it you also need at least
[mw-parser](https://github.com/simon-brooke/mw-parser) and
[mw-engine](https://github.com/simon-brooke/mw-engine). There will be other
modules in due course.
-You can see MicroWorld in action [here](http://www.journeyman.cc/microworld/) -
-but please don't be mean to my poor little server. If you want to run big maps
-or complex rule-sets, please run it on your own machines.
-
## What this is about
-
+
MicroWorld is a rule driven cellular automaton. What does that mean? Well, it's
a two dimensional world made up of squares called **cells**. The world develops
in steps, and at each step, each cell is modified by applying the rules.
diff --git a/docs/cloverage/coverage.css b/docs/cloverage/coverage.css
new file mode 100644
index 0000000..2be4e57
--- /dev/null
+++ b/docs/cloverage/coverage.css
@@ -0,0 +1,40 @@
+.covered {
+ font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
+ background-color: #558B55;
+}
+
+.not-covered {
+ font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
+ background-color: red;
+}
+
+.partial {
+ font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
+ background-color: orange;
+}
+
+.not-tracked {
+ font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
+}
+
+.blank {
+ font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
+}
+
+td {
+ padding-right: 10px;
+}
+
+td.with-bar {
+ width: 250px;
+ text-align: center;
+}
+
+td.with-number {
+ text-align: right;
+}
+
+td.ns-name {
+ min-width: 150px;
+ padding-right: 25px;
+}
diff --git a/docs/cloverage/index.html b/docs/cloverage/index.html
new file mode 100644
index 0000000..bab5f30
--- /dev/null
+++ b/docs/cloverage/index.html
@@ -0,0 +1,200 @@
+
+
\ No newline at end of file
diff --git a/docs/codox/mw-ui.layout.html b/docs/codox/mw-ui.layout.html
new file mode 100644
index 0000000..bad5643
--- /dev/null
+++ b/docs/codox/mw-ui.layout.html
@@ -0,0 +1,6 @@
+
+mw-ui.layout documentation
\ No newline at end of file
diff --git a/docs/codox/mw-ui.middleware.html b/docs/codox/mw-ui.middleware.html
new file mode 100644
index 0000000..38a30bd
--- /dev/null
+++ b/docs/codox/mw-ui.middleware.html
@@ -0,0 +1,8 @@
+
+mw-ui.middleware documentation
\ No newline at end of file
diff --git a/docs/codox/mw-ui.render-world.html b/docs/codox/mw-ui.render-world.html
new file mode 100644
index 0000000..768d6e6
--- /dev/null
+++ b/docs/codox/mw-ui.render-world.html
@@ -0,0 +1,11 @@
+
+mw-ui.render-world documentation
\ No newline at end of file
diff --git a/docs/codox/mw-ui.repl.html b/docs/codox/mw-ui.repl.html
new file mode 100644
index 0000000..e5abb24
--- /dev/null
+++ b/docs/codox/mw-ui.repl.html
@@ -0,0 +1,9 @@
+
+mw-ui.repl documentation
\ No newline at end of file
diff --git a/docs/codox/mw-ui.routes.home.html b/docs/codox/mw-ui.routes.home.html
new file mode 100644
index 0000000..264ea33
--- /dev/null
+++ b/docs/codox/mw-ui.routes.home.html
@@ -0,0 +1,12 @@
+
+mw-ui.routes.home documentation
\ No newline at end of file
diff --git a/docs/codox/mw-ui.routes.load.html b/docs/codox/mw-ui.routes.load.html
new file mode 100644
index 0000000..756f03b
--- /dev/null
+++ b/docs/codox/mw-ui.routes.load.html
@@ -0,0 +1,7 @@
+
+mw-ui.routes.load documentation
Route which handles the upload of worlds/rules from the client.
+
load-page
(load-page)(load-page request)
If no args, show the load form; with args, load a world file from the client.
+
NOTE that this reads a Clojure form from an untrusted client and should almost certainly NOT be enabled on a public-facing site, especially not on the Internet.
\ No newline at end of file
diff --git a/docs/codox/mw-ui.routes.params.html b/docs/codox/mw-ui.routes.params.html
new file mode 100644
index 0000000..2c1556e
--- /dev/null
+++ b/docs/codox/mw-ui.routes.params.html
@@ -0,0 +1,5 @@
+
+mw-ui.routes.params documentation
Route which serves and handles the parameters page.
+
params-page
(params-page)(params-page request)
Handler for params request. If no request passed, show empty params form. If request is passed, put parameters from request into session and show the world page.
\ No newline at end of file
diff --git a/docs/codox/mw-ui.routes.rules.html b/docs/codox/mw-ui.routes.rules.html
new file mode 100644
index 0000000..7b9b966
--- /dev/null
+++ b/docs/codox/mw-ui.routes.rules.html
@@ -0,0 +1,7 @@
+
+mw-ui.routes.rules documentation
Request handler for the rules request. If the request contains a value for :src, treat that as rule source and try to compile it. If compilation succeeds, stash the compiled rules and the rule text on the session, and provide feedback; if not, provide feedback.
+
If request doesn’t contain a value for :src, load basic rule source from the session or from resources/rulesets/basic.txt and pass that back.
\ No newline at end of file
diff --git a/docs/codox/mw-ui.routes.save.html b/docs/codox/mw-ui.routes.save.html
new file mode 100644
index 0000000..beb4720
--- /dev/null
+++ b/docs/codox/mw-ui.routes.save.html
@@ -0,0 +1,5 @@
+
+mw-ui.routes.save documentation
Route which handles the saving of world state the client.
+
save-page
(save-page)
Save the current world to the browser, using our own custom mime-type in an attempt to prevent the browser trying to do anything clever with it. Note that it is saved as a raw Clojure data structure, not as XML or any proprietary format.
\ No newline at end of file
diff --git a/docs/codox/mw-ui.util.html b/docs/codox/mw-ui.util.html
new file mode 100644
index 0000000..eb2a009
--- /dev/null
+++ b/docs/codox/mw-ui.util.html
@@ -0,0 +1,9 @@
+
+mw-ui.util documentation
The resources which were visible at compile time. If we are running from a JAR file, it is highly likely that these are all the resources available at run time.
\ No newline at end of file
diff --git a/docs/uberdoc.html b/docs/uberdoc.html
new file mode 100644
index 0000000..4d7c64b
--- /dev/null
+++ b/docs/uberdoc.html
@@ -0,0 +1,3690 @@
+
+mw-ui -- Marginalia
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+
Copyright (C) 2014 Simon Brooke
+
+
(defn format-css-class [statekey]
+ "Format this statekey, assumed to be a keyword indicating a state in the
+ world, into a CSS class"
+ (subs (str statekey) 1))
Render this statekey, assumed to be a keyword indicating a state in the
+ world, into a path which should recover the corresponding image file.
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+
Copyright (C) 2014 Simon Brooke
+
+
(defonce server (atom nil))
+
(defn get-handler []
+ ;; #'app expands to (var app) so that when we reload our code,
+ ;; the server is forced to re-resolve the symbol in the var
+ ;; rather than having its own copy. When the root binding
+ ;; changes, the server picks it up without having to restart.
+ (-> #'app
+ ; Makes static assets in $PROJECT_DIR/resources/public/ available.
+ (wrap-file "resources")
+ ; Content-Type, Content-Length, and Last Modified headers for files in body
+ (wrap-file-info)))
used for starting the server in development mode from REPL
+
(defn start-server
+ [& [port]]
+ (let [port (if port (Integer/parseInt port) 3000)]
+ (reset! server
+ (serve (get-handler)
+ {:port port
+ :init init
+ :auto-reload? true
+ :destroy destroy
+ :join? false}))
+ (println (str "You can view the site at http://localhost:" port))))
+
(defn stop-server []
+ (.stop @server)
+ (reset! server nil))
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
(defn world-page []
+ "Render the world in the current session (or a default one if none)."
+ (layout/render "trusted-content.html"
+ {:title "Watch your world grow"
+ :world-selected "active"
+ :content (html (world/render-world-table))
+ :pause (or (session/get :pause) 5)
+ :maybe-refresh "refresh"}))
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+
Copyright (C) 2014 Simon Brooke
+
+
(defn- upload [file]
+ (io/upload-file "/tmp/" file)
+ (cond
+ (session/put! :world
+ (with-open [eddi (java.io.FileReader. (:tempfile file))] (read)))
+ (str "Successfully loaded your world from " (:filename file))))
If no args, show the load form; with args, load a world file from the client.
+
+
NOTE that this reads a Clojure form from an untrusted client and should almost
+ certainly NOT be enabled on a public-facing site, especially not on the Internet.
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
Handler for params request. If no request passed, show empty params form.
+ If request is passed, put parameters from request into session and show
+ the world page.
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
Request handler for the rules request. If the request contains a value
+ for :src, treat that as rule source and try to compile it. If compilation
+ succeeds, stash the compiled rules and the rule text on the session, and
+ provide feedback; if not, provide feedback.
+
+
If request doesn't contain a value for :src, load basic rule source from
+ the session or from resources/rulesets/basic.txt and pass that back.
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+
Copyright (C) 2014 Simon Brooke
+
+
(defn save-page []
+ "Save the current world to the browser, using our own custom mime-type in
+ an attempt to prevent the browser trying to do anything clever with it.
+ Note that it is saved as a raw Clojure data structure, not as XML or
+ any proprietary format."
+ (response/content-type
+ "application/journeyman-mwm; charset=utf-8"
+ (with-out-str (pretty/pprint (session/get :world)))))
mw-ui: a servlet user/visualisation interface for MicroWorld.
+
+
This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+
You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+
Copyright (C) 2014 Simon Brooke
+
reads a markdown file from public/md and returns an HTML string