Merge pull request #8041 from penpot/niwinz-subpath-support

 Add several adjustments for make penpot run on subpath
This commit is contained in:
Alejandro Alonso 2026-01-26 07:34:24 +01:00 committed by GitHub
commit 18de7f1db6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 16 deletions

View File

@ -13,7 +13,7 @@
$weight: unquote("normal"), $weight: unquote("normal"),
$style: string.unquote("normal") $style: string.unquote("normal")
) { ) {
$filepath: "/fonts/" + $file; $filepath: "../fonts/" + $file;
@font-face { @font-face {
font-family: "#{$style-name}"; font-family: "#{$style-name}";
@ -29,7 +29,7 @@
} }
@mixin font-face-variable($style-name, $file, $unicode-range) { @mixin font-face-variable($style-name, $file, $unicode-range) {
$filepath: "/fonts/" + $file; $filepath: "../fonts/" + $file;
@font-face { @font-face {
font-family: "#{$style-name}"; font-family: "#{$style-name}";

View File

@ -111,12 +111,9 @@
(defn- normalize-uri (defn- normalize-uri
[uri-str] [uri-str]
(let [uri (u/uri uri-str)] ;; Ensure that the path always ends with "/"; this ensures that
;; Ensure that the path always ends with "/"; this ensures that ;; all path join operations works as expected.
;; all path join operations works as expected. (u/ensure-path-slash uri-str))
(cond-> uri
(not (str/ends-with? (:path uri) "/"))
(update :path #(str % "/")))))
(def public-uri (def public-uri
(normalize-uri (or (obj/get global "penpotPublicURI") (normalize-uri (or (obj/get global "penpotPublicURI")

View File

@ -12,6 +12,7 @@
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.logging :as log] [app.common.logging :as log]
[app.common.types.text :as txt] [app.common.types.text :as txt]
[app.common.uri :as u]
[app.config :as cf] [app.config :as cf]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.globals :as globals] [app.util.globals :as globals]
@ -19,7 +20,6 @@
[app.util.object :as obj] [app.util.object :as obj]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[cuerdas.core :as str] [cuerdas.core :as str]
[lambdaisland.uri :as u]
[okulary.core :as l] [okulary.core :as l]
[promesa.core :as p])) [promesa.core :as p]))
@ -138,13 +138,13 @@
"&display=block")] "&display=block")]
(dm/str (dm/str
(-> cf/public-uri (-> cf/public-uri
(assoc :path "/internal/gfonts/css") (u/join "internal/gfonts/css")
(assoc :query query))))) (assoc :query query)))))
(defn- process-gfont-css (defn- process-gfont-css
[css] [css]
(let [base (dm/str (assoc cf/public-uri :path "/internal/gfonts/font"))] (let [base (u/join cf/public-uri "internal/gfonts/font")]
(str/replace css "https://fonts.gstatic.com/s" base))) (str/replace css "https://fonts.gstatic.com/s" (dm/str base))))
(defn- fetch-gfont-css (defn- fetch-gfont-css
[url] [url]
@ -178,7 +178,9 @@
(defn- asset-id->uri (defn- asset-id->uri
[asset-id] [asset-id]
(str (u/join cf/public-uri "assets/by-id/" asset-id))) (-> cf/public-uri
(u/join "assets/by-id/" asset-id)
(str)))
(defn generate-custom-font-variant-css (defn generate-custom-font-variant-css
[family variant] [family variant]
@ -370,7 +372,7 @@
:else :else
(let [{:keys [weight style suffix]} (get-variant font font-variant-id) (let [{:keys [weight style suffix]} (get-variant font font-variant-id)
suffix (or suffix font-variant-id) suffix (or suffix font-variant-id)
params {:uri (dm/str cf/public-uri "fonts/" family "-" suffix ".woff") params {:uri (str (u/join cf/public-uri (str "fonts/" family "-" suffix ".woff")))
:family family :family family
:style style :style style
:weight weight}] :weight weight}]

View File

@ -14,6 +14,7 @@
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.logging :as log] [app.common.logging :as log]
[app.common.uri :as u]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.config :as cf] [app.config :as cf]
[app.util.dom :as dom] [app.util.dom :as dom]
@ -26,7 +27,9 @@
(defonce instance nil) (defonce instance nil)
(defonce msgbus (rx/subject)) (defonce msgbus (rx/subject))
(defonce origin (defonce origin
(dm/str (assoc cf/rasterizer-uri :path "/rasterizer.html"))) (-> cf/rasterizer-uri
(u/join "rasterizer.html")
(dm/str)))
(declare send-message!) (declare send-message!)
@ -129,7 +132,9 @@
(dom/append-child! js/document.body iframe) (dom/append-child! js/document.body iframe)
(set! instance iframe)) (set! instance iframe))
(let [new-origin (dm/str (assoc cf/public-uri :path "/rasterizer.html"))] (let [new-origin (-> cf/public-uri
(u/join "rasterizer.html")
(dm/str))]
(log/warn :hint "fallback to main domain" :origin new-origin) (log/warn :hint "fallback to main domain" :origin new-origin)
(dom/set-attribute! iframe "src" new-origin) (dom/set-attribute! iframe "src" new-origin)