Compare commits

..

1 Commits

Author SHA1 Message Date
Andrey Antukh
6192569df6 Add several adjustments for make penpot run on subpath 2026-01-08 18:54:52 +01:00
8 changed files with 47 additions and 65 deletions

View File

@@ -19,7 +19,7 @@
inner join team_profile_rel as tpr on (tpr.team_id = p.team_id)
where tpr.profile_id = ?
and p.team_id = ?
and (p.deleted_at is null)
and (p.deleted_at is null or p.deleted_at > now())
and (tpr.is_admin = true or
tpr.is_owner = true or
tpr.can_edit = true)
@@ -29,7 +29,7 @@
inner join project_profile_rel as ppr on (ppr.project_id = p.id)
where ppr.profile_id = ?
and p.team_id = ?
and (p.deleted_at is null)
and (p.deleted_at is null or p.deleted_at > now())
and (ppr.is_admin = true or
ppr.is_owner = true or
ppr.can_edit = true)
@@ -47,7 +47,7 @@
left join file_thumbnail as ft on (ft.file_id = f.id and ft.revn = f.revn)
inner join projects as pr on (f.project_id = pr.id)
where f.name ilike ('%' || ? || '%')
and (f.deleted_at is null)
and (f.deleted_at is null or f.deleted_at > now())
order by f.created_at asc")
(defn search-files

View File

@@ -13,7 +13,7 @@
$weight: unquote("normal"),
$style: string.unquote("normal")
) {
$filepath: "/fonts/" + $file;
$filepath: "../fonts/" + $file;
@font-face {
font-family: "#{$style-name}";
@@ -29,7 +29,7 @@
}
@mixin font-face-variable($style-name, $file, $unicode-range) {
$filepath: "/fonts/" + $file;
$filepath: "../fonts/" + $file;
@font-face {
font-family: "#{$style-name}";

View File

@@ -110,12 +110,9 @@
(defn- normalize-uri
[uri-str]
(let [uri (u/uri uri-str)]
;; Ensure that the path always ends with "/"; this ensures that
;; all path join operations works as expected.
(cond-> uri
(not (str/ends-with? (:path uri) "/"))
(update :path #(str % "/")))))
;; Ensure that the path always ends with "/"; this ensures that
;; all path join operations works as expected.
(u/ensure-path-slash uri-str))
(def public-uri
(normalize-uri (or (obj/get global "penpotPublicURI")

View File

@@ -12,6 +12,7 @@
[app.common.data.macros :as dm]
[app.common.logging :as log]
[app.common.types.text :as txt]
[app.common.uri :as u]
[app.config :as cf]
[app.util.dom :as dom]
[app.util.globals :as globals]
@@ -19,7 +20,6 @@
[app.util.object :as obj]
[beicon.v2.core :as rx]
[cuerdas.core :as str]
[lambdaisland.uri :as u]
[okulary.core :as l]
[promesa.core :as p]))
@@ -138,13 +138,13 @@
"&display=block")]
(dm/str
(-> cf/public-uri
(assoc :path "/internal/gfonts/css")
(u/join "internal/gfonts/css")
(assoc :query query)))))
(defn- process-gfont-css
[css]
(let [base (dm/str (assoc cf/public-uri :path "/internal/gfonts/font"))]
(str/replace css "https://fonts.gstatic.com/s" base)))
(let [base (u/join cf/public-uri "internal/gfonts/font")]
(str/replace css "https://fonts.gstatic.com/s" (dm/str base))))
(defn- fetch-gfont-css
[url]
@@ -178,7 +178,9 @@
(defn- asset-id->uri
[asset-id]
(str (u/join cf/public-uri "assets/by-id/" asset-id)))
(-> cf/public-uri
(u/join "assets/by-id/" asset-id)
(str)))
(defn generate-custom-font-variant-css
[family variant]
@@ -370,7 +372,7 @@
:else
(let [{:keys [weight style suffix]} (get-variant font font-variant-id)
suffix (or suffix font-variant-id)
params {:uri (dm/str cf/public-uri "fonts/" family "-" suffix ".woff")
params {:uri (str (u/join cf/public-uri (str "fonts/" family "-" suffix ".woff")))
:family family
:style style
:weight weight}]

View File

@@ -14,6 +14,7 @@
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.logging :as log]
[app.common.uri :as u]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.util.dom :as dom]
@@ -26,7 +27,9 @@
(defonce instance nil)
(defonce msgbus (rx/subject))
(defonce origin
(dm/str (assoc cf/rasterizer-uri :path "/rasterizer.html")))
(-> cf/rasterizer-uri
(u/join "rasterizer.html")
(dm/str)))
(declare send-message!)
@@ -129,7 +132,9 @@
(dom/append-child! js/document.body iframe)
(set! instance iframe))
(let [new-origin (dm/str (assoc cf/public-uri :path "/rasterizer.html"))]
(let [new-origin (-> cf/public-uri
(u/join "rasterizer.html")
(dm/str))]
(log/warn :hint "fallback to main domain" :origin new-origin)
(dom/set-attribute! iframe "src" new-origin)

View File

@@ -32,27 +32,6 @@
(def ^:private menu-icon
(deprecated-icon/icon-xref :menu (stl/css :menu-icon)))
(defn- on-restore-project
[project]
(let [on-accept #(st/emit! (dd/restore-project-immediately project))]
(st/emit! (modal/show
{:type :confirm
:title (tr "dashboard.restore-project-confirmation.title")
:message (tr "dashboard.restore-project-confirmation.description" (:name project))
:accept-style :primary
:accept-label (tr "labels.continue")
:on-accept on-accept}))))
(defn- on-delete-project
[project]
(let [accept-fn #(st/emit! (dd/delete-project-immediately project))]
(st/emit! (modal/show
{:type :confirm
:title (tr "dashboard.delete-forever-confirmation.title")
:message (tr "dashboard.delete-project-forever-confirmation.description" (:name project))
:accept-label (tr "dashboard.delete-forever-confirmation.title")
:on-accept accept-fn}))))
(mf/defc header*
{::mf/props :obj
::mf/private true}
@@ -62,7 +41,6 @@
[:h1 (tr "dashboard.projects-title")]]])
(mf/defc deleted-project-menu*
{::mf/private true}
[{:keys [project show on-close top left]}]
(let [top (d/nilv top 0)
left (d/nilv left 0)
@@ -70,13 +48,25 @@
on-restore-project
(mf/use-fn
(mf/deps project)
(partial on-restore-project project))
(fn []
(let [on-accept #(st/emit! (dd/restore-project-immediately project))]
(st/emit! (modal/show {:type :confirm
:title (tr "dashboard.restore-project-confirmation.title")
:message (tr "dashboard.restore-project-confirmation.description" (:name project))
:accept-style :primary
:accept-label (tr "labels.continue")
:on-accept on-accept})))))
on-delete-project
(mf/use-fn
(mf/deps project)
(partial on-delete-project project))
(fn []
(let [accept-fn #(st/emit! (dd/delete-project-immediately project))]
(st/emit! (modal/show {:type :confirm
:title (tr "dashboard.delete-forever-confirmation.title")
:message (tr "dashboard.delete-project-forever-confirmation.description" (:name project))
:accept-label (tr "dashboard.delete-forever-confirmation.title")
:on-accept accept-fn})))))
options
(mf/with-memo [on-restore-project on-delete-project]
[{:name (tr "dashboard.restore-project-button")
@@ -184,8 +174,8 @@
:limit limit
:selected-files selected-files}])]]))
(mf/defc menu*
{::mf/private true}
[{:keys [team-id section]}]
(let [on-recent-click
(mf/use-fn
@@ -232,8 +222,7 @@
(some #(= (:id project) (:project-id %))
(vals deleted-map)))))
(sort-by :modified-at)
(reverse)
(not-empty)))
(reverse)))
team-id
(get team :id)
@@ -309,7 +298,7 @@
:on-click on-delete-all}
(tr "dashboard.clear-trash-button")]]]
(when projects
(when (seq projects)
(for [{:keys [id] :as project} projects]
(let [files (when deleted-map
(->> (vals deleted-map)

View File

@@ -7,7 +7,6 @@
(ns app.main.ui.workspace.tokens.management.forms.controls.input
(:require
[app.common.data :as d]
[app.common.files.tokens :as cft]
[app.common.types.tokens-lib :as ctob]
[app.main.data.style-dictionary :as sd]
[app.main.data.workspace.tokens.format :as dwtf]
@@ -293,7 +292,7 @@
(mf/spread-props props {:hint-formated true})
props)]
(mf/with-effect [resolve-stream tokens token input-name name]
(mf/with-effect [resolve-stream tokens token input-name]
(let [subs (->> resolve-stream
(rx/debounce 300)
(rx/mapcat (partial resolve-value tokens token))
@@ -318,21 +317,11 @@
(reset! hint* {:message error' :type "error"}))
:else
(let [input-value (get-in @form [:data :value input-name] "")
resolved-value (if (= name :line-height)
(when-let [{:keys [unit value]} (cft/parse-token-value input-value)]
(let [font-size (get-in @form [:data :value :font-size] "")
calculated (case unit
"%" (/ (d/parse-double value) 100)
"px" (/ (d/parse-double value) (d/parse-double font-size))
nil value
nil)]
(dwtf/format-token-value calculated)))
(dwtf/format-token-value value))
message (tr "workspace.tokens.resolved-value" (or resolved-value value))]
(let [message (tr "workspace.tokens.resolved-value" (dwtf/format-token-value value))
input-value (get-in @form [:data :value input-name] "")]
(swap! form update :errors dissoc :value)
(swap! form update :extra-errors dissoc :value)
(if (= input-value (str resolved-value))
(if (= input-value (str value))
(reset! hint* {})
(reset! hint* {:message message :type "hint"})))))))]
(fn []

View File

@@ -93,9 +93,9 @@
line-height-sub-token
(mf/with-memo [token]
(if-let [value (get token :value)]
{:type :dimensions
{:type :number
:value (get value :line-height)}
{:type :dimensions}))
{:type :number}))
text-case-sub-token
(mf/with-memo [token]