mirror of
https://github.com/penpot/penpot.git
synced 2025-05-19 14:36:10 +02:00
✨ Remove atom wrapping on public-uri
This commit is contained in:
parent
d11b007795
commit
0aefd044dc
14 changed files with 41 additions and 43 deletions
|
@ -107,13 +107,12 @@
|
||||||
(update :path #(str % "/")))))
|
(update :path #(str % "/")))))
|
||||||
|
|
||||||
(def public-uri
|
(def public-uri
|
||||||
(atom
|
(normalize-uri (or (obj/get global "penpotPublicURI")
|
||||||
(normalize-uri (or (obj/get global "penpotPublicURI")
|
(obj/get location "origin"))))
|
||||||
(obj/get location "origin")))))
|
|
||||||
|
|
||||||
(def thumbnail-renderer-uri
|
(def thumbnail-renderer-uri
|
||||||
(or (some-> (obj/get global "penpotThumbnailRendererURI") normalize-uri)
|
(or (some-> (obj/get global "penpotThumbnailRendererURI") normalize-uri)
|
||||||
(deref public-uri)))
|
public-uri))
|
||||||
|
|
||||||
(def worker-uri
|
(def worker-uri
|
||||||
(obj/get global "penpotWorkerURI" "/js/worker.js"))
|
(obj/get global "penpotWorkerURI" "/js/worker.js"))
|
||||||
|
@ -132,18 +131,19 @@
|
||||||
[{:keys [photo-id fullname name] :as profile}]
|
[{:keys [photo-id fullname name] :as profile}]
|
||||||
(if (nil? photo-id)
|
(if (nil? photo-id)
|
||||||
(avatars/generate {:name (or fullname name)})
|
(avatars/generate {:name (or fullname name)})
|
||||||
(str (u/join @public-uri "assets/by-id/" photo-id))))
|
(dm/str (u/join public-uri "assets/by-id/" photo-id))))
|
||||||
|
|
||||||
(defn resolve-team-photo-url
|
(defn resolve-team-photo-url
|
||||||
[{:keys [photo-id name] :as team}]
|
[{:keys [photo-id name] :as team}]
|
||||||
(if (nil? photo-id)
|
(if (nil? photo-id)
|
||||||
(avatars/generate {:name name})
|
(avatars/generate {:name name})
|
||||||
(str (u/join @public-uri "assets/by-id/" photo-id))))
|
(dm/str (u/join public-uri "assets/by-id/" photo-id))))
|
||||||
|
|
||||||
(defn resolve-file-media
|
(defn resolve-file-media
|
||||||
([media]
|
([media]
|
||||||
(resolve-file-media media false))
|
(resolve-file-media media false))
|
||||||
([{:keys [id] :as media} thumbnail?]
|
([{:keys [id] :as media} thumbnail?]
|
||||||
(str (cond-> (u/join @public-uri "assets/by-file-media-id/")
|
(dm/str
|
||||||
(true? thumbnail?) (u/join (str id "/thumbnail"))
|
(cond-> (u/join public-uri "assets/by-file-media-id/")
|
||||||
(false? thumbnail?) (u/join (str id))))))
|
(true? thumbnail?) (u/join (dm/str id "/thumbnail"))
|
||||||
|
(false? thumbnail?) (u/join (dm/str id))))))
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(ns app.main
|
(ns app.main
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.common.logging :as log]
|
[app.common.logging :as log]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
|
@ -40,7 +41,7 @@
|
||||||
:version (:full @cf/version)
|
:version (:full @cf/version)
|
||||||
:asserts *assert*
|
:asserts *assert*
|
||||||
:build-date cf/build-date
|
:build-date cf/build-date
|
||||||
:public-uri (str @cf/public-uri)))
|
:public-uri (dm/str cf/public-uri)))
|
||||||
|
|
||||||
(declare reinit)
|
(declare reinit)
|
||||||
|
|
||||||
|
|
|
@ -475,7 +475,7 @@
|
||||||
(rx/map (fn [params]
|
(rx/map (fn [params]
|
||||||
(rt/resolve router :auth-verify-token {} params)))
|
(rt/resolve router :auth-verify-token {} params)))
|
||||||
(rx/map (fn [fragment]
|
(rx/map (fn [fragment]
|
||||||
(assoc @cf/public-uri :fragment fragment)))
|
(assoc cf/public-uri :fragment fragment)))
|
||||||
(rx/tap (fn [uri]
|
(rx/tap (fn [uri]
|
||||||
(wapi/write-to-clipboard (str uri))))
|
(wapi/write-to-clipboard (str uri))))
|
||||||
(rx/tap on-success)
|
(rx/tap on-success)
|
||||||
|
|
|
@ -215,7 +215,7 @@
|
||||||
(defn- persist-events
|
(defn- persist-events
|
||||||
[events]
|
[events]
|
||||||
(if (seq events)
|
(if (seq events)
|
||||||
(let [uri (u/join @cf/public-uri "api/rpc/command/push-audit-events")
|
(let [uri (u/join cf/public-uri "api/rpc/command/push-audit-events")
|
||||||
params {:uri uri
|
params {:uri uri
|
||||||
:method :post
|
:method :post
|
||||||
:credentials "include"
|
:credentials "include"
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
(defn- prepare-uri
|
(defn- prepare-uri
|
||||||
[params]
|
[params]
|
||||||
(let [base (-> @cf/public-uri
|
(let [base (-> cf/public-uri
|
||||||
(u/join "ws/notifications")
|
(u/join "ws/notifications")
|
||||||
(assoc :query (u/map->query-string params)))]
|
(assoc :query (u/map->query-string params)))]
|
||||||
(cond-> base
|
(cond-> base
|
||||||
|
|
|
@ -160,7 +160,7 @@
|
||||||
|
|
||||||
(defn- asset-id->uri
|
(defn- asset-id->uri
|
||||||
[asset-id]
|
[asset-id]
|
||||||
(str (u/join @cf/public-uri "assets/by-id/" asset-id)))
|
(str (u/join cf/public-uri "assets/by-id/" asset-id)))
|
||||||
|
|
||||||
(defn generate-custom-font-variant-css
|
(defn generate-custom-font-variant-css
|
||||||
[family variant]
|
[family variant]
|
||||||
|
@ -281,7 +281,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 (dm/str cf/public-uri "fonts/" family "-" suffix ".woff")
|
||||||
:family family
|
:family family
|
||||||
:style style
|
:style style
|
||||||
:weight weight}]
|
:weight weight}]
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
:else :post)
|
:else :post)
|
||||||
|
|
||||||
request {:method method
|
request {:method method
|
||||||
:uri (u/join @cf/public-uri "api/rpc/command/" (name id))
|
:uri (u/join cf/public-uri "api/rpc/command/" (name id))
|
||||||
:credentials "include"
|
:credentials "include"
|
||||||
:headers {"accept" "application/transit+json"}
|
:headers {"accept" "application/transit+json"}
|
||||||
:body (when (= method :post)
|
:body (when (= method :post)
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
|
|
||||||
(defmethod cmd! :login-with-oidc
|
(defmethod cmd! :login-with-oidc
|
||||||
[_ {:keys [provider] :as params}]
|
[_ {:keys [provider] :as params}]
|
||||||
(let [uri (u/join @cf/public-uri "api/auth/oauth/" (d/name provider))
|
(let [uri (u/join cf/public-uri "api/auth/oauth/" (d/name provider))
|
||||||
params (dissoc params :provider)]
|
params (dissoc params :provider)]
|
||||||
(->> (http/send! {:method :post
|
(->> (http/send! {:method :post
|
||||||
:uri uri
|
:uri uri
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
(defn- send-export
|
(defn- send-export
|
||||||
[{:keys [blob?] :as params}]
|
[{:keys [blob?] :as params}]
|
||||||
(->> (http/send! {:method :post
|
(->> (http/send! {:method :post
|
||||||
:uri (u/join @cf/public-uri "api/export")
|
:uri (u/join cf/public-uri "api/export")
|
||||||
:body (http/transit-data (dissoc params :blob?))
|
:body (http/transit-data (dissoc params :blob?))
|
||||||
:credentials "include"
|
:credentials "include"
|
||||||
:response-type (if blob? :blob :text)})
|
:response-type (if blob? :blob :text)})
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
(defmethod cmd! ::multipart-upload
|
(defmethod cmd! ::multipart-upload
|
||||||
[id params]
|
[id params]
|
||||||
(->> (http/send! {:method :post
|
(->> (http/send! {:method :post
|
||||||
:uri (u/join @cf/public-uri "api/rpc/command/" (name id))
|
:uri (u/join cf/public-uri "api/rpc/command/" (name id))
|
||||||
:credentials "include"
|
:credentials "include"
|
||||||
:body (http/form-data params)})
|
:body (http/form-data params)})
|
||||||
(rx/map http/conditional-decode-transit)
|
(rx/map http/conditional-decode-transit)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(ns app.main.ui.onboarding.templates
|
(ns app.main.ui.onboarding.templates
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
@ -21,7 +22,7 @@
|
||||||
(mf/defc template-item
|
(mf/defc template-item
|
||||||
[{:keys [name path image project-id]}]
|
[{:keys [name path image project-id]}]
|
||||||
(let [downloading? (mf/use-state false)
|
(let [downloading? (mf/use-state false)
|
||||||
link (str (assoc @cf/public-uri :path path))
|
link (dm/str (assoc cf/public-uri :path path))
|
||||||
|
|
||||||
on-finish-import
|
on-finish-import
|
||||||
(fn []
|
(fn []
|
||||||
|
|
|
@ -145,7 +145,7 @@
|
||||||
(assoc qparams :zoom zoom-type))
|
(assoc qparams :zoom zoom-type))
|
||||||
|
|
||||||
href (rt/resolve router :viewer pparams qparams)]
|
href (rt/resolve router :viewer pparams qparams)]
|
||||||
(assoc @cf/public-uri :fragment href)))]
|
(assoc cf/public-uri :fragment href)))]
|
||||||
(reset! link (some-> href str)))))
|
(reset! link (some-> href str)))))
|
||||||
|
|
||||||
[:div.modal-overlay.transparent.share-modal
|
[:div.modal-overlay.transparent.share-modal
|
||||||
|
|
|
@ -10,35 +10,30 @@
|
||||||
[app.main.errors :as err]
|
[app.main.errors :as err]
|
||||||
[app.util.worker :as uw]))
|
[app.util.worker :as uw]))
|
||||||
|
|
||||||
(defonce instance (atom nil))
|
(defonce instance nil)
|
||||||
|
|
||||||
(defn- update-public-uri!
|
|
||||||
[instance val]
|
|
||||||
(uw/ask! instance {:cmd :configure
|
|
||||||
:key :public-uri
|
|
||||||
:val val}))
|
|
||||||
|
|
||||||
(defn init!
|
(defn init!
|
||||||
[]
|
[]
|
||||||
(let [worker (uw/init cf/worker-uri err/on-error)]
|
(let [worker (uw/init cf/worker-uri err/on-error)]
|
||||||
(update-public-uri! worker @cf/public-uri)
|
(uw/ask! worker {:cmd :configure
|
||||||
(add-watch cf/public-uri ::worker-public-uri (fn [_ _ _ val] (update-public-uri! worker val)))
|
:key :public-uri
|
||||||
(reset! instance worker)))
|
:val cf/public-uri})
|
||||||
|
(set! instance worker)))
|
||||||
|
|
||||||
(defn ask!
|
(defn ask!
|
||||||
([message]
|
([message]
|
||||||
(when @instance (uw/ask! @instance message)))
|
(when instance (uw/ask! instance message)))
|
||||||
([message transfer]
|
([message transfer]
|
||||||
(when @instance (uw/ask! @instance message transfer))))
|
(when instance (uw/ask! instance message transfer))))
|
||||||
|
|
||||||
(defn ask-buffered!
|
(defn ask-buffered!
|
||||||
([message]
|
([message]
|
||||||
(when @instance (uw/ask-buffered! @instance message)))
|
(when instance (uw/ask-buffered! instance message)))
|
||||||
([message transfer]
|
([message transfer]
|
||||||
(when @instance (uw/ask-buffered! @instance message transfer))))
|
(when instance (uw/ask-buffered! instance message transfer))))
|
||||||
|
|
||||||
(defn ask-many!
|
(defn ask-many!
|
||||||
([message]
|
([message]
|
||||||
(when @instance (uw/ask-many! @instance message)))
|
(when instance (uw/ask-many! instance message)))
|
||||||
([message transfer]
|
([message transfer]
|
||||||
(when @instance (uw/ask-many! @instance message transfer))))
|
(when instance (uw/ask-many! instance message transfer))))
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
(declare send-failure!)
|
(declare send-failure!)
|
||||||
|
|
||||||
(defonce parent-origin
|
(defonce parent-origin
|
||||||
(dm/str @cf/public-uri))
|
(dm/str cf/public-uri))
|
||||||
|
|
||||||
(defn- get-document-element
|
(defn- get-document-element
|
||||||
[^js svg]
|
[^js svg]
|
||||||
|
@ -237,9 +237,10 @@
|
||||||
[]
|
[]
|
||||||
(send-answer! nil "ready" nil))
|
(send-answer! nil "ready" nil))
|
||||||
|
|
||||||
;; Initializes worker
|
|
||||||
(defn ^:export init
|
(defn ^:export init
|
||||||
[]
|
[]
|
||||||
(listen)
|
(listen)
|
||||||
(send-ready!)
|
(send-ready!)
|
||||||
(log/info :hint "initialized" :public-uri @cf/public-uri))
|
(log/info :hint "initialized"
|
||||||
|
:public-uri (dm/str cf/public-uri)
|
||||||
|
:parent-uri (dm/str parent-origin)))
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
(let [router (:router state)
|
(let [router (:router state)
|
||||||
path (resolve router rname path-params query-params)
|
path (resolve router rname path-params query-params)
|
||||||
name (or name "_blank")
|
name (or name "_blank")
|
||||||
uri (assoc @cf/public-uri :fragment path)]
|
uri (assoc cf/public-uri :fragment path)]
|
||||||
(dom/open-new-window uri name nil)))))
|
(dom/open-new-window uri name nil)))))
|
||||||
|
|
||||||
(defn nav-back
|
(defn nav-back
|
||||||
|
|
|
@ -54,4 +54,4 @@
|
||||||
(log/info :hint "configure worker" :key key :val val)
|
(log/info :hint "configure worker" :key key :val val)
|
||||||
(case key
|
(case key
|
||||||
:public-uri
|
:public-uri
|
||||||
(reset! cf/public-uri val)))
|
(set! cf/public-uri val)))
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
:strip-frames-with-thumbnails true
|
:strip-frames-with-thumbnails true
|
||||||
:features features}
|
:features features}
|
||||||
request {:method :get
|
request {:method :get
|
||||||
:uri (u/join @cf/public-uri path)
|
:uri (u/join cf/public-uri path)
|
||||||
:credentials "include"
|
:credentials "include"
|
||||||
:query params}]
|
:query params}]
|
||||||
(->> (http/send! request)
|
(->> (http/send! request)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue