]> git.openstreetmap.org Git - chef.git/commitdiff
nominatim: switch UI to nominatim-ui
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 18 Jul 2020 10:39:59 +0000 (12:39 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 4 Aug 2020 16:14:33 +0000 (18:14 +0200)
cookbooks/nominatim/attributes/default.rb
cookbooks/nominatim/recipes/default.rb
cookbooks/nominatim/templates/default/nginx.erb

index 1c0978afe2af3860aef5904c96c7eda4ea56d150..e29fd7931e0eeb174274df5ae3901b0d81d43dab 100644 (file)
@@ -9,6 +9,8 @@ default[:nominatim][:repository] = "https://git.openstreetmap.org/public/nominat
 default[:nominatim][:revision] = "master"
 default[:nominatim][:enable_backup] = false
 default[:nominatim][:enable_git_updates] = true
 default[:nominatim][:revision] = "master"
 default[:nominatim][:enable_backup] = false
 default[:nominatim][:enable_git_updates] = true
+default[:nominatim][:ui_repository] = "https://github.com/osm-search/nominatim-ui"
+default[:nominatim][:ui_revision] = "master"
 
 default[:nominatim][:fpm_pools] = {
   :www => {
 
 default[:nominatim][:fpm_pools] = {
   :www => {
index 0a9172b4b778c23cbd37ddf0c0ff631f25b5190e..75a8938418dfe100ab6a834f911517d330480ea4 100644 (file)
@@ -174,6 +174,7 @@ package %w[
 
 source_directory = "#{basedir}/nominatim"
 build_directory = "#{basedir}/bin"
 
 source_directory = "#{basedir}/nominatim"
 build_directory = "#{basedir}/bin"
+ui_directory = "#{basedir}/ui"
 
 directory build_directory do
   owner "nominatim"
 
 directory build_directory do
   owner "nominatim"
@@ -226,6 +227,21 @@ template "#{build_directory}/settings/local.php" do
             :log_file => "#{node[:nominatim][:logdir]}/query.log"
 end
 
             :log_file => "#{node[:nominatim][:logdir]}/query.log"
 end
 
+git ui_directory do
+  action :sync
+  repository node[:nominatim][:ui_repository]
+  revision node[:nominatim][:ui_revision]
+  user "nominatim"
+  group "nominatim"
+end
+
+template "#{ui_directory}/dist/config.js" do
+  source "ui-config.js.erb"
+  owner "nominatim"
+  group "nominatim"
+  mode 0o664
+end
+
 if node[:nominatim][:flatnode_file]
   directory File.dirname(node[:nominatim][:flatnode_file]) do
     recursive true
 if node[:nominatim][:flatnode_file]
   directory File.dirname(node[:nominatim][:flatnode_file]) do
     recursive true
@@ -401,7 +417,8 @@ nginx_site "nominatim" do
   directory build_directory
   variables :pools => node[:nominatim][:fpm_pools],
             :frontends => search(:node, "recipes:web\\:\\:frontend"),
   directory build_directory
   variables :pools => node[:nominatim][:fpm_pools],
             :frontends => search(:node, "recipes:web\\:\\:frontend"),
-            :confdir => "#{basedir}/etc"
+            :confdir => "#{basedir}/etc",
+            :ui_directory => ui_directory
 end
 
 template "/etc/logrotate.d/nginx" do
 end
 
 template "/etc/logrotate.d/nginx" do
index 2e851c517087020c659f677c8decab434d940c87..f42c60f3b857806f93985ec3caecb3acef9ebc89 100644 (file)
@@ -12,6 +12,20 @@ map $uri $nominatim_path_info {
     ~^/([^/]+)(.*)$      $2;
 }
 
     ~^/([^/]+)(.*)$      $2;
 }
 
+map $args $format {
+    default                  default;
+    ~(^|&)format=html(&|$)   html;
+    ~(^|&)format=            other;
+}
+
+map $uri/$format $forward_to_ui {
+    default               1;
+    ~^/ui                 0;
+    ~/other$              0;
+    ~/reverse.*/default   0;
+    ~/lookup.*/default    0;
+}
+
 map $query_string $email_id {
     ~(^|&)email=([^&]+)  $2;
 }
 map $query_string $email_id {
     ~(^|&)email=([^&]+)  $2;
 }
@@ -136,6 +150,11 @@ server {
         try_files $uri $uri/ @php;
     }
 
         try_files $uri $uri/ @php;
     }
 
+    location /ui/ {
+        alias <%= @ui_directory %>/dist/;
+        index search.html;
+    }
+
     location @php {
         if ($blocked_user_agent ~ ^2$)
         { return 403; }
     location @php {
         if ($blocked_user_agent ~ ^2$)
         { return 403; }
@@ -152,6 +171,9 @@ server {
         fastcgi_param QUERY_STRING    $args;
         fastcgi_param PATH_INFO       "$nominatim_path_info";
         fastcgi_param SCRIPT_FILENAME  "$document_root/$nominatim_script_name";
         fastcgi_param QUERY_STRING    $args;
         fastcgi_param PATH_INFO       "$nominatim_path_info";
         fastcgi_param SCRIPT_FILENAME  "$document_root/$nominatim_script_name";
+        if ($forward_to_ui) {
+            rewrite ^(/[^/]*) http://$host/ui$1.html redirect;
+        }
     }
 
     location ~* \.php$ {
     }
 
     location ~* \.php$ {
@@ -168,5 +190,9 @@ server {
         fastcgi_pass    nominatim_service;
         include         fastcgi_params;
         fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
         fastcgi_pass    nominatim_service;
         include         fastcgi_params;
         fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
+
+        if ($forward_to_ui) {
+            rewrite (.*).php http://$host/ui$1.html redirect;
+        }
     }
 }
     }
 }