]> git.openstreetmap.org Git - nominatim-ui.git/commitdiff
allow theming (#84)
authormtmail <mtmail@gmx.net>
Tue, 23 Feb 2021 00:43:16 +0000 (01:43 +0100)
committerGitHub <noreply@github.com>
Tue, 23 Feb 2021 00:43:16 +0000 (01:43 +0100)
27 files changed:
README.md
dist/about.html [new file with mode: 0644]
dist/config.example.js
dist/deletable.html
dist/details.html
dist/global.css [deleted file]
dist/images/favicon-16x16.png [deleted file]
dist/images/favicon-194x194.png [deleted file]
dist/images/osm_logo.120px.png [deleted file]
dist/polygons.html
dist/reverse.html
dist/search.html
dist/theme/about-help.html [new file with mode: 0644]
dist/theme/favicon-194x194.png [new file with mode: 0644]
dist/theme/favicon-32x32.png [new file with mode: 0644]
dist/theme/logo.png [new file with mode: 0644]
dist/theme/style.css [new file with mode: 0644]
dist/theme/welcome.html [new file with mode: 0644]
screenshot.png
src/App.svelte
src/components/Header.svelte
src/components/ReportIssueModal.svelte [deleted file]
src/components/Welcome.svelte
src/lib/api_utils.js
src/lib/config_reader.js
src/lib/stores.js
src/pages/AboutPage.svelte [new file with mode: 0644]

index 91a0220e3c115615721094e43c3c74661e3a2b54..8eb100fd16ba180f6942532589beffad70ff8e7d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -40,6 +40,15 @@ Defaults:
 | `Map_Tile_Attribution` | [OpenStreetMap](https://openstreetmap.org/copyright) obviously |
 
 
+## Theming
+
+You can customize parts of the website by overwriting files in `dist/theme/`
+
+   * Set a `Page_Title` in the configuration
+   * Logo
+   * Content of Welcome and About&Help page
+   * Additional CSS styling
+
 ## License
 
 The source code is available under a [GPLv2 license](LICENSE).
diff --git a/dist/about.html b/dist/about.html
new file mode 100644 (file)
index 0000000..7918259
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset='utf-8'>
+  <meta name='viewport' content='width=device-width,initial-scale=1'>
+
+  <title>Nominatim Demo</title>
+
+  <link rel="icon" type="image/png" href="theme/favicon-194x194.png" sizes="194x194" />
+  <link rel="icon" type="image/png" href="theme/favicon-32x32.png" sizes="32x32" />
+
+  <link rel='stylesheet' href='build/bundle.css'>
+  <link rel='stylesheet' href='theme/style.css'>
+
+  <script src='config.js'></script>
+  <script defer src='build/bundle.js'></script>
+</head>
+
+<body>
+</body>
+</html>
index cf4df52345e77b35c46bf092603f07032b5ef49b..e3b8a3ea1f6153462c1a5bc8bc5c685ab772cb73 100644 (file)
@@ -25,3 +25,6 @@ var Nominatim_Config = [];
 // 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';
index 95d679f522f51eb8fa3e7323f1528e56d61d8afd..79182597a522d780090e70c21ad0074fc02ac5d9 100644 (file)
@@ -4,13 +4,13 @@
   <meta charset='utf-8'>
   <meta name='viewport' content='width=device-width,initial-scale=1'>
 
-  <title>OpenStreetMap Nominatim</title>
+  <title>Nominatim Demo</title>
 
-  <link rel="icon" type="image/png" href="images/favicon-194x194.png" sizes="194x194" />
-  <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
+  <link rel="icon" type="image/png" href="theme/favicon-194x194.png" sizes="194x194" />
+  <link rel="icon" type="image/png" href="theme/favicon-32x32.png" sizes="32x32" />
 
-  <link rel='stylesheet' href='global.css'>
   <link rel='stylesheet' href='build/bundle.css'>
+  <link rel='stylesheet' href='theme/style.css'>
 
   <script src='config.js'></script>
   <script defer src='build/bundle.js'></script>
index 95d679f522f51eb8fa3e7323f1528e56d61d8afd..79182597a522d780090e70c21ad0074fc02ac5d9 100644 (file)
@@ -4,13 +4,13 @@
   <meta charset='utf-8'>
   <meta name='viewport' content='width=device-width,initial-scale=1'>
 
-  <title>OpenStreetMap Nominatim</title>
+  <title>Nominatim Demo</title>
 
-  <link rel="icon" type="image/png" href="images/favicon-194x194.png" sizes="194x194" />
-  <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
+  <link rel="icon" type="image/png" href="theme/favicon-194x194.png" sizes="194x194" />
+  <link rel="icon" type="image/png" href="theme/favicon-32x32.png" sizes="32x32" />
 
-  <link rel='stylesheet' href='global.css'>
   <link rel='stylesheet' href='build/bundle.css'>
+  <link rel='stylesheet' href='theme/style.css'>
 
   <script src='config.js'></script>
   <script defer src='build/bundle.js'></script>
diff --git a/dist/global.css b/dist/global.css
deleted file mode 100644 (file)
index 45a2648..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-body {
-  font-size: 0.85em
-}
diff --git a/dist/images/favicon-16x16.png b/dist/images/favicon-16x16.png
deleted file mode 100644 (file)
index 09213a1..0000000
Binary files a/dist/images/favicon-16x16.png and /dev/null differ
diff --git a/dist/images/favicon-194x194.png b/dist/images/favicon-194x194.png
deleted file mode 100644 (file)
index 7e356f1..0000000
Binary files a/dist/images/favicon-194x194.png and /dev/null differ
diff --git a/dist/images/osm_logo.120px.png b/dist/images/osm_logo.120px.png
deleted file mode 100755 (executable)
index 22f1166..0000000
Binary files a/dist/images/osm_logo.120px.png and /dev/null differ
index 95d679f522f51eb8fa3e7323f1528e56d61d8afd..79182597a522d780090e70c21ad0074fc02ac5d9 100644 (file)
@@ -4,13 +4,13 @@
   <meta charset='utf-8'>
   <meta name='viewport' content='width=device-width,initial-scale=1'>
 
-  <title>OpenStreetMap Nominatim</title>
+  <title>Nominatim Demo</title>
 
-  <link rel="icon" type="image/png" href="images/favicon-194x194.png" sizes="194x194" />
-  <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
+  <link rel="icon" type="image/png" href="theme/favicon-194x194.png" sizes="194x194" />
+  <link rel="icon" type="image/png" href="theme/favicon-32x32.png" sizes="32x32" />
 
-  <link rel='stylesheet' href='global.css'>
   <link rel='stylesheet' href='build/bundle.css'>
+  <link rel='stylesheet' href='theme/style.css'>
 
   <script src='config.js'></script>
   <script defer src='build/bundle.js'></script>
index 95d679f522f51eb8fa3e7323f1528e56d61d8afd..79182597a522d780090e70c21ad0074fc02ac5d9 100644 (file)
@@ -4,13 +4,13 @@
   <meta charset='utf-8'>
   <meta name='viewport' content='width=device-width,initial-scale=1'>
 
-  <title>OpenStreetMap Nominatim</title>
+  <title>Nominatim Demo</title>
 
-  <link rel="icon" type="image/png" href="images/favicon-194x194.png" sizes="194x194" />
-  <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
+  <link rel="icon" type="image/png" href="theme/favicon-194x194.png" sizes="194x194" />
+  <link rel="icon" type="image/png" href="theme/favicon-32x32.png" sizes="32x32" />
 
-  <link rel='stylesheet' href='global.css'>
   <link rel='stylesheet' href='build/bundle.css'>
+  <link rel='stylesheet' href='theme/style.css'>
 
   <script src='config.js'></script>
   <script defer src='build/bundle.js'></script>
index 95d679f522f51eb8fa3e7323f1528e56d61d8afd..79182597a522d780090e70c21ad0074fc02ac5d9 100644 (file)
@@ -4,13 +4,13 @@
   <meta charset='utf-8'>
   <meta name='viewport' content='width=device-width,initial-scale=1'>
 
-  <title>OpenStreetMap Nominatim</title>
+  <title>Nominatim Demo</title>
 
-  <link rel="icon" type="image/png" href="images/favicon-194x194.png" sizes="194x194" />
-  <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
+  <link rel="icon" type="image/png" href="theme/favicon-194x194.png" sizes="194x194" />
+  <link rel="icon" type="image/png" href="theme/favicon-32x32.png" sizes="32x32" />
 
-  <link rel='stylesheet' href='global.css'>
   <link rel='stylesheet' href='build/bundle.css'>
+  <link rel='stylesheet' href='theme/style.css'>
 
   <script src='config.js'></script>
   <script defer src='build/bundle.js'></script>
diff --git a/dist/theme/about-help.html b/dist/theme/about-help.html
new file mode 100644 (file)
index 0000000..cbf57ca
--- /dev/null
@@ -0,0 +1,25 @@
+<h2 class="my-4">About & Help</h2>
+
+<p>
+  This website is based on <a href="https://github.com/osm-search/nominatim-ui">Nominatim UI</a>,
+  a debugging interface for the <a href="https://nominatim.org/">Nominatim</a> geocoding software.
+</p>
+
+<p>
+  The Nominatim API is installed at <code>Nominatim_API_Endpoint</code> and for questions you
+  should contact their administrators.
+</p>
+
+<p>
+  Nominatim is a search engine for <a href="https://www.openstreetmap.org/">OpenStreetMap</a> data.
+  You may search for a name or address (forward search) or look up data by its geographic coordinate
+  (reverse search). Each result comes with a link to a details page where you can inspect what data
+  about the object is saved in the database and investigate how the address of the object has been
+  computed.
+</p>
+
+
+<p class="alert alert-secondary my-4">
+  If you're the adminstrator of this website you can edit the text above in
+  <code>dist/branding/about-and-help.html</code>
+</p>
diff --git a/dist/theme/favicon-194x194.png b/dist/theme/favicon-194x194.png
new file mode 100644 (file)
index 0000000..69abd1a
Binary files /dev/null and b/dist/theme/favicon-194x194.png differ
diff --git a/dist/theme/favicon-32x32.png b/dist/theme/favicon-32x32.png
new file mode 100644 (file)
index 0000000..69abd1a
Binary files /dev/null and b/dist/theme/favicon-32x32.png differ
diff --git a/dist/theme/logo.png b/dist/theme/logo.png
new file mode 100644 (file)
index 0000000..a39f89b
Binary files /dev/null and b/dist/theme/logo.png differ
diff --git a/dist/theme/style.css b/dist/theme/style.css
new file mode 100644 (file)
index 0000000..51b19ee
--- /dev/null
@@ -0,0 +1,3 @@
+#theme-logo {
+  height: 30px;
+}
diff --git a/dist/theme/welcome.html b/dist/theme/welcome.html
new file mode 100644 (file)
index 0000000..8bed397
--- /dev/null
@@ -0,0 +1,9 @@
+<h2>Welcome to Nominatim</h2>
+
+<p>
+  Nominatim is a search engine for
+  <a href="https://www.openstreetmap.org">OpenStreetMap</a> data. This
+  is the debugging interface.
+</p>
+
+<a href="about.html">More information</a>
\ No newline at end of file
index 48a356abf2798caed69adfca1a1b384f64240511..834475cf0b92529a1084e1486f1a34977df1d50f 100644 (file)
Binary files a/screenshot.png and b/screenshot.png differ
index d12017345e22290425710f49af164ce3c5db16c5..05533e902c8dce04bfea21d30b80b02d8f85dc2d 100644 (file)
@@ -5,12 +5,12 @@
   import { page, refresh_page } from './lib/stores.js';
 
   import Footer from './components/Footer.svelte';
-  import ReportIssueModal from './components/ReportIssueModal.svelte';
   import SearchPage from './pages/SearchPage.svelte';
   import ReversePage from './pages/ReversePage.svelte';
   import DetailsPage from './pages/DetailsPage.svelte';
   import PolygonsPage from './pages/PolygonsPage.svelte';
   import DeletablePage from './pages/DeletablePage.svelte';
+  import AboutPage from './pages/AboutPage.svelte';
 
   $: view = $page.tab;
 
@@ -30,6 +30,7 @@
 <DeletablePage />
 {:else if view === 'polygons'}
 <PolygonsPage />
+{:else if view === 'about'}
+<AboutPage />
 {/if}
 <Footer/>
-<ReportIssueModal/>
index 9178267f01482a6c5d48b951131cea499f46693b..06f3bd4aa6c06f936ecdb16caca60951a01e63e2 100644 (file)
@@ -4,6 +4,7 @@
   import LastUpdated from './LastUpdated.svelte';
 
   import { page } from '../lib/stores.js';
+  import { get_config_value } from '../lib/config_reader.js';
 
   $: view = $page.tab;
 </script>
     white-space: nowrap;
   }
 
