Made 'map' the default page, moved documentation to 'about'.

This commit is contained in:
Simon Brooke 2020-02-10 15:58:04 +00:00
parent 2d2ad00f5d
commit eb354fdcda
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
5 changed files with 46 additions and 43 deletions

2
.gitignore vendored
View file

@ -24,3 +24,5 @@ resources/docs/orig.md
resources/public/img/map-pins/colours/*.svg
resources/public/img/map-pins/colours/*.png
.rebel_readline_history

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -34,13 +34,14 @@
[:div#nav-menu.navbar-menu
{:class (when @expanded? :is-active)}
[:div.navbar-start
[nav-link "#/" "Home" :home]
[nav-link "#/map" "Map" :map]
[nav-link "#/" "Map" :map]
[nav-link "#/about" "About" :about]]]]))
(defn about-page []
[:section.section>div.container>div.content
[:img {:src "/img/warning_clojure.png"}]
[:div
(when-let [docs @(rf/subscribe [:docs])]
[:div {:dangerouslySetInnerHTML {:__html (md->html docs)}}])
(when-let [images @(rf/subscribe [:available-pin-images])]
[:div
[:h2 "The following pin images are available on this server"]
@ -64,12 +65,7 @@
:alt %}]
" "
%)
(sort images))))])])
(defn home-page []
[:section.section>div.container>div.content
(when-let [docs @(rf/subscribe [:docs])]
[:div {:dangerouslySetInnerHTML {:__html (md->html docs)}}])])
(sort images))))])]])
(defn map-page []
"Return the content for the main map page. Map showing current location."
@ -77,8 +73,7 @@
(mv/panel))
(def pages
{:home #'home-page
:map #'map-page
{:map #'map-page
:about #'about-page})
(defn page []
@ -92,14 +87,12 @@
(def router
(reitit/router
[["/" {:name :home
:view #'home-page
:controllers [{:start (fn [_] (rf/dispatch [:init-home]))}]}]
["/map" {:name :map
[["/" {:name :map
:view #'map-page
:controllers [{:start (fn [_] (rf/dispatch [:init-map]))}]}]
["/about" {:name :about
:view #'about-page}]]))
:view #'about-page
:controllers [{:start (fn [_] (rf/dispatch [:init-about]))}]}]]))
(defn start-router! []
(rfe/start!

View file

@ -38,5 +38,5 @@
"Power-supplier"} ;; need to be fetched from server side
:latitude 56
:longitude -4
:page :home
:page :about
:zoom 1})

View file

@ -50,6 +50,12 @@
(js/console.log (str "Failed to fetch data data" response))
db))
(rf/reg-event-db
:bad-docs
(fn [db [_ _]]
(js/console.log "Failed to fetch docs")
(assoc db :docs "**WARNING:** failed to fetch documentation from server.")))
(rf/reg-event-db
:common/set-error
(fn [db [_ error]]
@ -96,10 +102,11 @@
{:http-xhrio {:method :get
:uri "/docs"
:response-format (ajax/raw-response-format)
:on-success [:set-docs]}}))
:on-success [:set-docs]
:on-failure [:bad-docs]}}))
(rf/reg-event-fx
:init-home
:init-about
(fn [_ _]
{:dispatch [:fetch-docs]}))
@ -152,7 +159,7 @@
(fn
[{db :db} [_ response]]
(let [db' (assoc db :available-pin-images (set response))]
(js/console.log (str "processing pin images"))
(js/console.log "processing pin images")
{:db (if
(:view db')
(refresh-map-pins db')
@ -161,6 +168,7 @@
(rf/reg-event-db
:set-docs
(fn [db [_ docs]]
(js/console.log "Successfully fetched docs")
(assoc db :docs docs)))
(rf/reg-event-db