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/") (def template-path "templates/")
(deftype RenderableTemplate [template params] (deftype RenderableTemplate [template params]
Renderable Renderable
(render [_ request] (render [_ request]

View file

@ -1,12 +1,9 @@
(ns ^{:doc "Render the state of the world as an HTML table." (ns ^{:doc "Render the state of the world as an HTML table."
:author "Simon Brooke"} :author "Simon Brooke"}
mw-ui.render-world mw-ui.render-world
(:require [clojure.java.io :as jio] (:require [mw-engine.core :as engine]
[mw-engine.core :as engine]
[mw-engine.world :as world]
[mw-engine.heightmap :as heightmap] [mw-engine.heightmap :as heightmap]
[mw-parser.bulk :as compiler] [mw-parser.bulk :as compiler]
[hiccup.core :refer [html]]
[noir.io :as io] [noir.io :as io]
[noir.session :as session])) [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 (def compile-time-resources
"The resources which were visible at compile time. If we are running from "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 a JAR file, it is highly likely that these are all the resources available
at run time." at run time."
(let [n (count (io/resource-path))] (let [f (file "resources/public")
n (count (.getCanonicalPath f))]
(remove nil? (remove nil?
(map #(let [s (str %)] (map #(let [s (.getCanonicalPath %)]
(when (> (count s) n) (when (> (count s) n)
(subs s 56))) (subs s n)))
(file-seq (file (io/resource-path))))))) (file-seq f)))))
(defn md->html (defn md->html
@ -57,12 +61,13 @@
"Do the same processing that list-resources does on names fetched from "Do the same processing that list-resources does on names fetched from
the file system, except on the resource list cached at compile time." the file system, except on the resource list cached at compile time."
[path pattern] [path pattern]
(timbre/info compile-time-resources)
(let [n (count path)] (let [n (count path)]
(remove nil? (remove nil?
(map #(when (> (count %) n) (map #(when (> (count %) n)
(let [name (subs % n)] (let [name (subs % n)]
(first (rest (re-matches pattern name))))) (last (re-matches pattern name))))
(filter #(starts-with? % path) (filter #(starts-with? % path)
compile-time-resources))))) compile-time-resources)))))