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/")
|
(def template-path "templates/")
|
||||||
|
|
||||||
|
|
||||||
(deftype RenderableTemplate [template params]
|
(deftype RenderableTemplate [template params]
|
||||||
Renderable
|
Renderable
|
||||||
(render [_ request]
|
(render [_ request]
|
||||||
|
|
|
@ -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]))
|
||||||
|
|
||||||
|
|
|
@ -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,11 +61,12 @@
|
||||||
"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)))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue