Substantial modification of how pages which are mainly generated content are
handled. I had ended up with four '.html' files which were essentially identical. Also work on new editable parameters feature.
This commit is contained in:
parent
ea1af2103f
commit
6618fded9d
7 changed files with 19 additions and 28 deletions
|
|
@ -1,6 +1,7 @@
|
|||
(ns mw-ui.routes.home
|
||||
(:use compojure.core
|
||||
[mw-ui.routes.rules :as rules])
|
||||
[mw-ui.routes.rules :as rules]
|
||||
[mw-ui.routes.params :as params])
|
||||
(:require [hiccup.core :refer [html]]
|
||||
[mw-ui.layout :as layout]
|
||||
[mw-ui.util :as util]
|
||||
|
|
@ -8,17 +9,17 @@
|
|||
[noir.session :as session]))
|
||||
|
||||
(defn home-page []
|
||||
(layout/render "home.html" {:title "Welcome to MicroWorld"
|
||||
(layout/render "trusted-content.html" {:title "Welcome to MicroWorld"
|
||||
:content (util/md->html "/md/mw-ui.md")}))
|
||||
|
||||
(defn world-page []
|
||||
(layout/render "world.html" {:title "Watch your world grow"
|
||||
(layout/render "trusted-content.html" {:title "Watch your world grow"
|
||||
:content (html (world/render-world-table))
|
||||
:seconds (or (session/get :seconds) 5)
|
||||
:pause (or (session/get :pause) 5)
|
||||
:maybe-refresh "refresh"}))
|
||||
|
||||
(defn about-page []
|
||||
(layout/render "about.html" {:title "About MicroWorld" :content (util/md->html "/md/about.md")}))
|
||||
(layout/render "trusted-content.html" {:title "About MicroWorld" :content (util/md->html "/md/about.md")}))
|
||||
|
||||
(defn list-states []
|
||||
(sort
|
||||
|
|
@ -28,8 +29,8 @@
|
|||
|
||||
(defn docs-page []
|
||||
(layout/render "docs.html" {:title "Documentation"
|
||||
:parser (util/md->html "/md/mw-parser.md")
|
||||
:states (list-states)
|
||||
:parser (util/md->html "/md/mw-parser.md" )
|
||||
:states (util/list-resources "resources/public/img/tiles" #"([0-9a-z-_]+).png")
|
||||
:components ["mw-engine" "mw-parser" "mw-ui"]}))
|
||||
|
||||
(defroutes home-routes
|
||||
|
|
@ -37,5 +38,7 @@
|
|||
(GET "/about" [] (about-page))
|
||||
(GET "/docs" [] (docs-page))
|
||||
(GET "/world" [] (world-page))
|
||||
(GET "/params" [] (params/params-page))
|
||||
(POST "/params" request (params/params-page request))
|
||||
(GET "/rules" request (rules/rules-page request))
|
||||
(POST "/rules" request (rules/rules-page request)))
|
||||
|
|
|
|||
|
|
@ -8,3 +8,10 @@
|
|||
(->>
|
||||
(io/slurp-resource filename)
|
||||
(md/md-to-html-string)))
|
||||
|
||||
(defn list-resources [directory pattern]
|
||||
"List resource files matching `pattern` in `directory`."
|
||||
(sort
|
||||
(filter #(not (nil? %))
|
||||
(map #(first (rest (re-matches pattern (.getName %))))
|
||||
(file-seq (clojure.java.io/file directory))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue