diff --git a/resources/frontend_client/embed_script.js b/resources/frontend_client/embed_script.js deleted file mode 100644 index fe4dc329a30bd552adcbb8edec77eefcd50bca9b..0000000000000000000000000000000000000000 --- a/resources/frontend_client/embed_script.js +++ /dev/null @@ -1,62 +0,0 @@ -(function() { - var scriptUrl; - try { - throw new Error(); - } catch (e) { - scriptUrl = e.stack.match( - /https?:\/\/[\w_-]+(\.[\w_-]+)*(\:\d+)?\/[^:\s]+\.js/ - )[0]; - } - - var scripts = document.getElementsByTagName("script"); - var script; - for (var i = scripts.length - 1; i >= 0; i--) { - if (scripts[i].src === scriptUrl) { - script = scripts[i]; - break; - } - } - - var iframeAttrsMap = { - width: "800", - height: "600", - frameborder: "0", - allowtransparency: "allowtransparency" - }; - var hashParamsMap = {}; - - if (script) { - for (var name in script.dataset) { - if (name in iframeAttrsMap) { - iframeAttrsMap[name] = script.dataset[name]; - } else { - hashParamsMap[name] = script.dataset[name]; - } - } - } - - var hashParamsStr = Object.keys(hashParamsMap) - .map(function(name) { - return name + "=" + hashParamsMap[name]; - }) - .join("&"); - - iframeAttrsMap["src"] = scriptUrl.replace(/\.js$/, "") + (hashParamsStr ? "#" + hashParamsStr : ""); - iframeAttrsMap["onload"] = "iFrameResize({}, this)"; - - var iframeAttrs = Object.keys(iframeAttrsMap) - .map(function(name) { - return name + "=" + JSON.stringify(iframeAttrsMap[name]); - }) - .join(" "); - - if (!window.iFrameResize) { - document.write( - '<script src="node_modules/iframe-resizer/js/iframeResizer.js" charset="utf-8"></script>' - ); - } - - console.log("iframeAttrs", iframeAttrs) - - document.write('<iframe ' + iframeAttrs + '></iframe>'); -})(); diff --git a/src/metabase/routes.clj b/src/metabase/routes.clj index 6fafcc0e567268322c18940545e922323d310806..f33dfdbed2035c157e2cdc34f71c3782a9855310 100644 --- a/src/metabase/routes.clj +++ b/src/metabase/routes.clj @@ -32,21 +32,14 @@ (def ^:private public (partial entrypoint "public" :embeddable)) (def ^:private embed (partial entrypoint "embed" :embeddable)) -(defn- embed-script [] - (-> (load-file "frontend_client/embed_script.js") - resp/response - (resp/content-type "application/javascript; charset=utf-8"))) - (defroutes ^:private public-routes (GET ["/question/:uuid.csv" :uuid u/uuid-regex] [uuid] (resp/redirect (format "/api/public/card/%s/query/csv" uuid))) (GET ["/question/:uuid.json" :uuid u/uuid-regex] [uuid] (resp/redirect (format "/api/public/card/%s/query/json" uuid))) - (GET "/:type/:uuid.js" [] (embed-script)) (GET "*" [] public)) (defroutes ^:private embed-routes (GET "/question/:token.csv" [token] (resp/redirect (format "/api/embed/card/%s/query/csv" token))) (GET "/question/:token.json" [token] (resp/redirect (format "/api/embed/card/%s/query/json" token))) - (GET "/:type/:uuid.js" [] (embed-script)) (GET "*" [] embed)) ;; Redirect naughty users who try to visit a page other than setup if setup is not yet complete