Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
fix(site): attribute embedded footer links to Cloud website
HoshinoSuzumibcab9fdc286b
diff --git a/packages/gallery/app/components/masonry/item/HeaderFooter.vue b/packages/gallery/app/components/masonry/item/HeaderFooter.vueindex 983f91af..2fc9c464 100644--- a/packages/gallery/app/components/masonry/item/HeaderFooter.vue+++ b/packages/gallery/app/components/masonry/item/HeaderFooter.vue@@ -1,5 +1,6 @@<script lang="ts" setup>import { motion, AnimatePresence } from 'motion-v'+import { siteFooterLink } from '../../../utils/site-footer-link'const props = withDefaults(defineProps<{@@ -10,6 +11,15 @@ const props = withDefaults()const isFixed = computed(() => props.variant === 'fixed')+const entry = useEntryContext()+const capabilities = useEntryCapabilities()+const websiteHref = computed(() =>+ siteFooterLink(+ entry.value?.capabilities.edition ?? capabilities.edition,+ props.variant,+ entry.value?.siteId,+ ),+)const isRepoLinkHovering = ref(false)const copyrightName = computed(() => getSetting('app:author') || getSetting('app:title'),@@ -39,7 +49,7 @@ const copyrightName = computed(© {{ $dayjs().format('YYYY') }} {{ copyrightName }}</p><a- href="https://github.com/HoshinoSuzumi/chronoframe"+ :href="websiteHref || 'https://github.com/HoshinoSuzumi/chronoframe'"target="_blank"rel="noopener noreferrer":class="@@ -49,17 +59,17 @@ const copyrightName = computed(: 'inline-flex items-center gap-1 whitespace-nowrap hover:underline': 'group inline-flex items-center gap-0.5 text-xs font-medium text-neutral-500/60 hover:underline dark:text-neutral-500/80'"- @mouseenter="isRepoLinkHovering = true"+ @mouseenter="isRepoLinkHovering = !websiteHref"@mouseleave="isRepoLinkHovering = false"><Icon- name="mdi:github"+ :name="websiteHref ? 'tabler:external-link' : 'mdi:github'"mode="svg":class="isFixed ? '' : '-mt-px inline-block text-sm'"/>ChronoFrame<template v-if="isFixed">{{ ' ' }}{{ $config.public.VERSION }}</template>- <AnimatePresence v-else>+ <AnimatePresence v-else-if="!websiteHref"><motion.spanv-if="isRepoLinkHovering":initial="{ width: 0, opacity: 0 }"diff --git a/packages/gallery/app/utils/site-footer-link.ts b/packages/gallery/app/utils/site-footer-link.tsnew file mode 100644index 00000000..02a3e5ad--- /dev/null+++ b/packages/gallery/app/utils/site-footer-link.ts@@ -0,0 +1,20 @@+import type { EntryCapabilities } from '@chronoframe/contracts/entry'++export function siteFooterLink(+ edition: EntryCapabilities['edition'],+ variant: 'embedded' | 'fixed',+ siteId?: number,+) {+ if (edition !== 'site' || variant !== 'embedded') return null+ const url = new URL('https://chronoframe.art/')+ url.searchParams.set(+ 'utm_source',+ Number.isSafeInteger(siteId) && Number(siteId) > 0+ ? `site_${siteId}`+ : 'site',+ )+ url.searchParams.set('utm_medium', 'referral')+ url.searchParams.set('utm_campaign', 'site_to_website')+ url.searchParams.set('utm_content', 'embedded_footer')+ return url.href+}diff --git a/tests/site-footer-link.test.ts b/tests/site-footer-link.test.tsnew file mode 100644index 00000000..02f485f8--- /dev/null+++ b/tests/site-footer-link.test.ts@@ -0,0 +1,31 @@+import assert from 'node:assert/strict'+import test from 'node:test'+import { siteFooterLink } from '../packages/gallery/app/utils/site-footer-link.ts'++test('embedded SaaS attribution lands on the website and distinguishes source sites', () => {+ const a = new URL(siteFooterLink('site', 'embedded', 12)!)+ const b = new URL(siteFooterLink('site', 'embedded', 34)!)+ assert.equal(a.origin, 'https://chronoframe.art')+ assert.equal(a.pathname, '/')+ assert.equal(a.searchParams.get('utm_source'), 'site_12')+ assert.equal(b.searchParams.get('utm_source'), 'site_34')+ assert.equal(a.searchParams.get('utm_medium'), 'referral')+ assert.equal(a.searchParams.get('utm_campaign'), 'site_to_website')+ assert.equal(a.searchParams.get('utm_content'), 'embedded_footer')+})+test('Self-hosted, Cloud portal, and fixed headers retain their existing footer', () => {+ for (const variant of ['embedded', 'fixed'] as const) {+ assert.equal(siteFooterLink('self-hosted', variant, 12), null)+ assert.equal(siteFooterLink('cloud', variant, 12), null)+ }+ assert.equal(siteFooterLink('site', 'fixed', 12), null)+})+test('unresolved site IDs never produce undefined or invalid attribution identifiers', () => {+ for (const id of [undefined, 0, -1, NaN])+ assert.equal(+ new URL(siteFooterLink('site', 'embedded', id)!).searchParams.get(+ 'utm_source',+ ),+ 'site',+ )+})