From ed7b2d941e479290918993a4a8aea738f4b50178 Mon Sep 17 00:00:00 2001 From: Vidyoot Senthil Date: Tue, 17 Dec 2024 16:31:47 -0600 Subject: [PATCH 1/4] feature: add video link field to public page settings + ts sdk --- clients/ts-sdk/src/types.gen.ts | 1 + .../src/pages/dataset/PublicPageSettings.tsx | 17 +++++++ server/src/data/models.rs | 3 ++ server/src/handlers/page_handler.rs | 2 + server/src/public/page.html | 48 +++++++++++++++++-- server/static/output.css | 19 ++++++++ 6 files changed, 87 insertions(+), 3 deletions(-) diff --git a/clients/ts-sdk/src/types.gen.ts b/clients/ts-sdk/src/types.gen.ts index 2368d87d9..57e0e7dc7 100644 --- a/clients/ts-sdk/src/types.gen.ts +++ b/clients/ts-sdk/src/types.gen.ts @@ -2102,6 +2102,7 @@ export type PublicPageParameters = { useGroupSearch?: (boolean) | null; usePagefind?: (boolean) | null; zIndex?: (number) | null; + videoLink?: (string) | null; }; export type PublicPageSearchOptions = { diff --git a/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx b/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx index 92d4630f4..b1486566e 100644 --- a/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx +++ b/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx @@ -663,6 +663,23 @@ const PublicPageControls = () => { options={Object.keys(HeroPatterns)} /> +
+
+ + } + /> +
+ { + setExtraParams("videoLink", e.currentTarget.value); + }} + class="block w-full rounded border border-neutral-300 px-3 py-1.5 shadow-sm placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6" + /> +
diff --git a/server/src/data/models.rs b/server/src/data/models.rs index df9dfd325..e6818fb19 100644 --- a/server/src/data/models.rs +++ b/server/src/data/models.rs @@ -3257,6 +3257,9 @@ impl DatasetConfigurationDTO { use_pagefind: page_parameters_self .use_pagefind .or(page_parameters_curr.use_pagefind), + video_link: page_parameters_self + .video_link + .or(page_parameters_curr.video_link), }), }, DISABLE_ANALYTICS: self diff --git a/server/src/handlers/page_handler.rs b/server/src/handlers/page_handler.rs index 0f6e7c423..1ca00e6ad 100644 --- a/server/src/handlers/page_handler.rs +++ b/server/src/handlers/page_handler.rs @@ -256,6 +256,8 @@ pub struct PublicPageParameters { pub hide_drawn_text: Option, #[serde(skip_serializing_if = "Option::is_none")] pub use_pagefind: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub video_link: Option, } #[utoipa::path( diff --git a/server/src/public/page.html b/server/src/public/page.html index 2e02c7e86..7f9653fa7 100644 --- a/server/src/public/page.html +++ b/server/src/public/page.html @@ -372,6 +372,48 @@ brackets: ["left"], }); } + const openTrieveRect = openTrieveModalElement.getBoundingClientRect(); + let endOpenX = openTrieveRect.right + 138; + let endOpenY = openTrieveRect.bottom + 45; + if (endOpenX > window.innerWidth) { + endOpenX = window.innerWidth - 125; + endOpenY += 15; + } + const startOpenX = openTrieveRect.right + 60; + const startOpenY = openTrieveRect.bottom - 15; + + rc.path( + `M ${startOpenX} ${startOpenY} + Q ${startOpenX + 85} ${endOpenY - 85} ${endOpenX} ${endOpenY}`, + { + stroke: window.paramsData.brandColor || "black", + strokeWidth: 2, + roughness: 3, + bowing: 3, + }, + ); + + const arrowSize = 10; + rc.line( + startOpenX - 5, + startOpenY, + startOpenX + arrowSize, + startOpenY + arrowSize, + { + stroke: window.paramsData.brandColor || "black", + strokeWidth: 2, + }, + ); + rc.line( + startOpenX - 5, + startOpenY, + startOpenX + arrowSize, + startOpenY - arrowSize, + { + stroke: window.paramsData.brandColor || "black", + strokeWidth: 2, + }, + ); const circleSearchAnimation = annotate(openTrieveModalElement, { type: "circle", @@ -414,7 +456,7 @@ strokeWidth: 2, roughness: 3, bowing: 3, - } + }, ); const arrowSize = 10; @@ -426,7 +468,7 @@ { stroke: window.paramsData.brandColor || "black", strokeWidth: 2, - } + }, ); rc.line( startOpenX - 5, @@ -436,7 +478,7 @@ { stroke: window.paramsData.brandColor || "black", strokeWidth: 2, - } + }, ); let endRecX = 0; diff --git a/server/static/output.css b/server/static/output.css index f2b52896a..a2e625659 100644 --- a/server/static/output.css +++ b/server/static/output.css @@ -612,6 +612,10 @@ video { margin-top: 2rem; } +.mt-0\.5 { + margin-top: 0.125rem; +} + .line-clamp-1 { overflow: hidden; display: -webkit-box; @@ -796,6 +800,11 @@ video { background-color: rgb(249 250 251 / var(--tw-bg-opacity)); } +.bg-white { + --tw-bg-opacity: 1; + background-color: rgb(255 255 255 / var(--tw-bg-opacity)); +} + .object-cover { -o-object-fit: cover; object-fit: cover; @@ -904,6 +913,16 @@ video { color: rgb(255 255 255 / var(--tw-text-opacity)); } +.text-black { + --tw-text-opacity: 1; + color: rgb(0 0 0 / var(--tw-text-opacity)); +} + +.text-gray-900 { + --tw-text-opacity: 1; + color: rgb(17 24 39 / var(--tw-text-opacity)); +} + .underline { text-decoration-line: underline; } From 77b0dffc03feef921799b2e6ff7d431860d3b7ff Mon Sep 17 00:00:00 2001 From: Vidyoot Senthil Date: Wed, 18 Dec 2024 14:44:28 -0600 Subject: [PATCH 2/4] feature: add video embed to public page template --- server/src/public/page.html | 54 ++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/server/src/public/page.html b/server/src/public/page.html index 7f9653fa7..f695b95f6 100644 --- a/server/src/public/page.html +++ b/server/src/public/page.html @@ -200,9 +200,6 @@ color: black; padding: 0.3rem; font-size: 0.8rem; - position: fixed; - bottom: 0.5rem; - left: 0.5rem; text-decoration: none; z-index: 20; } @@ -306,6 +303,41 @@ background-color: color-mix(in srgb, var(--brand-color), black 20%); } } + + .video-wrapper { + position: fixed; + bottom: 20px; + left: 20px; + width: 100%; + max-width: 18.5rem; + height: 14.5rem; + margin: 0; + padding: 0; + + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + gap: 0.5rem; + } + + .video-wrapper iframe { + width: 100%; + height: 100%; + border: none; + object-fit: cover; + } + + @media (max-width: 640px) { + .video-wrapper { + position: relative; + bottom: 0; + left: 0; + margin: 0 auto; + max-width: calc(100vw - 4rem); + height: 20rem; + } + }