diff --git a/README.md b/README.md index 34f9e16..9a1ef18 100644 --- a/README.md +++ b/README.md @@ -20,18 +20,32 @@ If you run the server running **geocsv**, the simplest way to add CSV files is s https://geocsv.example.com/ -and the file you want to view is `myfile.csv`, then you would specify this as +and the file you want to view is `myfile.csv`, then you would specify this as the value of `file` in the query part of the URL. https://geocsv.example.com/?file=myfile.csv +### Loading CSV file onto another public server + +If you're not running the **geocsv** server yourself, you can upload the CSV to another server which is accessible by the **geocsv** server. You can then map data from the CSV file by specifying the URL of the file as the value of `uri` in the query part of the URL: + + https://geocsv.example.com/?uri=http://my.other.server/path/to/myfile.csv + ### Using a Google spreadsheet -If you use [Google Sheets](https://www.google.co.uk/sheets/about/), then every sheet has a 'document id', a long string of characters which uniquely identifies that sheet. Suppose your Google spreadsheet has a document id of `abcdefghijklmnopqrstuvwxyz-12345`, then you could pull data from this spreadsheet by specifying: +If you use [Google Sheets](https://www.google.co.uk/sheets/about/), then every sheet has a 'document id', a long string of characters which uniquely identifies that sheet. Suppose your Google spreadsheet has a document id of `abcdefghijklmnopqrstuvwxyz-12345`, then you could pull data from this spreadsheet by specifying this as the value of `docid` in the query part of the URL: https://geocsv.example.com/?docid=abcdefghijklmnopqrstuvwxyz-12345 The spreadsheet **must** be publicly readable. +### Precedence + +Nothing, of course, stops you from specifying multiple arguments in the query part of the URL, but only one will be used. The precedence is in this order: + +1. `docid` is considered first, and overrides anything else; +2. `uri` is considered next, and overrides `file`; +3. the value of `file` is considered only if neither of the other two are present. + ## Not yet working GeoCSV is at an early stage of development, and some features are not yet working. diff --git a/project.clj b/project.clj index fa8b919..b4d1cc9 100644 --- a/project.clj +++ b/project.clj @@ -32,6 +32,7 @@ [org.clojure/tools.cli "0.4.2"] [org.clojure/tools.logging "0.5.0"] [org.webjars.npm/bulma "0.8.0"] + [org.webjars.npm/leaflet "1.6.0"] [org.webjars.npm/material-icons "0.3.1"] [org.webjars/webjars-locator "0.38"] [re-frame "0.10.9"] @@ -43,10 +44,6 @@ [selmer "1.12.18"]] :min-lein-version "2.0.0" - :npm {:dependencies [[bulma "0.8.0"] - [leaflet "1.3.1"] - [material-design-icons "3.0.1"]] - :root "resources/public/js/lib/node_modules"} :source-paths ["src/clj" "src/cljs" "src/cljc"] :test-paths ["test/clj"] @@ -56,7 +53,6 @@ :plugins [[lein-cljsbuild "1.1.7"] [lein-codox "0.10.7"] - [lein-npm "0.6.2"] [lein-release "1.0.5"]] :clean-targets ^{:protect false} diff --git a/resources/docs/docs.md b/resources/docs/docs.md index 34f9e16..9a1ef18 100644 --- a/resources/docs/docs.md +++ b/resources/docs/docs.md @@ -20,18 +20,32 @@ If you run the server running **geocsv**, the simplest way to add CSV files is s https://geocsv.example.com/ -and the file you want to view is `myfile.csv`, then you would specify this as +and the file you want to view is `myfile.csv`, then you would specify this as the value of `file` in the query part of the URL. https://geocsv.example.com/?file=myfile.csv +### Loading CSV file onto another public server + +If you're not running the **geocsv** server yourself, you can upload the CSV to another server which is accessible by the **geocsv** server. You can then map data from the CSV file by specifying the URL of the file as the value of `uri` in the query part of the URL: + + https://geocsv.example.com/?uri=http://my.other.server/path/to/myfile.csv + ### Using a Google spreadsheet -If you use [Google Sheets](https://www.google.co.uk/sheets/about/), then every sheet has a 'document id', a long string of characters which uniquely identifies that sheet. Suppose your Google spreadsheet has a document id of `abcdefghijklmnopqrstuvwxyz-12345`, then you could pull data from this spreadsheet by specifying: +If you use [Google Sheets](https://www.google.co.uk/sheets/about/), then every sheet has a 'document id', a long string of characters which uniquely identifies that sheet. Suppose your Google spreadsheet has a document id of `abcdefghijklmnopqrstuvwxyz-12345`, then you could pull data from this spreadsheet by specifying this as the value of `docid` in the query part of the URL: https://geocsv.example.com/?docid=abcdefghijklmnopqrstuvwxyz-12345 The spreadsheet **must** be publicly readable. +### Precedence + +Nothing, of course, stops you from specifying multiple arguments in the query part of the URL, but only one will be used. The precedence is in this order: + +1. `docid` is considered first, and overrides anything else; +2. `uri` is considered next, and overrides `file`; +3. the value of `file` is considered only if neither of the other two are present. + ## Not yet working GeoCSV is at an early stage of development, and some features are not yet working. diff --git a/resources/html/error.html b/resources/html/error.html index 88103f7..fd31cc5 100644 --- a/resources/html/error.html +++ b/resources/html/error.html @@ -4,7 +4,7 @@ <title>Something Bad Happened</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - {% style "/js/lib/node_modules/bulma/css/bulma.min.css" %} + {% style "/assets/bulma/css/bulma.min.css" %} <style type="text/css"> html { height: 100%; diff --git a/resources/html/home.html b/resources/html/home.html index 5f65079..74314ba 100644 --- a/resources/html/home.html +++ b/resources/html/home.html @@ -1,32 +1,31 @@ <!DOCTYPE html> <html> <head> - <meta charset="UTF-8"/> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <title>Welcome to geocsv</title> + <meta charset="UTF-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Welcome to geocsv</title> </head> <body> + <div id="app"> - <div class="splash-screen"> - <div class="sk-fading-circle"> - <div class="sk-circle1 sk-circle"></div> - <div class="sk-circle2 sk-circle"></div> - <div class="sk-circle3 sk-circle"></div> - <div class="sk-circle4 sk-circle"></div> - <div class="sk-circle5 sk-circle"></div> - <div class="sk-circle6 sk-circle"></div> - <div class="sk-circle7 sk-circle"></div> - <div class="sk-circle8 sk-circle"></div> - <div class="sk-circle9 sk-circle"></div> - <div class="sk-circle10 sk-circle"></div> - <div class="sk-circle11 sk-circle"></div> - <div class="sk-circle12 sk-circle"></div> + <section class="section"> + <div class="container is-fluid"> + <div class="content"> + <h4 class="title">Welcome to geocsv</h4> + <p>If you're seeing this message, that means you haven't yet compiled your ClojureScript!</p> + <p>Please run <code>lein figwheel</code> to start the ClojureScript compiler and reload the page.</p> + <h4>For better ClojureScript development experience in Chrome follow these steps:</h4> + <ul> + <li>Open DevTools + <li>Go to Settings ("three dots" icon in the upper right corner of DevTools > Menu > Settings F1 > General > Console) + <li>Check-in "Enable custom formatters" + <li>Close DevTools + <li>Open DevTools + </ul> + <p>See <a href="http://www.luminusweb.net/docs/clojurescript.md">ClojureScript</a> documentation for further details.</p> + </div> </div> - </div> - <p class="footer"> - <b>geocsv</b> is loading. - You must enable JavaScript to use <b>geocsv</b>. - </p> + </section> </div> {% block foot %} @@ -44,20 +43,20 @@ {% endblock %} <!-- scripts and styles --> - {% style "/js/lib/node_modules/bulma/css/bulma.min.css" %} - {% style "/js/lib/node_modules/material-icons/iconfont/material-icons.css" %} + {% style "/assets/bulma/css/bulma.min.css" %} + {% style "/assets/material-icons/css/material-icons.min.css" %} {% style "/css/screen.css" %} {% style "/css/geocsv.css" %} <script type="text/javascript"> - var csrfToken = "{{csrf-token}}"; + var csrfToken = "{{csrf-token}}"; </script> <!-- scripts and styles --> <!-- ATTENTION \/ --> <!-- ATTENTION /\ --> <!-- Leaflet --> - {% style "js/lib/node_modules/leaflet/dist/leaflet.css" %} - {% script "/js/lib/node_modules/leaflet/dist/leaflet.js" %} + {% style "/assets/leaflet/dist/leaflet.css" %} + {% script "/assets/leaflet/dist/leaflet.js" %} {% script "/js/app.js" %} </body> </html> diff --git a/resources/public/css/screen.css b/resources/public/css/screen.css index 16aa762..e90ddb8 100644 --- a/resources/public/css/screen.css +++ b/resources/public/css/screen.css @@ -6,12 +6,12 @@ body { font-family: 'Material Icons'; font-style: normal; font-weight: 400; - src: url(/js/lib/node_modules/material-icons/iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */ + src: url(/assets/material-icons/iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */ src: local('Material Icons'), local('MaterialIcons-Regular'), - url(/js/lib/node_modules/material-icons/iconfont/MaterialIcons-Regular.woff2) format('woff2'), - url(/js/lib/node_modules/material-icons/iconfont/MaterialIcons-Regular.woff) format('woff'), - url(/js/lib/node_modules/material-icons/iconfont/MaterialIcons-Regular.ttf) format('truetype'); + url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff2) format('woff2'), + url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff) format('woff'), + url(/assets/material-icons/iconfont/MaterialIcons-Regular.ttf) format('truetype'); } .material-icons { font-family: 'Material Icons'; diff --git a/resources/public/img/map-pins/unknown-pin.png b/resources/public/img/map-pins/Unknown-pin.png similarity index 100% rename from resources/public/img/map-pins/unknown-pin.png rename to resources/public/img/map-pins/Unknown-pin.png diff --git a/resources/public/img/map-pins/unknown-pin.svg b/resources/public/img/map-pins/Unknown-pin.svg similarity index 100% rename from resources/public/img/map-pins/unknown-pin.svg rename to resources/public/img/map-pins/Unknown-pin.svg diff --git a/resources/public/img/map-pins/unknown-pin.xcf b/resources/public/img/map-pins/unknown-pin.xcf deleted file mode 100644 index b55b9f8..0000000 Binary files a/resources/public/img/map-pins/unknown-pin.xcf and /dev/null differ diff --git a/src/clj/geocsv/handler serves resources.clj b/src/clj/geocsv/handler serves resources.clj new file mode 100644 index 0000000..e86d51b --- /dev/null +++ b/src/clj/geocsv/handler serves resources.clj @@ -0,0 +1,40 @@ +(ns geocsv.handler + (:require [compojure.core :refer [routes wrap-routes]] + [geocsv.env :refer [defaults]] + [geocsv.middleware :as middleware] + [geocsv.layout :refer [error-page]] + [geocsv.routes.home :refer [home-routes]] + [geocsv.routes.json :refer [json-routes]] + [reitit.ring :as ring] + [ring.middleware.content-type :refer [wrap-content-type]] + [ring.middleware.webjars :refer [wrap-webjars]] + [mount.core :as mount])) + +(mount/defstate init-app + :start ((or (:init defaults) (fn []))) + :stop ((or (:stop defaults) (fn [])))) + +(mount/defstate app-routes + :start + (ring/ring-handler + (ring/router + [(home-routes) +;; (-> #'json-routes +;; (wrap-routes middleware/wrap-csrf) +;; (wrap-routes middleware/wrap-formats)) + ]) + (ring/routes + (ring/create-resource-handler + {:path "/"}) + (wrap-content-type + (wrap-webjars (constantly nil))) + (ring/create-default-handler + {:not-found + (constantly (error-page {:status 404, :title "404 - Page not found"})) + :method-not-allowed + (constantly (error-page {:status 405, :title "405 - Not allowed"})) + :not-acceptable + (constantly (error-page {:status 406, :title "406 - Not acceptable"}))})))) + +(defn app [] + (middleware/wrap-base #'app-routes)) diff --git a/src/clj/geocsv/handler.clj b/src/clj/geocsv/handler.clj index b1929ec..8c0e65a 100644 --- a/src/clj/geocsv/handler.clj +++ b/src/clj/geocsv/handler.clj @@ -22,13 +22,14 @@ (routes (-> #'home-routes (wrap-routes middleware/wrap-csrf) - (wrap-routes middleware/wrap-formats)) + (wrap-routes middleware/wrap-formats) + wrap-webjars) (-> #'rest-routes (wrap-routes middleware/wrap-csrf) (wrap-routes middleware/wrap-formats)) - (ring/create-resource-handler - {:path "/"}) -;; (route/resources "/") +;; (ring/create-resource-handler +;; {:path "/"}) + (route/resources "/") (route/not-found (:body (error-page {:status 404 diff --git a/src/clj/geocsv/routes/resources.clj b/src/clj/geocsv/routes/resources.clj deleted file mode 100644 index 3511ae7..0000000 --- a/src/clj/geocsv/routes/resources.clj +++ /dev/null @@ -1,14 +0,0 @@ -(ns geocsv.routes.resources - "Serve resources for geocsv." - (:require [adl-support.core :as ac] - [adl-support.rest-support :as ar] - [clojure.core.memoize :as memo] - [clojure.java.io :as io] - [clojure.string :as s] - [clojure.tools.logging :as log] - [compojure.core :refer [defroutes GET POST]] - [csv2edn.csv2edn :refer :all] - [noir.response :as nresponse] - [noir.util.route :as route] - [ring.util.http-response :as response] - )) diff --git a/src/cljs/geocsv/core.cljs b/src/cljs/geocsv/core.cljs index a85d2f3..92bf1c7 100644 --- a/src/cljs/geocsv/core.cljs +++ b/src/cljs/geocsv/core.cljs @@ -3,6 +3,7 @@ [day8.re-frame.http-fx] [reagent.core :as r] [re-frame.core :as rf] + [geocsv.gis :as gis] [geocsv.views.map :as mv] [goog.events :as events] [goog.history.EventType :as HistoryEventType] @@ -11,7 +12,7 @@ [geocsv.events] [reitit.core :as reitit] [reitit.frontend.easy :as rfe] - [clojure.string :as string]) + [clojure.string :as s]) (:import goog.History)) (defn nav-link [uri title page] @@ -39,7 +40,31 @@ (defn about-page [] [:section.section>div.container>div.content - [:img {:src "/img/warning_clojure.png"}]]) + [:img {:src "/img/warning_clojure.png"}] + (when-let [images @(rf/subscribe [:available-pin-images])] + [:div + [:h2 "The following pin images are available on this server"] + (apply + vector + (cons + :ol + (map + #(vector + :ol + [:img + {:src + (str + "img/map-pins/" + (s/capitalize + (s/replace + (s/lower-case + (str %)) + #"[^a-z0-9]" "-")) + "-pin.png") + :alt %}] + " " + %) + (sort images))))])]) (defn home-page [] [:section.section>div.container>div.content diff --git a/src/cljs/geocsv/gis.cljs b/src/cljs/geocsv/gis.cljs index 3aefc87..59d8323 100644 --- a/src/cljs/geocsv/gis.cljs +++ b/src/cljs/geocsv/gis.cljs @@ -81,7 +81,7 @@ (if (available category) (str category "-pin") - "unknown-pin"))) + "Unknown-pin"))) (defn popup-content "Appropriate content for the popup of a map pin for this `record`."