From 33c9956cf7b4f4b596872e349c8c284080677eee Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Thu, 29 May 2025 03:35:06 +0200 Subject: [PATCH] Write share sidebar in erb template --- app/abilities/ability.rb | 2 +- app/assets/javascripts/leaflet.share.js | 259 +++------------------- app/controllers/share_panes_controller.rb | 9 + app/views/share_panes/show.html.erb | 85 +++++++ config/locales/en.yml | 2 +- config/routes.rb | 1 + 6 files changed, 124 insertions(+), 234 deletions(-) create mode 100644 app/controllers/share_panes_controller.rb create mode 100644 app/views/share_panes/show.html.erb diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index f68449aa8..fefa361b4 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -4,7 +4,7 @@ class Ability include CanCan::Ability def initialize(user) - can :read, [:feature_query, :legend_pane] + can :read, [:feature_query, :legend_pane, :share_pane] can :read, [Node, Way, Relation, OldNode, OldWay, OldRelation] can [:show, :create], Note can :read, :directions diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js index fedfc4d31..4bca5ebd6 100644 --- a/app/assets/javascripts/leaflet.share.js +++ b/app/assets/javascripts/leaflet.share.js @@ -6,251 +6,37 @@ L.OSM.share = function (options) { adjustButton: false }); - control.onAddPane = function (map, button, $ui) { + function init(map, $ui) { // Link / Embed - $("#content").addClass("overlay-right-sidebar"); - const $linkSection = $("
") - .attr("class", "share-link p-3 border-bottom border-secondary-subtle") - .appendTo($ui); - - $("

") - .text(OSM.i18n.t("javascripts.share.link")) - .appendTo($linkSection); - - let $form = $("
") - .appendTo($linkSection); - - $("
") - .attr("class", "form-check mb-3") - .appendTo($form) - .append($("