From 6e68f11776a8f6f5a62b989f13ebf7438ef32476 Mon Sep 17 00:00:00 2001 From: mtmail Date: Thu, 25 Feb 2021 21:03:16 +0100 Subject: [PATCH] New configuration paths (#89) * remove lib/config_reader.js, replace config.js with config.defaults.js * Assume README is part of release, add screenshot --- .github/workflows/release.yml | 2 +- .gitignore | 3 ++- CHANGES.md | 4 +++ CONTRIBUTE.md | 5 +++- README.md | 47 ++++++++++++++--------------------- dist/about.html | 7 +++--- dist/config.defaults.js | 27 ++++++++++++++++++++ dist/config.example.js | 30 ---------------------- dist/deletable.html | 7 +++--- dist/details.html | 7 +++--- dist/polygons.html | 7 +++--- dist/reverse.html | 7 +++--- dist/search.html | 7 +++--- src/components/Header.svelte | 4 +-- src/components/Map.svelte | 13 +++++----- src/components/MapIcon.svelte | 3 +-- src/lib/api_utils.js | 9 +++---- src/lib/config_reader.js | 23 ----------------- src/pages/ReversePage.svelte | 3 +-- src/pages/SearchPage.svelte | 3 +-- 20 files changed, 94 insertions(+), 124 deletions(-) create mode 100644 dist/config.defaults.js delete mode 100644 dist/config.example.js delete mode 100644 src/lib/config_reader.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1850544..fe8d44c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: yarn build export VERSION=${GITREF/*v/} mkdir nominatim-ui-${VERSION} - mv dist LICENSE README.md nominatim-ui-${VERSION}/ + mv dist LICENSE README.md screenshot.png nominatim-ui-${VERSION}/ mkdir artifacts tar czf artifacts/nominatim-ui-${VERSION}.tar.gz nominatim-ui-${VERSION} zip -qr artifacts/nominatim-ui-${VERSION}.zip nominatim-ui-${VERSION} diff --git a/.gitignore b/.gitignore index 434259e..0f8d259 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store -dist/config.js +dist/theme/config.theme.js +dist/build/bundle.* node_modules diff --git a/CHANGES.md b/CHANGES.md index 6234a43..df3b598 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # CHANGES +* unreleased + * Add theming + * Replace config.js with config.default.js and theme/config.theme.js + * version 2.3.0 - 2021-02-19 * New top-level navigation: Search, Reverse, Search-by-id diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index e11ae17..e8c56e3 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -1,10 +1,13 @@ # Developing Nominatim-UI +[![Continuous Integration](https://github.com/osm-search/nominatim-ui/actions/workflows/ci.yml/badge.svg)](https://github.com/osm-search/nominatim-ui/actions/workflows/ci.yml) + ## Background The user interface used to be included in the geocoder. Thus the first version avoid being a redesign and still uses some of the -same configuration values. +same configuration values. Version 2 was a full refactor using +Svelte. Version 3 added theme and easier configuration. Uses [svelte](https://svelte.dev/) framework, [leaflet](https://leafletjs.com/) for map interaction, diff --git a/README.md b/README.md index 8eb100f..1d4d018 100644 --- a/README.md +++ b/README.md @@ -2,52 +2,41 @@ Debugging user interface for [Nominatim](https://nominatim.org/) ([source](https://github.com/osm-search/Nominatim/)) geocoder. -The frontend runs standalone as website and will requests data -from a separate Nominatim API (either on the same server or -remote). -For technical details see [CONTRIBUTE.md](CONTRIBUTE.md) file. +The frontend runs standalone as website and will request data +from a separate Nominatim API running on http://localhost:80/nominatim/ (configurable, see below). + +Download a stable release from [https://github.com/osm-search/nominatim-ui/releases](). +For technical background, how to develop and create a release see [CONTRIBUTE.md](CONTRIBUTE.md) file at [https://github.com/osm-search/nominatim-ui/](). ![Screenshot](screenshot.png) ## Starting the frontend -* You can open the `dist` directory in your browser. +You can either + +* open the `dist` directory in your browser. -* If you have python installed (part of the Nominatim server installation): +* if you have Python installed (part of the Nominatim API server installation): 1. `cd dist` 2. start webserver `python3 -m http.server 8765` - 3. open http://localhost:8765/ in your browser + 3. open [http://localhost:8765/]() in your browser -* Start a webserver using ([Big list of http static server one-liners](https://gist.github.com/willurd/5720255)) or configure Apache, nginx or other webservers to serve the `dist` directory. +* start a webserver using ([Big list of http static server one-liners](https://gist.github.com/willurd/5720255)) or configure Apache, nginx or other webservers to serve the `dist` directory. ## Configuration -Create a `dist/config.js` file, you can use `dist/config.example.js` as basis (just copy it). All settings are optional. Usually you want to set the `Nominatim_API_Endpoint` value at least. - -Defaults: - -| setting | default | -|---|---| -| `Nominatim_API_Endpoint` | http://localhost/nominatim/ (port 80) | -| `Images_Base_Url` | images in [mapicons](dist/mapicons) | -| `Search_AreaPolygons` | yes, print boundaries of search results on map | -| `Reverse_Default_Search_Zoom` | 18 (house-number level) | -| `Map_Default_Lat`, `Map_Default_Lon`, `Map_Default_Zoom` | display whole world | -| `Map_Tile_URL` | load from openstreetmap.org | -| `Map_Tile_Attribution` | [OpenStreetMap](https://openstreetmap.org/copyright) obviously | - - -## Theming +Defaults are set in `dist/config.default.js`. +You can overwrite settings in `dist/config.theme.js`, for example: -You can customize parts of the website by overwriting files in `dist/theme/` +```javascript + Nominatim_Config.Nominatim_API_Endpoint = 'http://my-server:1234/'; +``` - * Set a `Page_Title` in the configuration - * Logo - * Content of Welcome and About&Help page - * Additional CSS styling +The `dist/theme/` directory also contains files make it easy to set a different +logo image, colors, welcome and help text. ## License diff --git a/dist/about.html b/dist/about.html index 7918259..99aa904 100644 --- a/dist/about.html +++ b/dist/about.html @@ -6,13 +6,14 @@ Nominatim Demo - - + + - + + diff --git a/dist/config.defaults.js b/dist/config.defaults.js new file mode 100644 index 0000000..9ab6f3a --- /dev/null +++ b/dist/config.defaults.js @@ -0,0 +1,27 @@ +// You can overwrite any defaults in dist/theme/config.theme.js + +let Nominatim_Config = { + Page_Title: 'Nominatim Demo', + + // Where Nominatim API runs. Remember to add port if needed and trailing slash. + Nominatim_API_Endpoint: 'http://localhost/nominatim/', + + // relative path or full URL + Images_Base_Url: 'mapicons/', + + // If the API should return polygons to be displayed on the map + Search_AreaPolygons: true, + + // ---- MAP ---- + Reverse_Default_Search_Zoom: 18, + Map_Default_Lat: 20.0, + Map_Default_Lon: 0.0, + Map_Default_Zoom: 2, + + // For what {x}, {y} etc stand for see + // https://leafletjs.com/reference-1.6.0.html#tilelayer + Map_Tile_URL: 'https://{s}.tile.osm.org/{z}/{x}/{y}.png', + + // Can be text or HTML. To hide set to '' + Map_Tile_Attribution: 'OpenStreetMap contributors' +}; diff --git a/dist/config.example.js b/dist/config.example.js deleted file mode 100644 index e3b8a3e..0000000 --- a/dist/config.example.js +++ /dev/null @@ -1,30 +0,0 @@ -// The app loads an optional file config.js -// -// You can use this file as base for config.js (just copy or rename it), all -// keys are optional. - -var Nominatim_Config = []; - -// Where Nominatim API runs. Remember to add port if needed and trailing slash. -// Nominatim_Config['Nominatim_API_Endpoint'] = 'http://localhost/nominatim/'; - -// Nominatim_Config['Images_Base_Url'] = '/mapicons/'; - -// If the API should return polygons to be displayed on the map -// Nominatim_Config['Search_AreaPolygons'] = 1; -// Nominatim_Config['Reverse_Default_Search_Zoom'] = 18; - -// ---- MAP ---- -// For what {x}, {y} etc stand for see -// https://leafletjs.com/reference-1.6.0.html#tilelayer -// Nominatim_Config['Map_Tile_URL'] = 'https://{s}.tile.osm.org/{z}/{x}/{y}.png'; - -// Can be text or HTML. To hide set to '' -// Nominatim_Config['Map_Tile_Attribution'] = 'OpenStreetMap contributors'; - -// Nominatim_Config['Map_Default_Lat'] = 20.0; -// Nominatim_Config['Map_Default_Lon'] = 0.0; -// Nominatim_Config['Map_Default_Zoom'] = 2; - -// ---- BRANDING ---- -// Nominatim_Config['Page_Title'] = 'Nominatim Demo'; diff --git a/dist/deletable.html b/dist/deletable.html index 7918259..99aa904 100644 --- a/dist/deletable.html +++ b/dist/deletable.html @@ -6,13 +6,14 @@ Nominatim Demo - - + + - + + diff --git a/dist/details.html b/dist/details.html index 7918259..99aa904 100644 --- a/dist/details.html +++ b/dist/details.html @@ -6,13 +6,14 @@ Nominatim Demo - - + + - + + diff --git a/dist/polygons.html b/dist/polygons.html index 7918259..99aa904 100644 --- a/dist/polygons.html +++ b/dist/polygons.html @@ -6,13 +6,14 @@ Nominatim Demo - - + + - + + diff --git a/dist/reverse.html b/dist/reverse.html index 7918259..99aa904 100644 --- a/dist/reverse.html +++ b/dist/reverse.html @@ -6,13 +6,14 @@ Nominatim Demo - - + + - + + diff --git a/dist/search.html b/dist/search.html index 7918259..99aa904 100644 --- a/dist/search.html +++ b/dist/search.html @@ -6,13 +6,14 @@ Nominatim Demo - - + + - + + diff --git a/src/components/Header.svelte b/src/components/Header.svelte index 777d8b8..4e6359a 100644 --- a/src/components/Header.svelte +++ b/src/components/Header.svelte @@ -5,9 +5,9 @@ import Error from './Error.svelte'; import { page } from '../lib/stores.js'; - import { get_config_value } from '../lib/config_reader.js'; $: view = $page.tab; + $: page_title = Nominatim_Config.Page_Title;