mirror of
https://github.com/penpot/penpot.git
synced 2025-08-06 13:08:28 +02:00
🐛 Safari compatibility fixes
This commit is contained in:
parent
9260c59afb
commit
001f90a540
12 changed files with 164 additions and 75 deletions
|
@ -9,9 +9,41 @@
|
|||
|
||||
(ns app.config
|
||||
(:require
|
||||
[clojure.spec.alpha :as s]
|
||||
[app.common.spec :as us]
|
||||
[app.util.object :as obj]
|
||||
[app.util.dom :as dom]
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
(s/def ::platform #{:windows :linux :macos :other})
|
||||
(s/def ::browser #{:chrome :mozilla :safari :edge :other})
|
||||
|
||||
(defn parse-browser
|
||||
[]
|
||||
(let [user-agent (-> (dom/get-user-agent) str/lower)
|
||||
check-chrome? (fn [] (str/includes? user-agent "chrom"))
|
||||
check-firefox? (fn [] (str/includes? user-agent "firefox"))
|
||||
check-edge? (fn [] (str/includes? user-agent "edg"))
|
||||
check-safari? (fn [] (str/includes? user-agent "safari"))]
|
||||
(cond
|
||||
(check-edge?) :edge
|
||||
(check-chrome?) :chrome
|
||||
(check-firefox?) :firefox
|
||||
(check-safari?) :safari
|
||||
:else :other)))
|
||||
|
||||
(defn parse-platform
|
||||
[]
|
||||
(let [user-agent (-> (dom/get-user-agent) str/lower)
|
||||
check-windows? (fn [] (str/includes? user-agent "windows"))
|
||||
check-linux? (fn [] (str/includes? user-agent "linux"))
|
||||
check-macos? (fn [] (str/includes? user-agent "mac os"))]
|
||||
(cond
|
||||
(check-windows?) :windows
|
||||
(check-linux?) :linux
|
||||
(check-macos?) :macos
|
||||
:else :other)))
|
||||
|
||||
(this-as global
|
||||
(def default-language "en")
|
||||
(def demo-warning (obj/get global "appDemoWarning" false))
|
||||
|
@ -22,7 +54,17 @@
|
|||
(def public-uri (or (obj/get global "appPublicURI")
|
||||
(.-origin ^js js/location)))
|
||||
(def media-uri (str public-uri "/media"))
|
||||
(def default-theme "default"))
|
||||
(def default-theme "default")
|
||||
(def browser (parse-browser))
|
||||
(def platform (parse-platform)))
|
||||
|
||||
(defn ^boolean check-browser? [candidate]
|
||||
(us/verify ::browser candidate)
|
||||
(= candidate browser))
|
||||
|
||||
(defn ^boolean check-platform? [candidate]
|
||||
(us/verify ::platform candidate)
|
||||
(= candidate platform))
|
||||
|
||||
(defn resolve-media-path
|
||||
[path]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue