mirror of
https://github.com/penpot/penpot.git
synced 2025-08-01 05:58:24 +02:00
✨ Add more adaptations to make app run in a prefixed path.
This commit is contained in:
parent
2828ccda7f
commit
55ea84a056
14 changed files with 115 additions and 98 deletions
|
@ -6,14 +6,15 @@
|
|||
|
||||
(ns app.config
|
||||
(:require
|
||||
[clojure.spec.alpha :as s]
|
||||
[app.common.data :as d]
|
||||
[app.common.uri :as u]
|
||||
[app.common.spec :as us]
|
||||
[app.common.version :as v]
|
||||
[app.util.avatars :as avatars]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.globals :refer [global location]]
|
||||
[app.util.object :as obj]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.avatars :as avatars]
|
||||
[clojure.spec.alpha :as s]
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
;; --- Auxiliar Functions
|
||||
|
@ -76,16 +77,24 @@
|
|||
(def translations (obj/get global "penpotTranslations"))
|
||||
(def themes (obj/get global "penpotThemes"))
|
||||
|
||||
(def public-uri (or (obj/get global "penpotPublicURI") (.-origin ^js location)))
|
||||
|
||||
(def version (delay (parse-version global)))
|
||||
(def target (delay (parse-target global)))
|
||||
(def browser (delay (parse-browser)))
|
||||
(def platform (delay (parse-platform)))
|
||||
|
||||
(def public-uri
|
||||
(let [uri (u/uri (or (obj/get global "penpotPublicURI")
|
||||
(str (.-origin ^js location)
|
||||
(.-pathname ^js location))))]
|
||||
;; Ensure that the path always ends with "/"; this ensures that
|
||||
;; all path join operations works as expected.
|
||||
(cond-> uri
|
||||
(not (str/ends-with? (:path uri) "/"))
|
||||
(update :path #(str % "/")))))
|
||||
|
||||
(when (= :browser @target)
|
||||
(js/console.log
|
||||
(str/format "Welcome to penpot! Version: '%s'." (:full @version))))
|
||||
(str/format "Welcome to penpot! version='%s' base-uri='%s'." (:full @version) (str public-uri))))
|
||||
|
||||
;; --- Helper Functions
|
||||
|
||||
|
@ -101,18 +110,20 @@
|
|||
[{:keys [photo-id fullname name] :as profile}]
|
||||
(if (nil? photo-id)
|
||||
(avatars/generate {:name (or fullname name)})
|
||||
(str public-uri "/assets/by-id/" photo-id)))
|
||||
(str (u/join public-uri "assets/by-id/" photo-id))))
|
||||
|
||||
(defn resolve-team-photo-url
|
||||
[{:keys [photo-id name] :as team}]
|
||||
(if (nil? photo-id)
|
||||
(avatars/generate {:name name})
|
||||
(str public-uri "/assets/by-id/" photo-id)))
|
||||
(str (u/join public-uri "assets/by-id/" photo-id))))
|
||||
|
||||
(defn resolve-file-media
|
||||
([media]
|
||||
(resolve-file-media media false))
|
||||
([{:keys [id] :as media} thumnail?]
|
||||
(str public-uri "/assets/by-file-media-id/" id (when thumnail? "/thumbnail"))))
|
||||
(str (cond-> (u/join public-uri "assets/by-file-media-id/")
|
||||
(true? thumnail?) (u/join (str id "/thumbnail"))
|
||||
(false? thumnail?) (u/join (str id))))))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue