0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-16 17:01:33 -05:00

Merge remote-tracking branch 'origin/main' into develop

This commit is contained in:
Andrey Antukh 2021-05-27 14:13:45 +02:00
commit a80120278e
15 changed files with 91 additions and 60 deletions

View file

@ -109,6 +109,17 @@
:cause e)
nil)))
(s/def ::backend ::us/not-empty-string)
(s/def ::email ::us/not-empty-string)
(s/def ::fullname ::us/not-empty-string)
(s/def ::props (s/map-of ::us/keyword any?))
(s/def ::info
(s/keys :req-un [::backend
::email
::fullname
::props]))
(defn retrieve-info
[{:keys [tokens provider] :as cfg} request]
(let [state (get-in request [:params :state])
@ -116,7 +127,10 @@
info (some->> (get-in request [:params :code])
(retrieve-access-token cfg)
(retrieve-user-info cfg))]
(when-not info
(when-not (s/valid? ::info info)
(l/warn :hint "received incomplete profile info object (please set correct scopes)"
:info (pr-str info))
(ex/raise :type :internal
:code :unable-to-auth
:hint "no user info"))
@ -228,6 +242,13 @@
:auth-uri (get data "authorization_endpoint")
:user-uri (get data "userinfo_endpoint"))))))
(defn- obfuscate-string
[s]
(if (< (count s) 10)
(apply str (take (count s) (repeat "*")))
(str (subs s 0 5)
(apply str (take (- (count s) 5) (repeat "*"))))))
(defn- initialize-oidc-provider
[cfg]
(let [opts {:base-uri (cf/get :oidc-base-uri)
@ -236,7 +257,7 @@
:token-uri (cf/get :oidc-token-uri)
:auth-uri (cf/get :oidc-auth-uri)
:user-uri (cf/get :oidc-user-uri)
:scopes (cf/get :oidc-scopes #{"openid" "profile"})
:scopes (cf/get :oidc-scopes #{"openid" "profile" "email"})
:roles-attr (cf/get :oidc-roles-attr)
:roles (cf/get :oidc-roles)
:name "oidc"}]
@ -247,10 +268,12 @@
(string? (:user-uri opts))
(string? (:auth-uri opts)))
(do
(l/info :action "initialize" :provider "oid" :method "static")
(l/info :action "initialize" :provider "oidc" :method "static"
:opts (pr-str (update opts :client-secret obfuscate-string)))
(assoc-in cfg [:providers "oidc"] opts))
(let [opts (discover-oidc-config opts)]
(l/info :action "initialize" :provider "oid" :method "discover")
(l/info :action "initialize" :provider "oidc" :method "discover"
:opts (pr-str (update opts :client-secret obfuscate-string)))
(assoc-in cfg [:providers "oidc"] opts)))
cfg)))
@ -266,7 +289,8 @@
(if (and (string? (:client-id opts))
(string? (:client-secret opts)))
(do
(l/info :action "initialize" :provider "google")
(l/info :action "initialize" :provider "google"
:opts (pr-str (update opts :client-secret obfuscate-string)))
(assoc-in cfg [:providers "google"] opts))
cfg)))
@ -282,7 +306,8 @@
(if (and (string? (:client-id opts))
(string? (:client-secret opts)))
(do
(l/info :action "initialize" :provider "github")
(l/info :action "initialize" :provider "github"
:opts (pr-str (update opts :client-secret obfuscate-string)))
(assoc-in cfg [:providers "github"] opts))
cfg)))
@ -301,7 +326,8 @@
(if (and (string? (:client-id opts))
(string? (:client-secret opts)))
(do
(l/info :action "initialize" :provider "gitlab")
(l/info :action "initialize" :provider "gitlab"
:opts (pr-str (update opts :client-secret obfuscate-string)))
(assoc-in cfg [:providers "gitlab"] opts))
cfg)))

View file

@ -61,7 +61,7 @@
[cfg {:keys [host version id] :as cdata}]
(try
(let [uri (:uri cfg)
text (str "Unhandled exception (@channel):\n"
text (str "Unhandled exception:\n"
"- detail: " (cfg/get :public-uri) "/dbg/error-by-id/" id "\n"
"- profile-id: `" (:profile-id cdata) "`\n"
"- host: `" host "`\n"

View file

@ -66,8 +66,7 @@
(defmethod process-error :default
[error]
(ex/raise :type :internal
:cause error))
(throw error))
(defn run
[{:keys [rlimits] :as cfg} {:keys [rlimit] :or {rlimit :image} :as params}]
@ -184,11 +183,10 @@
(us/assert ::input input)
(let [{:keys [path mtype]} input]
(if (= mtype "image/svg+xml")
(let [data (svg/parse (slurp path))
info (get-basic-info-from-svg data)]
(let [info (some-> path slurp svg/parse get-basic-info-from-svg)]
(when-not info
(ex/raise :type :validation
:code :unable-to-retrieve-dimensions
:code :invalid-svg-file
:hint "uploaded svg does not provides dimensions"))
(assoc info :mtype mtype))
@ -211,6 +209,7 @@
[error]
(ex/raise :type :validation
:code :invalid-image
:hint "invalid image"
:cause error))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -36,6 +36,7 @@
:message (ex-message e))
(ex/raise :type :validation
:code :invalid-svg-file
:hint "invalid svg file"
:cause e))))
(declare pre-process)
@ -53,6 +54,6 @@
[data]
(cond-> data
(str/includes? data "<!DOCTYPE")
(str/replace #"<\!DOCTYPE[^>]+>" "")))
(str/replace #"<\!DOCTYPE[^>]*>" "")))
(def pre-process strip-doctype)

View file

@ -42,7 +42,7 @@ PENPOT_REGISTRATION_ENABLED=true
# Comma separated list of allowed domains to register. Empty for allow
# all.
PENPOT_REGISTRATION_DOMAIN_WHITELIST=""
# PENPOT_REGISTRATION_DOMAIN_WHITELIST=""
# Penpot comes with the facility to create quick demo users that are
# automatically deleted after some time. This settings enables or

View file

@ -97,7 +97,7 @@ update_registration_enabled() {
fi
}
update_registration_enabled() {
update_analytics_enabled() {
if [ -n "$PENPOT_ANALYTICS_ENABLED" ]; then
sed -i \
-e "s|^//var penpotAnalyticsEnabled = .*;|var penpotAnalyticsEnabled = $PENPOT_ANALYTICS_ENABLED;|g" \

View file

@ -89,7 +89,7 @@
{:content {:data (js/Uint8Array. data)
:name name
:type type}
:font-family family
:font-family (or family "")
:font-weight (cm/parse-font-weight variant)
:font-style (cm/parse-font-style variant)}))

View file

@ -1238,7 +1238,6 @@
qparams {:page-id page-id}]
(rx/of (rt/nav :workspace pparams qparams))))))
(defn go-to-viewer
([] (go-to-viewer {}))
([{:keys [file-id page-id]}]

View file

@ -228,7 +228,7 @@
ptk/WatchEvent
(watch [it state stream]
(let [[path name] (cp/parse-path-name (:name typography))
typography (assoc typography :path path :name name)
typography (assoc typography :path path :name name)
prev (get-in state [:workspace-data :typographies (:id typography)])
rchg {:type :mod-typography
:typography typography}

View file

@ -88,10 +88,10 @@
(let [objects (wsh/lookup-page-objects state)
page-id (:current-page-id state)
id (get-in state [:workspace-local :edition])
old-content (get-in state [:workspace-local :edit-path id :old-content])]
(if (some? old-content)
(let [shape (get-in state (st/get-path state))
[rch uch] (generate-path-changes objects page-id shape old-content (:content shape))]
old-content (get-in state [:workspace-local :edit-path id :old-content])
shape (get-in state (st/get-path state))]
(if (and (some? old-content) (some? shape))
(let [[rch uch] (generate-path-changes objects page-id shape old-content (:content shape))]
(rx/of (dch/commit-changes {:redo-changes rch
:undo-changes uch
:origin it})))

View file

@ -60,20 +60,20 @@
old-points (->> content upg/content->points)
new-points (->> new-content upg/content->points)
point-change (->> (map hash-map old-points new-points) (reduce merge))
point-change (->> (map hash-map old-points new-points) (reduce merge))]
[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]
(if (empty? new-content)
(rx/of (dch/commit-changes {:redo-changes rch
:undo-changes uch
:origin it})
dwc/clear-edition-mode)
(rx/of (dch/commit-changes {:redo-changes rch
:undo-changes uch
:origin it})
(selection/update-selection point-change)
(fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler))))))))
(when (and (some? new-content) (some? shape))
(let [[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]
(if (empty? new-content)
(rx/of (dch/commit-changes {:redo-changes rch
:undo-changes uch
:origin it})
dwc/clear-edition-mode)
(rx/of (dch/commit-changes {:redo-changes rch
:undo-changes uch
:origin it})
(selection/update-selection point-change)
(fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler))))))))))
(defn modify-content-point
[content {dx :x dy :y} modifiers point]
@ -263,7 +263,8 @@
(streams/drag-stream
(rx/concat
(->> (streams/move-handler-stream snap-toggled start-point point handler opposite points)
(rx/take-until (->> stream (rx/filter ms/mouse-up?)))
(rx/take-until (->> stream (rx/filter #(or (ms/mouse-up? %)
(streams/finish-edition? %)))))
(rx/map
(fn [{:keys [x y alt? shift?]}]
(let [pos (cond-> (gpt/point x y)

View file

@ -24,6 +24,9 @@
(fn [current]
(>= (gpt/distance start current) (/ drag-threshold zoom))))
(defn finish-edition? [event]
(= (ptk/type event) :app.main.data.workspace.common/clear-edition-mode))
(defn drag-stream
([to-stream]
(drag-stream to-stream (rx/empty)))
@ -31,7 +34,8 @@
([to-stream not-drag-stream]
(let [start @ms/mouse-position
zoom (get-in @st/state [:workspace-local :zoom] 1)
mouse-up (->> st/stream (rx/filter #(ms/mouse-up? %)))
mouse-up (->> st/stream (rx/filter #(or (finish-edition? %)
(ms/mouse-up? %))))
position-stream
(->> ms/mouse-position

View file

@ -33,7 +33,7 @@
selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{})
points (or points selected-points)]
(when-not (empty? points)
(when (and (not (empty? points)) (some? shape))
(let [new-content (-> (tool-fn (:content shape) points)
(ups/close-subpaths))
[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]

View file

@ -192,9 +192,10 @@
on-save
(fn [event]
(let [font-family @state]
(st/emit! (df/update-font
{:id font-id
:name font-family}))
(when-not (str/blank? font-family)
(st/emit! (df/update-font
{:id font-id
:name font-family})))
(reset! edit? false)))
on-key-down

View file

@ -428,26 +428,27 @@
[:> text-transform-options opts]]]))
;; TODO: this need to be refactored, right now combines too much logic
;; and has a dropdown that behaves like a modal but is not a modal.
;; In summary, this need to a good UX/UI/IMPL rework.
(mf/defc typography-entry
[{:keys [typography read-only? selected? on-click on-change on-detach on-context-menu editting? focus-name? file]}]
(let [open? (mf/use-state editting?)
hover-detach (mf/use-state false)
name-input-ref (mf/use-ref nil)
value (mf/use-state (cp/merge-path-item (:path typography) (:name typography)))
(let [open? (mf/use-state editting?)
hover-detach (mf/use-state false)
name-input-ref (mf/use-ref)
#_(rt/resolve router :workspace
{:project-id (:project-id file)
:file-id (:id file)}
{:page-id (get-in file [:data :pages 0])})
handle-change
on-name-blur
(fn [event]
(reset! value (dom/get-target-val event)))
(let [content (dom/get-target-val event)]
(when-not (str/blank? content)
(on-change {:name content}))))
handle-go-to-edit
(fn [] (st/emit! (rt/nav :workspace {:project-id (:project-id file)
:file-id (:id file)}
{:page-id (get-in file [:data :pages 0])})))]
(fn []
(let [pparams {:project-id (:project-id file)
:file-id (:id file)}]
(st/emit! (rt/nav :workspace pparams))))]
(mf/use-effect
(mf/deps editting?)
@ -459,7 +460,7 @@
(mf/deps focus-name?)
(fn []
(when focus-name?
(ts/schedule 100
(ts/schedule
#(when-let [node (mf/ref-val name-input-ref)]
(dom/focus! node)
(dom/select-text! node))))))
@ -530,8 +531,7 @@
[:input.element-name.adv-typography-name
{:type "text"
:ref name-input-ref
:value @value
:on-change handle-change
:on-blur #(on-change {:name @value})}]]]
:default-value (cp/merge-path-item (:path typography) (:name typography))
:on-blur on-name-blur}]]]
[:& typography-options {:values typography
:on-change on-change}]])]]))