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