No idea whether or not this is progress.

This commit is contained in:
Simon Brooke 2021-12-10 12:44:48 +00:00
parent c673b3e134
commit 73c71e4df0
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
3 changed files with 13 additions and 12 deletions

View file

@ -32,7 +32,6 @@
(def template-path "templates/")
(deftype RenderableTemplate [template params]
Renderable
(render [_ request]

View file

@ -1,12 +1,9 @@
(ns ^{:doc "Render the state of the world as an HTML table."
:author "Simon Brooke"}
mw-ui.render-world
(:require [clojure.java.io :as jio]
[mw-engine.core :as engine]
[mw-engine.world :as world]
(:require [mw-engine.core :as engine]
[mw-engine.heightmap :as heightmap]
[mw-parser.bulk :as compiler]
[hiccup.core :refer [html]]
[noir.io :as io]
[noir.session :as session]))

View file

@ -31,18 +31,22 @@
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def running-from-filesystem (atom true))
(def running-from-filesystem
"We assume we're running from the filesystem unless we find we're not."
(atom true))
(def compile-time-resources
"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."
(let [n (count (io/resource-path))]
(let [f (file "resources/public")
n (count (.getCanonicalPath f))]
(remove nil?
(map #(let [s (str %)]
(map #(let [s (.getCanonicalPath %)]
(when (> (count s) n)
(subs s 56)))
(file-seq (file (io/resource-path)))))))
(subs s n)))
(file-seq f)))))
(defn md->html
@ -57,11 +61,12 @@
"Do the same processing that list-resources does on names fetched from
the file system, except on the resource list cached at compile time."
[path pattern]
(timbre/info compile-time-resources)
(let [n (count path)]
(remove nil?
(map #(when (> (count %) n)
(let [name (subs % n)]
(first (rest (re-matches pattern name)))))
(last (re-matches pattern name))))
(filter #(starts-with? % path)
compile-time-resources)))))