From 9ac70151a8cb66ea9d68f433c832a3fc61e6882b Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Fri, 8 Dec 2023 12:55:18 +0300 Subject: [PATCH 1/1] Load map key data in controller --- app/controllers/site_controller.rb | 1 + app/views/site/key.html.erb | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 5fb8aa111..dce5faf54 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -48,6 +48,7 @@ class SiteController < ApplicationController def key expires_in 7.days, :public => true + @key = YAML.load_file(Rails.root.join("config/key.yml")) render :layout => false end diff --git a/app/views/site/key.html.erb b/app/views/site/key.html.erb index d3da86856..60eff9a44 100644 --- a/app/views/site/key.html.erb +++ b/app/views/site/key.html.erb @@ -1,13 +1,13 @@
- <% YAML.load_file(Rails.root.join("config/key.yml")).each do |name,data| %> - <% data.each do |entry| %> - <%= tag.tr :class => "mapkey-table-entry", :data => { :layer => name, :zoom_min => entry["min_zoom"], :zoom_max => entry["max_zoom"] } do %> + <% @key.each do |layer_name, layer_data| %> + <% layer_data.each do |entry| %> + <%= tag.tr :class => "mapkey-table-entry", :data => { :layer => layer_name, :zoom_min => entry["min_zoom"], :zoom_max => entry["max_zoom"] } do %>
<% if entry["width"] && entry["height"] && entry["fill"] %> <%= image_tag "data:image/svg+xml,#{u("")}" %> <% else %> - <%= image_tag "key/#{name}/#{entry['image']}" %> + <%= image_tag "key/#{layer_name}/#{entry['image']}" %> <% end %> -- 2.39.5