From 994bd1fe5cf54f4995e2fe34e8e13122a3d23664 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Wed, 31 Jul 2024 10:41:28 +0300 Subject: [PATCH] dummy script --- app/controllers/embed_scripts_controller.rb | 39 +++++++++++++++++++++ config/routes.rb | 2 ++ 2 files changed, 41 insertions(+) create mode 100644 app/controllers/embed_scripts_controller.rb diff --git a/app/controllers/embed_scripts_controller.rb b/app/controllers/embed_scripts_controller.rb new file mode 100644 index 00000000..874c21f3 --- /dev/null +++ b/app/controllers/embed_scripts_controller.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +class EmbedScriptsController < ActionController::Metal + DUMMY_SCRIPT = <<~JAVASCRIPT.freeze + const DummyBuilder = class extends HTMLElement { + connectedCallback() { + this.innerHTML = ` +
+

Upgrade to Pro

+

Unlock embedded components by upgrading to Pro

+
+ + Learn More + +
+
+ `; + } + }; + + const DummyForm = class extends DummyBuilder {}; + + if (!window.customElements.get('docuseal-builder')) { + window.customElements.define('docuseal-builder', DummyBuilder); + } + + if (!window.customElements.get('docuseal-form')) { + window.customElements.define('docuseal-form', DummyForm); + } + JAVASCRIPT + + def show + headers['Content-Type'] = 'application/javascript' + + self.response_body = DUMMY_SCRIPT + + self.status = 200 + end +end diff --git a/config/routes.rb b/config/routes.rb index a3e90fc8..7874959f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -166,5 +166,7 @@ Rails.application.routes.draw do end end + get '/js/:filename', to: 'embed_scripts#show', as: :embed_script + ActiveSupport.run_load_hooks(:routes, self) end