Resources now working.

This commit is contained in:
Simon Brooke 2020-01-29 12:56:06 +00:00
parent b4f441bfd0
commit d729459e92
14 changed files with 137 additions and 62 deletions

View file

@ -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.

View file

@ -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}

View file

@ -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.

View file

@ -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%;

View file

@ -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>

View file

@ -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';

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View file

@ -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))

View file

@ -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

View file

@ -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]
))

View file

@ -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

View file

@ -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`."