-  .dropdown-menu { /* need to be above map markers */
-    z-index: 1005;
-  }
-
   .page-title-section {
     display: none;
     text-align: center;
 
 <header class="container-fluid">
   <nav class="navbar navbar-expand-sm navbar-light">
+    <!-- Brand -->
     <div class="navbar-brand">
       <PageLink page="search">
-        <img alt="logo" src="images/osm_logo.120px.png" width="30" height="30"/>
-        <h1>Nominatim</h1>
+        <img alt="logo" id="theme-logo" src="theme/logo.png" />
+        <h1>{get_config_value('Page_Title')}</h1>
       </PageLink>
     </div>
+    <!-- Toggler (hamburger button) -->
     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
       <span class="navbar-toggler-icon"></span>
     </button>
     <div class="collapse navbar-collapse" id="navbarSupportedContent">
+      <!-- Left-aligned links -->
       <ul class="navbar-nav mr-auto">
         <li class="nav-item {view === 'search' ? 'active' : ''}">
           <PageLink page="search" extra_classes="nav-link ">Search</PageLink>
           <PageLink page="details" extra_classes="nav-link ">Search By ID</PageLink>
         </li>
       </ul>
-      <ul class="navbar-nav">
-        <li class="nav-item dropdown">
-          <a class="nav-link dropdown-toggle" href="#open-about-dropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-            About &amp; Help
-          </a>
-          <div class="dropdown-menu dropdown-menu-right">
-            <a class="dropdown-item" href="https://nominatim.org/release-docs/develop/api/Overview/" target="_blank">API Reference</a>
-            <a class="dropdown-item" href="https://nominatim.org/release-docs/develop/api/Faq/" target="_blank">FAQ</a>
-            <a class="dropdown-item" href="https://help.openstreetmap.org/tags/nominatim/">OpenStreetMap Help</a>
-            <a class="dropdown-item" href="https://github.com/osm-search/Nominatim">Nominatim on Github</a>
-            <a class="dropdown-item" href="https://github.com/osm-search/nominatim-ui">This frontend on Github</a>
-            <div class="dropdown-divider"></div>
-            <a class="dropdown-item" href="#report-issue" data-toggle="modal" data-target="#report-modal">Report problem with results</a>
-          </div>
-        </li>
-      </ul>
     </div>
+    <!-- Right aligned links -->
+    <ul class="navbar-nav">
+      <li class="nav-item {view === 'about' ? 'active' : ''}">
+        <PageLink page="about" extra_classes="nav-link ">About & Help</PageLink>
+      </li>
+    </ul>
   </nav>
 </header>
 <section class="page-title-section">
diff --git a/src/components/ReportIssueModal.svelte b/src/components/ReportIssueModal.svelte
deleted file mode 100644 (file)
index 267dd8f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<div class="modal fade" id="report-modal">
-  <div class="modal-dialog">
-    <div class="modal-content">
-      <div class="modal-header">
-        <h4 class="modal-title">Report a problem</h4>
-        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
-      </div>
-      <div class="modal-body">
-        <p>
-          Before reporting problems please read the <a target="_blank" href="https://nominatim.org/release-docs/develop/api/Overview/">user documentation</a>
-          and
-          <a target="_blank" href="https://nominatim.org/release-docs/develop/api/Faq/">FAQ</a>.
-
-          If your problem relates to the address of a particular search result please use the 'details' link 
-          to check how the address was generated before reporting a problem.
-        </p>
-        <p>
-          Use <a target="_blank" href="https://github.com/osm-search/Nominatim/issues">Nominatim issues on github</a>
-          to report problems.
-        </p>
-        <p>
-          Please ensure that you include a full description of the problem, including the search
-          query that you used, the problem with the result and, if the problem relates to missing data,
-          the osm type (node, way, relation) and id of the item that is missing.
-        </p>
-        <p>
-          Problems that contain enough detail are likely to get looked at before ones that require
-          significant research.
-        </p>
-      </div>
-      <div class="modal-footer">
-        <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">OK</button>
-      </div>
-    </div>
-  </div>
-</div>
\ No newline at end of file
index 01d0a07e7a1f7c975adaf0ba13ec507624b7cfdc..2a04c14da505eb93879d74215abce0dc200a0f97 100644 (file)
@@ -1,16 +1,10 @@
-<div id="welcome">
-  <h2>Welcome to Nominatim</h2>
+<script>
+  import { onMount } from 'svelte';
+  import { fetch_content_into_element } from '../lib/api_utils.js';
 
-  <p>
-    Nominatim is a search engine for
-    <a href="https://www.openstreetmap.org">OpenStreetMap</a> data. This
-    is the debugging interface. You may search for a name or address
-    (forward search) or look up data by its geographic coordinate (reverse
-    search). Each result comes with a link to a details page where you
-    can inspect what data about the object is saved in the database and
-    investigate how the address of the object has been computed.
-  </p>
+  onMount(() => {
+    fetch_content_into_element('theme/welcome.html', document.getElementById('welcome'));
+  });
+</script>
 
-  For more information visit the
-  <a href="https://nominatim.org">Nominatim home page</a>.
-</div>
+<div id="welcome"></div>
index 8470b0b7b2873d99bc7640e097afaa96dee1e51f..8422dc491237696e55b65f0a0956c255141c10c4 100644 (file)
@@ -25,6 +25,21 @@ export async function fetch_from_api(endpoint_name, params, callback) {
   if (endpoint_name !== 'status') last_api_request_url_store.set(api_url);
 }
 
+var fetch_content_cache = {};
+export async function fetch_content_into_element(url, dom_element) {
+  if (fetch_content_cache[url]) {
+    dom_element.innerHTML = fetch_content_cache[url];
+    return;
+  }
+  await fetch(url)
+    .then(response => response.text())
+    .then(html => {
+      html = html.replace('Nominatim_API_Endpoint', get_config_value('Nominatim_API_Endpoint'));
+      dom_element.innerHTML = html;
+      fetch_content_cache[url] = html;
+    });
+}
+
 function generate_nominatim_api_url(endpoint_name, params) {
   return get_config_value('Nominatim_API_Endpoint') + endpoint_name + '.php?'
          + Object.keys(clean_up_parameters(params)).map((k) => {
@@ -46,7 +61,7 @@ function clean_up_parameters(params) {
 }
 
 export function update_html_title(title) {
-  document.title = [title, 'OpenStreetMap Nominatim']
+  document.title = [title, get_config_value('Page_Title')]
     .filter((val) => val && val.length > 1)
     .join(' | ');
 }
index 936078d262f5df95f82193154f97553458463647..30a8a1bda47cd79f24f7a2450f6e2a26ad68a586 100644 (file)
@@ -10,7 +10,8 @@ const Nominatim_Config_Defaults = {
   Map_Default_Lon: 0.0,
   Map_Default_Zoom: 2,
   Map_Tile_URL: 'https://{s}.tile.osm.org/{z}/{x}/{y}.png',
-  Map_Tile_Attribution: '<a href="https://osm.org/copyright">OpenStreetMap contributors</a>'
+  Map_Tile_Attribution: '<a href="https://osm.org/copyright">OpenStreetMap contributors</a>',
+  Page_Title: 'Nominatim Demo'
 };
 
 function get_config_value(str, default_val) {
index a7a524a3b4f738cf3f5ef4abec407dba552ccf42..6220ecc46f1ba792bb9db4910e6a0a588987bfc4 100644 (file)
@@ -15,13 +15,13 @@ export const page = writable();
  * the requested query parameters. It may also be omitted completely for a
  * link without query parameters.
  */
+const pagenames = ['search', 'reverse', 'details', 'deletable', 'polygons', 'about'];
+
 export function refresh_page(pagename, params) {
   if (typeof pagename === 'undefined') {
     pagename = window.location.pathname.replace('.html', '').replace(/^.*\//, '');
 
-    if (['search', 'reverse', 'details', 'deletable', 'polygons'].indexOf(pagename) === -1) {
-      pagename = 'search';
-    }
+    if (!pagenames.includes(pagename)) pagename = 'search';
 
     params = new URLSearchParams(window.location.search);
   } else {
diff --git a/src/pages/AboutPage.svelte b/src/pages/AboutPage.svelte
new file mode 100644 (file)
index 0000000..e480730
--- /dev/null
@@ -0,0 +1,19 @@
+<script>
+  import Header from '../components/Header.svelte';
+  import { onMount } from 'svelte';
+  import { fetch_content_into_element } from '../lib/api_utils.js';
+
+  onMount(() => {
+    fetch_content_into_element('theme/about-help.html', document.getElementById('about-help'));
+  });
+</script>
+
+<Header />
+<div id="about-help" class="container"></div>
+
+<style>
+  #about-help {
+    max-width: 800px;
+    padding: 4em;
+  }
+</style>
\ No newline at end of file