From 4c393defb7901f581b503336ab08bfb2ca775930 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 23 Oct 2023 00:45:40 +0200 Subject: [PATCH] Add `ModalController#close` action --- app/controllers/modal_controller.rb | 13 +++++++++++++ app/views/layouts/base.html.haml | 1 + config/routes.rb | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 app/controllers/modal_controller.rb diff --git a/app/controllers/modal_controller.rb b/app/controllers/modal_controller.rb new file mode 100644 index 00000000..16ae890e --- /dev/null +++ b/app/controllers/modal_controller.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class ModalController < ApplicationController + include ActionView::Helpers::TagHelper + include Turbo::FramesHelper + + skip_before_action :find_active_announcements, :banned? + + def close + redirect_to root_path unless turbo_frame_request? + render inline: turbo_frame_tag("modal") + end +end diff --git a/app/views/layouts/base.html.haml b/app/views/layouts/base.html.haml index 0607c377..cf829de8 100644 --- a/app/views/layouts/base.html.haml +++ b/app/views/layouts/base.html.haml @@ -32,6 +32,7 @@ = yield = render "shared/formatting" = render "shared/hotkeys" + = turbo_frame_tag "modal" .d-none#toasts - if Rails.env.development? #debug diff --git a/config/routes.rb b/config/routes.rb index 51e170f9..5fcac30f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -181,5 +181,7 @@ Rails.application.routes.draw do get "/nodeinfo/2.1", to: "well_known/node_info#nodeinfo", as: :node_info + get "/modal/close", to: "modal#close", as: :modal_close + puts "processing time of routes.rb: #{"#{(Time.zone.now - start).round(3).to_s.ljust(5, '0')}s".light_green}" end