From 9d090ad3d96556723d115e4ab8dc5136ea8932e8 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 15 Sep 2023 12:19:17 +0200 Subject: [PATCH] Revert ":sparkles: Add support for svg optimizations on exporter output" This reverts commit 9fc771292ae5420547535055ab0390e5c0806bc2. --- common/src/app/common/schema.cljc | 16 -------- exporter/src/app/config.cljs | 64 ++++++++++++++---------------- exporter/src/app/core.cljs | 2 +- exporter/src/app/http.cljs | 3 +- exporter/src/app/renderer/svg.cljs | 7 +--- 5 files changed, 33 insertions(+), 59 deletions(-) diff --git a/common/src/app/common/schema.cljc b/common/src/app/common/schema.cljc index 641837f53..494b1df2a 100644 --- a/common/src/app/common/schema.cljc +++ b/common/src/app/common/schema.cljc @@ -316,22 +316,6 @@ (let [v (if (string? v) (str/split v #"[\s,]+") 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 {:type ::set-of-emails :pred #(and (set? %) (every? string? %)) diff --git a/exporter/src/app/config.cljs b/exporter/src/app/config.cljs index c219857d0..6b9b46925 100644 --- a/exporter/src/app/config.cljs +++ b/exporter/src/app/config.cljs @@ -9,15 +9,14 @@ (:require ["process" :as process] [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.version :as v] [cljs.core :as c] + [cljs.pprint] + [cljs.spec.alpha :as s] [cuerdas.core :as str])) -(def ^:private defaults +(def defaults {:public-uri "http://localhost:3449" :tenant "default" :host "localhost" @@ -25,19 +24,22 @@ :http-server-host "0.0.0.0" :redis-uri "redis://redis/0"}) -(def ^:private schema:config - [:map {:title "config"} - [:public-uri {:optional true} ::sm/uri] - [:host {:optional true} :string] - [:tenant {:optional true} :string] - [:flags {:optional true} ::sm/set-of-keywords] - [:redis-uri {:optional true} :string] - [:browser-pool-max {:optional true} :int] - [:browser-pool-min {:optional true} :int]]) +(s/def ::http-server-port ::us/integer) +(s/def ::http-server-host ::us/string) +(s/def ::public-uri ::us/uri) +(s/def ::tenant ::us/string) +(s/def ::host ::us/string) +(s/def ::browser-pool-max ::us/integer) +(s/def ::browser-pool-min ::us/integer) -(defn- parse-flags - [config] - (flags/parse (:flags config))) +(s/def ::config + (s/keys :opt-un [::public-uri + ::host + ::tenant + ::http-server-port + ::http-server-host + ::browser-pool-max + ::browser-pool-min])) (defn- read-env [prefix] @@ -56,30 +58,24 @@ (defn- prepare-config [] - (let [env (read-env "penpot") - env (d/without-nils env) - data (merge defaults env) - data (sm/decode schema:config data sm/default-transformer)] - - (when-not (sm/validate schema:config data) - (pp/pprint (-> (sm/explain-data schema:config data) - (sm/humanize))) - (process/exit -1)) - - data)) + (try + (let [env (read-env "penpot") + env (d/without-nils env) + data (merge defaults env)] + (us/conform ::config data)) + (catch :default cause + (js/console.log (us/pretty-explain (ex-data cause))) + (throw cause)))) (def config - (prepare-config)) + (atom (prepare-config))) (def version - (v/parse "%version%")) - -(def flags - (parse-flags config)) + (atom (v/parse "%version%"))) (defn get "A configuration getter." ([key] - (c/get config key)) + (c/get @config key)) ([key default] - (c/get config key default))) + (c/get @config key default))) diff --git a/exporter/src/app/core.cljs b/exporter/src/app/core.cljs index 6d30b9220..29455bec2 100644 --- a/exporter/src/app/core.cljs +++ b/exporter/src/app/core.cljs @@ -21,7 +21,7 @@ [& _] (l/info :msg "initializing" :public-uri (str (cf/get :public-uri)) - :version (:full cf/version)) + :version (:full @cf/version)) (p/do! (bwr/init) (redis/init) diff --git a/exporter/src/app/http.cljs b/exporter/src/app/http.cljs index acfb6e909..e0d492129 100644 --- a/exporter/src/app/http.cljs +++ b/exporter/src/app/http.cljs @@ -172,8 +172,7 @@ (.listen server port) (l/info :hint "welcome to penpot" :module "exporter" - :flags cf/flags - :version (:full cf/version)) + :version (:full @cf/version)) (l/info :hint "starting http server" :port port) (reset! instance server))) diff --git a/exporter/src/app/renderer/svg.cljs b/exporter/src/app/renderer/svg.cljs index 729b57fb4..ba3287a64 100644 --- a/exporter/src/app/renderer/svg.cljs +++ b/exporter/src/app/renderer/svg.cljs @@ -10,7 +10,6 @@ [app.browser :as bw] [app.common.data :as d] [app.common.logging :as l] - [app.common.svg :as svg] [app.common.uri :as u] [app.config :as cf] [app.util.mime :as mime] @@ -317,11 +316,7 @@ ;; SVG standard don't allow the entity ;; nbsp.   is equivalent but compatible ;; with SVG. - result (str/replace result " " " ") - - result (if (contains? cf/flags :exporter-svgo) - (svg/optimize result) - result)] + result (str/replace result " " " ")] ;; (println "------- ORIGIN:") ;; (cljs.pprint/pprint (xml->clj xmldata))