From: Sarah Hoffmann Date: Sat, 18 Jul 2020 10:39:59 +0000 (+0200) Subject: nominatim: switch UI to nominatim-ui X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/df246797e4b8705a0912158c7aa46e4da3138e01 nominatim: switch UI to nominatim-ui --- diff --git a/cookbooks/nominatim/attributes/default.rb b/cookbooks/nominatim/attributes/default.rb index 1c0978afe..e29fd7931 100644 --- a/cookbooks/nominatim/attributes/default.rb +++ b/cookbooks/nominatim/attributes/default.rb @@ -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][:ui_repository] = "https://github.com/osm-search/nominatim-ui" +default[:nominatim][:ui_revision] = "master" default[:nominatim][:fpm_pools] = { :www => { diff --git a/cookbooks/nominatim/recipes/default.rb b/cookbooks/nominatim/recipes/default.rb index 0a9172b4b..75a893841 100644 --- a/cookbooks/nominatim/recipes/default.rb +++ b/cookbooks/nominatim/recipes/default.rb @@ -174,6 +174,7 @@ package %w[ source_directory = "#{basedir}/nominatim" build_directory = "#{basedir}/bin" +ui_directory = "#{basedir}/ui" 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 +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 @@ -401,7 +417,8 @@ nginx_site "nominatim" do 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 diff --git a/cookbooks/nominatim/templates/default/nginx.erb b/cookbooks/nominatim/templates/default/nginx.erb index 2e851c517..f42c60f3b 100644 --- a/cookbooks/nominatim/templates/default/nginx.erb +++ b/cookbooks/nominatim/templates/default/nginx.erb @@ -12,6 +12,20 @@ map $uri $nominatim_path_info { ~^/([^/]+)(.*)$ $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; } @@ -136,6 +150,11 @@ server { try_files $uri $uri/ @php; } + location /ui/ { + alias <%= @ui_directory %>/dist/; + index search.html; + } + 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"; + if ($forward_to_ui) { + rewrite ^(/[^/]*) http://$host/ui$1.html redirect; + } } location ~* \.php$ { @@ -168,5 +190,9 @@ server { 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; + } } }