From 5ded76199f3f476dc397bd69350130df3d04923d Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Wed, 29 Jan 2020 19:39:49 +0000 Subject: [PATCH 1/2] Tidyup of unused database keys and subscription handlers --- src/cljs/geocsv/client/ajax.cljs | 2 -- src/cljs/geocsv/client/db.cljs | 4 +--- src/cljs/geocsv/client/events.cljs | 5 ----- src/cljs/geocsv/client/views/map.cljs | 2 +- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/cljs/geocsv/client/ajax.cljs b/src/cljs/geocsv/client/ajax.cljs index 2d55989..c1adc58 100644 --- a/src/cljs/geocsv/client/ajax.cljs +++ b/src/cljs/geocsv/client/ajax.cljs @@ -6,11 +6,9 @@ [re-frame.core :as rf])) (defn local-uri? [{:keys [uri]}] - (js/console.log (str "local-uri?: received `" (str uri) "` (type " (type uri) ") as uri")) (not (re-find #"^\w+?://" (str uri)))) (defn default-headers [request] - (js/console.log (str "default-headers: received `" request "` as request")) (if (local-uri? request) (-> request (update :headers #(merge {"x-csrf-token" js/csrfToken} %))) diff --git a/src/cljs/geocsv/client/db.cljs b/src/cljs/geocsv/client/db.cljs index cba96d4..b6cb488 100644 --- a/src/cljs/geocsv/client/db.cljs +++ b/src/cljs/geocsv/client/db.cljs @@ -38,6 +38,4 @@ "Other-key-customers" "Power-supplier"} ;; need to be fetched from server side :latitude 56 - :longitude -4 - :map {:map-centre [56 -4] - :map-zoom 6}}) + :longitude -4}) diff --git a/src/cljs/geocsv/client/events.cljs b/src/cljs/geocsv/client/events.cljs index 342db20..5b6da4a 100644 --- a/src/cljs/geocsv/client/events.cljs +++ b/src/cljs/geocsv/client/events.cljs @@ -198,11 +198,6 @@ (js/console.log (str "Fetching longitude" v)) v))) -(rf/reg-sub - :map - (fn [db _] - (:map db))) - (rf/reg-sub :route (fn [db _] diff --git a/src/cljs/geocsv/client/views/map.cljs b/src/cljs/geocsv/client/views/map.cljs index bb01c2d..27b5945 100644 --- a/src/cljs/geocsv/client/views/map.cljs +++ b/src/cljs/geocsv/client/views/map.cljs @@ -83,7 +83,7 @@ (defn map-render "Render the actual div containing the map." [] - [:div#map {:style {:height "1000px"}}]) + [:div#map {:style {:height "800px"}}]) (defn panel "A reagent class for the map object." From f8c05e56687cdbc8e3f7faf6c2003c16c99fd4b0 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Wed, 29 Jan 2020 20:28:12 +0000 Subject: [PATCH 2/2] #8: Fixed. Works in filesystem and from jar. Updated docs to recognise that the scale-and-zoom issue is fixed. --- README.md | 4 ---- env/prod/cljs/geocsv/app.cljs | 2 +- project.clj | 1 + resources/docs/docs.md | 4 ---- src/clj/geocsv/routes/rest.clj | 18 +++++++++--------- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9a1ef18..3e2cb03 100644 --- a/README.md +++ b/README.md @@ -54,10 +54,6 @@ GeoCSV is at an early stage of development, and some features are not yet workin At the current stage of development, if no appropriate image exists in the `resources/public/img/map-pins` folder, that's your problem. **TODO:** I intend at some point to make missing pin images default to `unknown-pin.png`, which does exist. -### Doesn't scale and centre the map to show the data in the sheet - -Currently the map is initially centred roughly on the centre of Scotland, and scaled arbitrarily. It should compute an appropriate centre and scale from the data provided, but currently doesn't. - ## Prerequisites You will need [Leiningen][1] 2.0 or above installed. diff --git a/env/prod/cljs/geocsv/app.cljs b/env/prod/cljs/geocsv/app.cljs index 15b798d..5e4c2f4 100644 --- a/env/prod/cljs/geocsv/app.cljs +++ b/env/prod/cljs/geocsv/app.cljs @@ -1,5 +1,5 @@ (ns geocsv.app - (:require [geocsv.core :as core])) + (:require [geocsv.client.core :as core])) ;;ignore println statements in prod (set! *print-fn* (fn [& _])) diff --git a/project.clj b/project.clj index 824d41a..7916487 100644 --- a/project.clj +++ b/project.clj @@ -12,6 +12,7 @@ [com.cemerick/url "0.1.1"] [com.cognitect/transit-clj "0.8.319"] [compojure "1.6.1"] + [cpath-clj "0.1.2"] [cprop "0.1.15"] [csv2edn "0.1.6"] [day8.re-frame/http-fx "0.1.6"] diff --git a/resources/docs/docs.md b/resources/docs/docs.md index 9a1ef18..3e2cb03 100644 --- a/resources/docs/docs.md +++ b/resources/docs/docs.md @@ -54,10 +54,6 @@ GeoCSV is at an early stage of development, and some features are not yet workin At the current stage of development, if no appropriate image exists in the `resources/public/img/map-pins` folder, that's your problem. **TODO:** I intend at some point to make missing pin images default to `unknown-pin.png`, which does exist. -### Doesn't scale and centre the map to show the data in the sheet - -Currently the map is initially centred roughly on the centre of Scotland, and scaled arbitrarily. It should compute an appropriate centre and scale from the data provided, but currently doesn't. - ## Prerequisites You will need [Leiningen][1] 2.0 or above installed. diff --git a/src/clj/geocsv/routes/rest.clj b/src/clj/geocsv/routes/rest.clj index 26d0446..c2d6fe7 100644 --- a/src/clj/geocsv/routes/rest.clj +++ b/src/clj/geocsv/routes/rest.clj @@ -6,6 +6,7 @@ [clojure.java.io :as io] [clojure.string :as s] [clojure.tools.logging :as log] + [cpath-clj.core :as cp] [compojure.core :refer [defroutes GET POST]] [csv2edn.csv2edn :refer :all] [noir.response :as nresponse] @@ -37,19 +38,18 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defn get-pin-image-names + "Return the category names for which we have pin images; `request` is ignored. + + This looks odd - why not file-seq over the directory? - but the answer is we + may be running in a jar file, and if we are that will fail." [request] (ar/do-or-server-fail (map - #(s/replace (.getName %) #"-pin\.png$" "") - (let [grammar-matcher (.getPathMatcher - (java.nio.file.FileSystems/getDefault) - "glob:*-pin.png")] + #(s/replace (s/replace (str %) #"-pin\.png$" "") "/" "") (->> "public/img/map-pins" - io/resource - io/file - file-seq - (filter #(.isFile %)) - (filter #(.matches grammar-matcher (.getFileName (.toPath %))))))) + cp/resources + keys + (filter #(re-find #".*-pin.png" %)))) 200)) (defn get-data-uri