0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 06:58:58 -05:00

💄 Fix naming inconsistencies on uri prop.

This commit is contained in:
Andrey Antukh 2020-05-26 12:47:09 +02:00
parent 19cd84597d
commit 5983155680
10 changed files with 45 additions and 41 deletions

View file

@ -94,8 +94,9 @@ function readLocales() {
}
function readConfig(data) {
const publicURL = process.env.UXBOX_PUBLIC_URL;
const backendURL = process.env.UXBOX_BACKEND_URL;
const googleClientID = process.env.UXBOX_GOOGLE_CLIENT_ID;
const publicURI = process.env.UXBOX_PUBLIC_URI;
const backendURI = process.env.UXBOX_BACKEND_URI;
const demoWarn = process.env.UXBOX_DEMO_WARNING;
const deployDate = process.env.UXBOX_DEPLOY_DATE;
const deployCommit = process.env.UXBOX_DEPLOY_COMMIT;
@ -104,12 +105,16 @@ function readConfig(data) {
demoWarning: demoWarn === "true"
};
if (publicURL !== undefined) {
cfg.publicURL = publicURL;
if (googleClientID !== undefined) {
cfg.googleClientID = googleClientID;
}
if (backendURL !== undefined) {
cfg.backendURL = backendURL;
if (publicURI !== undefined) {
cfg.publicURI = publicURI;
}
if (backendURI !== undefined) {
cfg.backendURI = backendURI;
}
if (deployDate !== undefined) {

View file

@ -12,12 +12,11 @@
(this-as global
(let [config (obj/get global "uxboxConfig")
purl (obj/get config "publicURL" "http://localhost:3449")
burl (obj/get config "backendURL" "http://localhost:6060")
puri (obj/get config "publicURI" "http://localhost:3449")
buri (obj/get config "backendURI" "http://localhost:6060")
warn (obj/get config "demoWarning" true)]
(def default-language "en")
(def demo-warning warn)
(def url burl)
(def backend-url burl)
(def public-url purl)
(def backend-uri buri)
(def public-uri puri)
(def default-theme "default")))

View file

@ -42,9 +42,9 @@
ptk/UpdateEvent
(update [_ 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})]
(assoc-in state [:ws file-id] (ws/open url))))
(assoc-in state [:ws file-id] (ws/open uri))))
ptk/WatchEvent
(watch [_ state stream]

View file

@ -11,7 +11,7 @@
(:require
[beicon.core :as rx]
[cuerdas.core :as str]
[uxbox.config :refer [url]]
[uxbox.config :as cfg]
[uxbox.util.http-api :as http]))
(defn- handle-response
@ -29,14 +29,14 @@
(defn send-query!
[id params]
(let [url (str url "/api/w/query/" (name id))]
(->> (http/send! {:method :get :url url :query params})
(let [uri (str cfg/backend-uri "/api/w/query/" (name id))]
(->> (http/send! {:method :get :uri uri :query params})
(rx/mapcat handle-response))))
(defn send-mutation!
[id params]
(let [url (str url "/api/w/mutation/" (name id))]
(->> (http/send! {:method :post :url url :body params})
(let [uri (str cfg/backend-uri "/api/w/mutation/" (name id))]
(->> (http/send! {:method :post :uri uri :body params})
(rx/mapcat handle-response))))
(defn- dispatch
@ -64,8 +64,8 @@
(defmethod mutation :login-with-google
[id params]
(let [url (str url "/api/oauth/google")]
(->> (http/send! {:method :post :url url})
(let [uri (str cfg/backend-uri "/api/oauth/google")]
(->> (http/send! {:method :post :uri uri})
(rx/mapcat handle-response))))
(defmethod mutation :upload-image
@ -94,14 +94,14 @@
(defmethod mutation :login
[id params]
(let [url (str url "/api/login")]
(->> (http/send! {:method :post :url url :body params})
(let [uri (str cfg/backend-uri "/api/login")]
(->> (http/send! {:method :post :uri uri :body params})
(rx/mapcat handle-response))))
(defmethod mutation :logout
[id params]
(let [url (str url "/api/logout")]
(->> (http/send! {:method :post :url url :body params})
(let [uri (str cfg/backend-uri "/api/logout")]
(->> (http/send! {:method :post :uri uri :body params})
(rx/mapcat handle-response))))
(def client-error? http/client-error?)

View file

@ -22,9 +22,9 @@
(defonce instance
(when (not= *target* "nodejs")
(let [uri (Uri. cfg/public-url)]
(let [uri (Uri. cfg/public-uri)]
(.setPath uri "js/worker.js")
(.setParameterValue uri "backendURL" cfg/backend-url)
(.setParameterValue uri "backendURI" cfg/backend-uri)
(uw/init (.toString uri) on-error))))
(defn ask!

View file

@ -58,9 +58,9 @@
:blob ResponseType.BLOB
ResponseType.DEFAULT))
(defn- create-url
[url qs qp]
(let [uri (Uri. url)]
(defn- create-uri
[uri qs qp]
(let [uri (Uri. uri)]
(when qs (.setQuery uri qs))
(when qp
(let [dt (.createFromMap QueryData (clj->js qp))]
@ -68,10 +68,10 @@
(.toString uri)))
(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]
: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 {})
method (translate-method method)
xhr (doto (XhrIo.)

View file

@ -32,13 +32,13 @@
{"content-type" "application/transit+json"})
(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}}]
(let [headers (merge {"Accept" "application/transit+json,*/*"}
(when (map? body) default-headers)
headers)
request {:method method
:url url
:uri uri
:headers headers
:query query
:body (if (map? body)

View file

@ -24,10 +24,10 @@
(-send [_ message] "send a message")
(-close [_] "close websocket"))
(defn url
([path] (url path {}))
(defn uri
([path] (uri path {}))
([path params]
(let [uri (.parse Uri cfg/url)]
(let [uri (.parse Uri cfg/backend-uri)]
(.setPath uri path)
(if (= (.getScheme uri) "http")
(.setScheme uri "ws")

View file

@ -30,8 +30,8 @@
(this-as global
(let [location (obj/get global "location")
uri (Uri. (obj/get location "href"))
buri (.getParameterValue uri "backendURL")]
(swap! impl/config assoc :backend-url buri)))
buri (.getParameterValue uri "backendURI")]
(swap! impl/config assoc :backend-uri buri)))
;; --- Messages Handling

View file

@ -33,11 +33,11 @@
(defn- request-page
[id]
(let [url (get @impl/config :backend-url "http://localhost:6060")
url (str url "/api/w/query/page")]
(let [uri (get @impl/config :backend-uri "http://localhost:6060")
uri (str uri "/api/w/query/page")]
(p/create
(fn [resolve reject]
(->> (http/send! {:url url
(->> (http/send! {:uri uri
:query {:id id}
:method :get})
(rx/mapcat handle-response)