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
|
@ -1,7 +1,5 @@
|
|||
## Ruleset which attempts to model retreat of ice after an iceage
|
||||
|
||||
if generation is less than 5 then state should be ice
|
||||
|
||||
;; Limitations: because the rule language doesn't (yet) allow sophisticated
|
||||
;; arithmetic, the ice retreats north to south (southern hemisphere).
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
{% extends "templates/base.html" %}
|
||||
{% block content %}
|
||||
<div>
|
||||
{{content|safe}}
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -16,13 +16,14 @@
|
|||
var context = "{{servlet-context}}";
|
||||
//]]>
|
||||
</script>
|
||||
<meta content="{{seconds}}" http-equiv="{{maybe-refresh}}" />
|
||||
<meta content="{{pause}}" http-equiv="{{maybe-refresh}}" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="header" style="background-image: url( '{{servlet-context}}/img/earth-space-strip.jpg');">
|
||||
<div id="nav">
|
||||
<ul class="nav">
|
||||
<li class="{{home-selected}}"><a href="{{servlet-context}}/">Home</a></li>
|
||||
<li class="{{params-selected}}"><a href="{{servlet-context}}/params">Parameters</a></li>
|
||||
<li class="{{rules-selected}}"><a href="{{servlet-context}}/rules">Rules</a></li>
|
||||
<li class="{{world-selected}}"><a href="{{servlet-context}}/world">World</a></li>
|
||||
<li class="{{about-selected}}"><a href="{{servlet-context}}/about">About</a></li>
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
{% extends "templates/base.html" %}
|
||||
{% block content %}
|
||||
<div>
|
||||
{{content|safe}}
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,6 +0,0 @@
|
|||
{% extends "templates/base.html" %}
|
||||
{% block content %}
|
||||
<div>
|
||||
{{content|safe}}
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -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…
Reference in a new issue