mirror of
https://github.com/penpot/penpot.git
synced 2025-02-01 11:59:17 -05:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
175072f546
8 changed files with 40 additions and 21773 deletions
|
@ -316,22 +316,6 @@
|
||||||
(let [v (if (string? v) (str/split v #"[\s,]+") v)]
|
(let [v (if (string? v) (str/split v #"[\s,]+") v)]
|
||||||
(into #{} non-empty-strings-xf v)))}})
|
(into #{} non-empty-strings-xf v)))}})
|
||||||
|
|
||||||
(def! ::set-of-keywords
|
|
||||||
{:type ::set-of-keywords
|
|
||||||
:pred #(and (set? %) (every? keyword? %))
|
|
||||||
:type-properties
|
|
||||||
{:title "set[string]"
|
|
||||||
:description "Set of Strings"
|
|
||||||
:error/message "should be a set of strings"
|
|
||||||
:gen/gen (-> :keyword sg/generator sg/set)
|
|
||||||
::oapi/type "array"
|
|
||||||
::oapi/format "set"
|
|
||||||
::oapi/items {:type "string" :format "keyword"}
|
|
||||||
::oapi/unique-items true
|
|
||||||
::oapi/decode (fn [v]
|
|
||||||
(let [v (if (string? v) (str/split v #"[\s,]+") v)]
|
|
||||||
(into #{} (comp non-empty-strings-xf (map keyword)) v)))}})
|
|
||||||
|
|
||||||
(def! ::set-of-emails
|
(def! ::set-of-emails
|
||||||
{:type ::set-of-emails
|
{:type ::set-of-emails
|
||||||
:pred #(and (set? %) (every? string? %))
|
:pred #(and (set? %) (every? string? %))
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
;;
|
|
||||||
;; Copyright (c) KALEIDOS INC
|
|
||||||
|
|
||||||
(ns app.common.svg
|
|
||||||
#?(:cljs
|
|
||||||
(:require
|
|
||||||
["./svg_optimizer.js" :as svgo])))
|
|
||||||
|
|
||||||
#?(:cljs
|
|
||||||
(defn optimize
|
|
||||||
([input] (optimize input nil))
|
|
||||||
([input options]
|
|
||||||
(svgo/optimize input (clj->js options)))))
|
|
File diff suppressed because one or more lines are too long
|
@ -9,15 +9,14 @@
|
||||||
(:require
|
(:require
|
||||||
["process" :as process]
|
["process" :as process]
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.flags :as flags]
|
|
||||||
[app.common.pprint :as pp]
|
|
||||||
[app.common.schema :as sm]
|
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.version :as v]
|
[app.common.version :as v]
|
||||||
[cljs.core :as c]
|
[cljs.core :as c]
|
||||||
|
[cljs.pprint]
|
||||||
|
[cljs.spec.alpha :as s]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
(def ^:private defaults
|
(def defaults
|
||||||
{:public-uri "http://localhost:3449"
|
{:public-uri "http://localhost:3449"
|
||||||
:tenant "default"
|
:tenant "default"
|
||||||
:host "localhost"
|
:host "localhost"
|
||||||
|
@ -25,19 +24,22 @@
|
||||||
:http-server-host "0.0.0.0"
|
:http-server-host "0.0.0.0"
|
||||||
:redis-uri "redis://redis/0"})
|
:redis-uri "redis://redis/0"})
|
||||||
|
|
||||||
(def ^:private schema:config
|
(s/def ::http-server-port ::us/integer)
|
||||||
[:map {:title "config"}
|
(s/def ::http-server-host ::us/string)
|
||||||
[:public-uri {:optional true} ::sm/uri]
|
(s/def ::public-uri ::us/uri)
|
||||||
[:host {:optional true} :string]
|
(s/def ::tenant ::us/string)
|
||||||
[:tenant {:optional true} :string]
|
(s/def ::host ::us/string)
|
||||||
[:flags {:optional true} ::sm/set-of-keywords]
|
(s/def ::browser-pool-max ::us/integer)
|
||||||
[:redis-uri {:optional true} :string]
|
(s/def ::browser-pool-min ::us/integer)
|
||||||
[:browser-pool-max {:optional true} :int]
|
|
||||||
[:browser-pool-min {:optional true} :int]])
|
|
||||||
|
|
||||||
(defn- parse-flags
|
(s/def ::config
|
||||||
[config]
|
(s/keys :opt-un [::public-uri
|
||||||
(flags/parse (:flags config)))
|
::host
|
||||||
|
::tenant
|
||||||
|
::http-server-port
|
||||||
|
::http-server-host
|
||||||
|
::browser-pool-max
|
||||||
|
::browser-pool-min]))
|
||||||
|
|
||||||
(defn- read-env
|
(defn- read-env
|
||||||
[prefix]
|
[prefix]
|
||||||
|
@ -56,30 +58,24 @@
|
||||||
|
|
||||||
(defn- prepare-config
|
(defn- prepare-config
|
||||||
[]
|
[]
|
||||||
(let [env (read-env "penpot")
|
(try
|
||||||
env (d/without-nils env)
|
(let [env (read-env "penpot")
|
||||||
data (merge defaults env)
|
env (d/without-nils env)
|
||||||
data (sm/decode schema:config data sm/default-transformer)]
|
data (merge defaults env)]
|
||||||
|
(us/conform ::config data))
|
||||||
(when-not (sm/validate schema:config data)
|
(catch :default cause
|
||||||
(pp/pprint (-> (sm/explain-data schema:config data)
|
(js/console.log (us/pretty-explain (ex-data cause)))
|
||||||
(sm/humanize)))
|
(throw cause))))
|
||||||
(process/exit -1))
|
|
||||||
|
|
||||||
data))
|
|
||||||
|
|
||||||
(def config
|
(def config
|
||||||
(prepare-config))
|
(atom (prepare-config)))
|
||||||
|
|
||||||
(def version
|
(def version
|
||||||
(v/parse "%version%"))
|
(atom (v/parse "%version%")))
|
||||||
|
|
||||||
(def flags
|
|
||||||
(parse-flags config))
|
|
||||||
|
|
||||||
(defn get
|
(defn get
|
||||||
"A configuration getter."
|
"A configuration getter."
|
||||||
([key]
|
([key]
|
||||||
(c/get config key))
|
(c/get @config key))
|
||||||
([key default]
|
([key default]
|
||||||
(c/get config key default)))
|
(c/get @config key default)))
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
[& _]
|
[& _]
|
||||||
(l/info :msg "initializing"
|
(l/info :msg "initializing"
|
||||||
:public-uri (str (cf/get :public-uri))
|
:public-uri (str (cf/get :public-uri))
|
||||||
:version (:full cf/version))
|
:version (:full @cf/version))
|
||||||
(p/do!
|
(p/do!
|
||||||
(bwr/init)
|
(bwr/init)
|
||||||
(redis/init)
|
(redis/init)
|
||||||
|
|
|
@ -172,8 +172,7 @@
|
||||||
(.listen server port)
|
(.listen server port)
|
||||||
(l/info :hint "welcome to penpot"
|
(l/info :hint "welcome to penpot"
|
||||||
:module "exporter"
|
:module "exporter"
|
||||||
:flags cf/flags
|
:version (:full @cf/version))
|
||||||
:version (:full cf/version))
|
|
||||||
(l/info :hint "starting http server" :port port)
|
(l/info :hint "starting http server" :port port)
|
||||||
(reset! instance server)))
|
(reset! instance server)))
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
[app.browser :as bw]
|
[app.browser :as bw]
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.logging :as l]
|
[app.common.logging :as l]
|
||||||
[app.common.svg :as svg]
|
|
||||||
[app.common.uri :as u]
|
[app.common.uri :as u]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.util.mime :as mime]
|
[app.util.mime :as mime]
|
||||||
|
@ -317,11 +316,7 @@
|
||||||
;; SVG standard don't allow the entity
|
;; SVG standard don't allow the entity
|
||||||
;; nbsp.   is equivalent but compatible
|
;; nbsp.   is equivalent but compatible
|
||||||
;; with SVG.
|
;; with SVG.
|
||||||
result (str/replace result " " " ")
|
result (str/replace result " " " ")]
|
||||||
|
|
||||||
result (if (contains? cf/flags :exporter-svgo)
|
|
||||||
(svg/optimize result)
|
|
||||||
result)]
|
|
||||||
|
|
||||||
;; (println "------- ORIGIN:")
|
;; (println "------- ORIGIN:")
|
||||||
;; (cljs.pprint/pprint (xml->clj xmldata))
|
;; (cljs.pprint/pprint (xml->clj xmldata))
|
||||||
|
|
|
@ -12,12 +12,11 @@
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.pages.changes-builder :as pcb]
|
[app.common.pages.changes-builder :as pcb]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.common.svg :refer [optimize]]
|
|
||||||
[app.common.types.container :as ctn]
|
[app.common.types.container :as ctn]
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
[app.common.types.shape-tree :as ctst]
|
[app.common.types.shape-tree :as ctst]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cf]
|
[app.config :as cfg]
|
||||||
[app.main.data.media :as dmm]
|
[app.main.data.media :as dmm]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.messages :as msg]
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
|
@ -35,34 +34,14 @@
|
||||||
[promesa.core :as p]
|
[promesa.core :as p]
|
||||||
[tubax.core :as tubax]))
|
[tubax.core :as tubax]))
|
||||||
|
|
||||||
(def ^:private svgo-config
|
|
||||||
{:multipass false
|
|
||||||
:plugins
|
|
||||||
[{:name "safePreset"
|
|
||||||
:params {:overrides
|
|
||||||
{:convertColors
|
|
||||||
{:names2hex true
|
|
||||||
:shorthex false
|
|
||||||
:shortname false}
|
|
||||||
:convertTransform
|
|
||||||
{:matrixToTransform false
|
|
||||||
:convertToShorts false
|
|
||||||
:transformPrecision 4
|
|
||||||
:leadingZero false}}}}]})
|
|
||||||
|
|
||||||
(defn svg->clj
|
(defn svg->clj
|
||||||
[[name text]]
|
[[name text]]
|
||||||
(try
|
(try
|
||||||
(let [text (if (contains? cf/flags :frontend-svgo)
|
(->> (rx/of (-> (tubax/xml->clj text)
|
||||||
(optimize text svgo-config)
|
(assoc :name name))))
|
||||||
text)
|
|
||||||
data (-> (tubax/xml->clj text)
|
(catch :default _err
|
||||||
(assoc :name name))]
|
(rx/throw {:type :svg-parser}))))
|
||||||
(rx/of data))
|
|
||||||
(catch :default cause
|
|
||||||
(js/console.error cause)
|
|
||||||
(rx/throw (ex/error :type :svg-parser
|
|
||||||
:hint (ex-message cause))))))
|
|
||||||
|
|
||||||
;; TODO: rename to bitmap-image-uploaded
|
;; TODO: rename to bitmap-image-uploaded
|
||||||
(defn image-uploaded
|
(defn image-uploaded
|
||||||
|
@ -252,7 +231,7 @@
|
||||||
"Load the contents of a media-obj of type svg, and parse it
|
"Load the contents of a media-obj of type svg, and parse it
|
||||||
into a clojure structure."
|
into a clojure structure."
|
||||||
[media-obj]
|
[media-obj]
|
||||||
(let [path (cf/resolve-file-media media-obj)]
|
(let [path (cfg/resolve-file-media media-obj)]
|
||||||
(->> (http/send! {:method :get :uri path :mode :no-cors})
|
(->> (http/send! {:method :get :uri path :mode :no-cors})
|
||||||
(rx/map :body)
|
(rx/map :body)
|
||||||
(rx/map #(vector (:name media-obj) %))
|
(rx/map #(vector (:name media-obj) %))
|
||||||
|
|
Loading…
Add table
Reference in a new issue