Some documentation; good enough for other folk to look at
This commit is contained in:
parent
2291670056
commit
e4e0d6a95d
11 changed files with 876 additions and 85 deletions
|
|
@ -2,7 +2,32 @@
|
|||
:author "Simon Brooke"}
|
||||
geocsv.db)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;
|
||||
;;;; geocsv.db: database initialisation, prior to fetching anything from
|
||||
;;;; server side.
|
||||
;;;;
|
||||
;;;; This program is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU General Public License
|
||||
;;;; as published by the Free Software Foundation; either version 2
|
||||
;;;; of the License, or (at your option) any later version.
|
||||
;;;;
|
||||
;;;; This program is distributed in the hope that it will be useful,
|
||||
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;;; GNU General Public License for more details.
|
||||
;;;;
|
||||
;;;; You should have received a copy of the GNU General Public License
|
||||
;;;; along with this program; if not, write to the Free Software
|
||||
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
;;;; USA.
|
||||
;;;;
|
||||
;;;; Copyright (C) 2016 Simon Brooke for Radical Independence Campaign
|
||||
;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def default-db
|
||||
{:page :home
|
||||
:available-pin-images #{"Planning authority" "unknown"} ;; need to be fetched from server side
|
||||
:map {:map-centre [56 -4]
|
||||
:map-zoom 6}})
|
||||
|
|
|
|||
|
|
@ -8,6 +8,29 @@
|
|||
[reitit.frontend.easy :as rfe]
|
||||
[reitit.frontend.controllers :as rfc]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;
|
||||
;;;; geocsv.events: events and subscriptions; things which change the state.
|
||||
;;;;
|
||||
;;;; This program is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU General Public License
|
||||
;;;; as published by the Free Software Foundation; either version 2
|
||||
;;;; of the License, or (at your option) any later version.
|
||||
;;;;
|
||||
;;;; This program is distributed in the hope that it will be useful,
|
||||
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;;; GNU General Public License for more details.
|
||||
;;;;
|
||||
;;;; You should have received a copy of the GNU General Public License
|
||||
;;;; along with this program; if not, write to the Free Software
|
||||
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
;;;; USA.
|
||||
;;;;
|
||||
;;;; Copyright (C) 2016 Simon Brooke for Radical Independence Campaign
|
||||
;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
(def source-host
|
||||
"The base URL of the host from which the app was loaded."
|
||||
|
|
@ -115,6 +138,10 @@
|
|||
(assoc db :view view)))
|
||||
|
||||
;;subscriptions. Keep in alphabetical order, please
|
||||
(rf/reg-sub
|
||||
:available-pin-images
|
||||
(fn [db _]
|
||||
(:available-pin-images db)))
|
||||
|
||||
(rf/reg-sub
|
||||
:common/error
|
||||
|
|
|
|||
|
|
@ -72,12 +72,14 @@
|
|||
(defn pin-image
|
||||
"Return the name of a suitable pin image for this `record`."
|
||||
[record]
|
||||
(if
|
||||
(:category record)
|
||||
(str
|
||||
(s/capitalize
|
||||
(s/replace (s/lower-case (str (:category record))) #"[^a-z0-9]" "-")) "-pin")
|
||||
"unknown-pin"))
|
||||
(let [available @(subscribe [:available-pin-images])]
|
||||
(js/console.log (str "pin-image: available is of type `" (type available) "`; `(fn? available)` returns " (set? available)))
|
||||
(if
|
||||
(contains? available (:category record))
|
||||
(str
|
||||
(s/capitalize
|
||||
(s/replace (s/lower-case (str (:category record))) #"[^a-z0-9]" "-")) "-pin")
|
||||
"unknown-pin")))
|
||||
|
||||
(defn popup-content
|
||||
"Appropriate content for the popup of a map pin for this `record`."
|
||||
|
|
@ -102,7 +104,9 @@
|
|||
"</h5><table>"
|
||||
(apply
|
||||
str
|
||||
(map #(str "<tr><th>" (name %) "</th><td>" (record %) "</td></tr>") (keys record)))
|
||||
(map
|
||||
#(str "<tr><th>" (name %) "</th><td>" (record %) "</td></tr>")
|
||||
(sort (keys record))))
|
||||
"</table>"))
|
||||
|
||||
(defn add-map-pin
|
||||
|
|
@ -132,10 +136,6 @@
|
|||
:title (:name record)}))]
|
||||
(.bindPopup marker (popup-table-content record))
|
||||
(.addTo marker view)
|
||||
;; (.on
|
||||
;; (.addTo marker view)
|
||||
;; "click"
|
||||
;; (fn [_] (map-pin-click-handler index)))
|
||||
(js/console.log (str "Added `"(:name record)"` in at " lat ", " lng))
|
||||
marker))))
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@
|
|||
(defn map-render
|
||||
"Render the actual div containing the map."
|
||||
[]
|
||||
[:div#map {:style {:height "500px" :width "800px"}}])
|
||||
[:div#map {:style {:height "500px"}}])
|
||||
|
||||
(defn panel
|
||||
"A reagent class for the map object."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue