mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 22:06:38 +02:00
💄 Fix naming inconsistencies on uri prop.
This commit is contained in:
parent
19cd84597d
commit
5983155680
10 changed files with 45 additions and 41 deletions
|
@ -94,8 +94,9 @@ function readLocales() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function readConfig(data) {
|
function readConfig(data) {
|
||||||
const publicURL = process.env.UXBOX_PUBLIC_URL;
|
const googleClientID = process.env.UXBOX_GOOGLE_CLIENT_ID;
|
||||||
const backendURL = process.env.UXBOX_BACKEND_URL;
|
const publicURI = process.env.UXBOX_PUBLIC_URI;
|
||||||
|
const backendURI = process.env.UXBOX_BACKEND_URI;
|
||||||
const demoWarn = process.env.UXBOX_DEMO_WARNING;
|
const demoWarn = process.env.UXBOX_DEMO_WARNING;
|
||||||
const deployDate = process.env.UXBOX_DEPLOY_DATE;
|
const deployDate = process.env.UXBOX_DEPLOY_DATE;
|
||||||
const deployCommit = process.env.UXBOX_DEPLOY_COMMIT;
|
const deployCommit = process.env.UXBOX_DEPLOY_COMMIT;
|
||||||
|
@ -104,12 +105,16 @@ function readConfig(data) {
|
||||||
demoWarning: demoWarn === "true"
|
demoWarning: demoWarn === "true"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (publicURL !== undefined) {
|
if (googleClientID !== undefined) {
|
||||||
cfg.publicURL = publicURL;
|
cfg.googleClientID = googleClientID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backendURL !== undefined) {
|
if (publicURI !== undefined) {
|
||||||
cfg.backendURL = backendURL;
|
cfg.publicURI = publicURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backendURI !== undefined) {
|
||||||
|
cfg.backendURI = backendURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deployDate !== undefined) {
|
if (deployDate !== undefined) {
|
||||||
|
|
|
@ -12,12 +12,11 @@
|
||||||
|
|
||||||
(this-as global
|
(this-as global
|
||||||
(let [config (obj/get global "uxboxConfig")
|
(let [config (obj/get global "uxboxConfig")
|
||||||
purl (obj/get config "publicURL" "http://localhost:3449")
|
puri (obj/get config "publicURI" "http://localhost:3449")
|
||||||
burl (obj/get config "backendURL" "http://localhost:6060")
|
buri (obj/get config "backendURI" "http://localhost:6060")
|
||||||
warn (obj/get config "demoWarning" true)]
|
warn (obj/get config "demoWarning" true)]
|
||||||
(def default-language "en")
|
(def default-language "en")
|
||||||
(def demo-warning warn)
|
(def demo-warning warn)
|
||||||
(def url burl)
|
(def backend-uri buri)
|
||||||
(def backend-url burl)
|
(def public-uri puri)
|
||||||
(def public-url purl)
|
|
||||||
(def default-theme "default")))
|
(def default-theme "default")))
|
||||||
|
|
|
@ -42,9 +42,9 @@
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [sid (:session-id state)
|
(let [sid (:session-id state)
|
||||||
url (ws/url "/ws/notifications" {:file-id file-id
|
uri (ws/uri "/ws/notifications" {:file-id file-id
|
||||||
:session-id sid})]
|
:session-id sid})]
|
||||||
(assoc-in state [:ws file-id] (ws/open url))))
|
(assoc-in state [:ws file-id] (ws/open uri))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
(:require
|
(:require
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.config :refer [url]]
|
[uxbox.config :as cfg]
|
||||||
[uxbox.util.http-api :as http]))
|
[uxbox.util.http-api :as http]))
|
||||||
|
|
||||||
(defn- handle-response
|
(defn- handle-response
|
||||||
|
@ -29,14 +29,14 @@
|
||||||
|
|
||||||
(defn send-query!
|
(defn send-query!
|
||||||
[id params]
|
[id params]
|
||||||
(let [url (str url "/api/w/query/" (name id))]
|
(let [uri (str cfg/backend-uri "/api/w/query/" (name id))]
|
||||||
(->> (http/send! {:method :get :url url :query params})
|
(->> (http/send! {:method :get :uri uri :query params})
|
||||||
(rx/mapcat handle-response))))
|
(rx/mapcat handle-response))))
|
||||||
|
|
||||||
(defn send-mutation!
|
(defn send-mutation!
|
||||||
[id params]
|
[id params]
|
||||||
(let [url (str url "/api/w/mutation/" (name id))]
|
(let [uri (str cfg/backend-uri "/api/w/mutation/" (name id))]
|
||||||
(->> (http/send! {:method :post :url url :body params})
|
(->> (http/send! {:method :post :uri uri :body params})
|
||||||
(rx/mapcat handle-response))))
|
(rx/mapcat handle-response))))
|
||||||
|
|
||||||
(defn- dispatch
|
(defn- dispatch
|
||||||
|
@ -64,8 +64,8 @@
|
||||||
|
|
||||||
(defmethod mutation :login-with-google
|
(defmethod mutation :login-with-google
|
||||||
[id params]
|
[id params]
|
||||||
(let [url (str url "/api/oauth/google")]
|
(let [uri (str cfg/backend-uri "/api/oauth/google")]
|
||||||
(->> (http/send! {:method :post :url url})
|
(->> (http/send! {:method :post :uri uri})
|
||||||
(rx/mapcat handle-response))))
|
(rx/mapcat handle-response))))
|
||||||
|
|
||||||
(defmethod mutation :upload-image
|
(defmethod mutation :upload-image
|
||||||
|
@ -94,14 +94,14 @@
|
||||||
|
|
||||||
(defmethod mutation :login
|
(defmethod mutation :login
|
||||||
[id params]
|
[id params]
|
||||||
(let [url (str url "/api/login")]
|
(let [uri (str cfg/backend-uri "/api/login")]
|
||||||
(->> (http/send! {:method :post :url url :body params})
|
(->> (http/send! {:method :post :uri uri :body params})
|
||||||
(rx/mapcat handle-response))))
|
(rx/mapcat handle-response))))
|
||||||
|
|
||||||
(defmethod mutation :logout
|
(defmethod mutation :logout
|
||||||
[id params]
|
[id params]
|
||||||
(let [url (str url "/api/logout")]
|
(let [uri (str cfg/backend-uri "/api/logout")]
|
||||||
(->> (http/send! {:method :post :url url :body params})
|
(->> (http/send! {:method :post :uri uri :body params})
|
||||||
(rx/mapcat handle-response))))
|
(rx/mapcat handle-response))))
|
||||||
|
|
||||||
(def client-error? http/client-error?)
|
(def client-error? http/client-error?)
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
|
|
||||||
(defonce instance
|
(defonce instance
|
||||||
(when (not= *target* "nodejs")
|
(when (not= *target* "nodejs")
|
||||||
(let [uri (Uri. cfg/public-url)]
|
(let [uri (Uri. cfg/public-uri)]
|
||||||
(.setPath uri "js/worker.js")
|
(.setPath uri "js/worker.js")
|
||||||
(.setParameterValue uri "backendURL" cfg/backend-url)
|
(.setParameterValue uri "backendURI" cfg/backend-uri)
|
||||||
(uw/init (.toString uri) on-error))))
|
(uw/init (.toString uri) on-error))))
|
||||||
|
|
||||||
(defn ask!
|
(defn ask!
|
||||||
|
|
|
@ -58,9 +58,9 @@
|
||||||
:blob ResponseType.BLOB
|
:blob ResponseType.BLOB
|
||||||
ResponseType.DEFAULT))
|
ResponseType.DEFAULT))
|
||||||
|
|
||||||
(defn- create-url
|
(defn- create-uri
|
||||||
[url qs qp]
|
[uri qs qp]
|
||||||
(let [uri (Uri. url)]
|
(let [uri (Uri. uri)]
|
||||||
(when qs (.setQuery uri qs))
|
(when qs (.setQuery uri qs))
|
||||||
(when qp
|
(when qp
|
||||||
(let [dt (.createFromMap QueryData (clj->js qp))]
|
(let [dt (.createFromMap QueryData (clj->js qp))]
|
||||||
|
@ -68,10 +68,10 @@
|
||||||
(.toString uri)))
|
(.toString uri)))
|
||||||
|
|
||||||
(defn- fetch
|
(defn- fetch
|
||||||
[{:keys [method url query-string query headers body] :as request}
|
[{:keys [method uri query-string query headers body] :as request}
|
||||||
{:keys [timeout credentials? response-type]
|
{:keys [timeout credentials? response-type]
|
||||||
:or {timeout 0 credentials? false response-type :text}}]
|
:or {timeout 0 credentials? false response-type :text}}]
|
||||||
(let [uri (create-url url query-string query)
|
(let [uri (create-uri uri query-string query)
|
||||||
headers (if headers (clj->js headers) #js {})
|
headers (if headers (clj->js headers) #js {})
|
||||||
method (translate-method method)
|
method (translate-method method)
|
||||||
xhr (doto (XhrIo.)
|
xhr (doto (XhrIo.)
|
||||||
|
|
|
@ -32,13 +32,13 @@
|
||||||
{"content-type" "application/transit+json"})
|
{"content-type" "application/transit+json"})
|
||||||
|
|
||||||
(defn- impl-send
|
(defn- impl-send
|
||||||
[{:keys [body headers auth method query url response-type]
|
[{:keys [body headers auth method query uri response-type]
|
||||||
:or {auth true response-type :text}}]
|
:or {auth true response-type :text}}]
|
||||||
(let [headers (merge {"Accept" "application/transit+json,*/*"}
|
(let [headers (merge {"Accept" "application/transit+json,*/*"}
|
||||||
(when (map? body) default-headers)
|
(when (map? body) default-headers)
|
||||||
headers)
|
headers)
|
||||||
request {:method method
|
request {:method method
|
||||||
:url url
|
:uri uri
|
||||||
:headers headers
|
:headers headers
|
||||||
:query query
|
:query query
|
||||||
:body (if (map? body)
|
:body (if (map? body)
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
(-send [_ message] "send a message")
|
(-send [_ message] "send a message")
|
||||||
(-close [_] "close websocket"))
|
(-close [_] "close websocket"))
|
||||||
|
|
||||||
(defn url
|
(defn uri
|
||||||
([path] (url path {}))
|
([path] (uri path {}))
|
||||||
([path params]
|
([path params]
|
||||||
(let [uri (.parse Uri cfg/url)]
|
(let [uri (.parse Uri cfg/backend-uri)]
|
||||||
(.setPath uri path)
|
(.setPath uri path)
|
||||||
(if (= (.getScheme uri) "http")
|
(if (= (.getScheme uri) "http")
|
||||||
(.setScheme uri "ws")
|
(.setScheme uri "ws")
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
(this-as global
|
(this-as global
|
||||||
(let [location (obj/get global "location")
|
(let [location (obj/get global "location")
|
||||||
uri (Uri. (obj/get location "href"))
|
uri (Uri. (obj/get location "href"))
|
||||||
buri (.getParameterValue uri "backendURL")]
|
buri (.getParameterValue uri "backendURI")]
|
||||||
(swap! impl/config assoc :backend-url buri)))
|
(swap! impl/config assoc :backend-uri buri)))
|
||||||
|
|
||||||
;; --- Messages Handling
|
;; --- Messages Handling
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,11 @@
|
||||||
|
|
||||||
(defn- request-page
|
(defn- request-page
|
||||||
[id]
|
[id]
|
||||||
(let [url (get @impl/config :backend-url "http://localhost:6060")
|
(let [uri (get @impl/config :backend-uri "http://localhost:6060")
|
||||||
url (str url "/api/w/query/page")]
|
uri (str uri "/api/w/query/page")]
|
||||||
(p/create
|
(p/create
|
||||||
(fn [resolve reject]
|
(fn [resolve reject]
|
||||||
(->> (http/send! {:url url
|
(->> (http/send! {:uri uri
|
||||||
:query {:id id}
|
:query {:id id}
|
||||||
:method :get})
|
:method :get})
|
||||||
(rx/mapcat handle-response)
|
(rx/mapcat handle-response)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue