mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 20:41:37 +02:00
🎉 Add version string parsing.
This commit is contained in:
parent
ac2310f71f
commit
28a2df96ff
6 changed files with 72 additions and 29 deletions
|
@ -10,15 +10,19 @@
|
|||
(ns app.config
|
||||
(:require
|
||||
[clojure.spec.alpha :as s]
|
||||
[app.common.data :as d]
|
||||
[app.common.spec :as us]
|
||||
[app.common.version :as v]
|
||||
[app.util.object :as obj]
|
||||
[app.util.dom :as dom]
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
;; --- Auxiliar Functions
|
||||
|
||||
(s/def ::platform #{:windows :linux :macos :other})
|
||||
(s/def ::browser #{:chrome :mozilla :safari :edge :other})
|
||||
|
||||
(defn parse-browser
|
||||
(defn- parse-browser
|
||||
[]
|
||||
(let [user-agent (-> (dom/get-user-agent) str/lower)
|
||||
check-chrome? (fn [] (str/includes? user-agent "chrom"))
|
||||
|
@ -32,7 +36,7 @@
|
|||
(check-safari?) :safari
|
||||
:else :other)))
|
||||
|
||||
(defn parse-platform
|
||||
(defn- parse-platform
|
||||
[]
|
||||
(let [user-agent (-> (dom/get-user-agent) str/lower)
|
||||
check-windows? (fn [] (str/includes? user-agent "windows"))
|
||||
|
@ -44,6 +48,10 @@
|
|||
(check-macos?) :macos
|
||||
:else :other)))
|
||||
|
||||
;; --- Globar Config Vars
|
||||
|
||||
(def default-theme "default")
|
||||
|
||||
(this-as global
|
||||
(def default-language "en")
|
||||
(def demo-warning (obj/get global "appDemoWarning" false))
|
||||
|
@ -53,10 +61,18 @@
|
|||
(def worker-uri (obj/get global "appWorkerURI" "/js/worker.js"))
|
||||
(def public-uri (or (obj/get global "appPublicURI")
|
||||
(.-origin ^js js/location)))
|
||||
(def media-uri (str public-uri "/media"))
|
||||
(def default-theme "default")
|
||||
(def browser (parse-browser))
|
||||
(def platform (parse-platform)))
|
||||
(def version (v/parse (obj/get global "appVersion"))))
|
||||
|
||||
|
||||
(def media-uri (str public-uri "/media"))
|
||||
(def browser (parse-browser))
|
||||
(def platform (parse-platform))
|
||||
|
||||
(js/console.log
|
||||
(str/format "Welcome to pentpot! Version: '%s'" (:full version)))
|
||||
|
||||
;; --- Helper Functions
|
||||
|
||||
|
||||
(defn ^boolean check-browser? [candidate]
|
||||
(us/verify ::browser candidate)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue