No idea whether or not this is progress.
This commit is contained in:
parent
c673b3e134
commit
73c71e4df0
|
@ -32,7 +32,6 @@
|
|||
|
||||
(def template-path "templates/")
|
||||
|
||||
|
||||
(deftype RenderableTemplate [template params]
|
||||
Renderable
|
||||
(render [_ request]
|
||||
|
|
|
@ -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]))
|
||||
|
||||
|
|
|
@ -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,12 +61,13 @@
|
|||
"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)))))
|
||||
(filter #(starts-with? % path)
|
||||
(last (re-matches pattern name))))
|
||||
(filter #(starts-with? % path)
|
||||
compile-time-resources)))))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue