Skip to content

Commit 4cdd741

Browse files
committed
Rethink share URLs to include location ID
This makes the URLs more resilient to changes and is as close to a permalink as it gets.
1 parent 3f72f79 commit 4cdd741

File tree

6 files changed

+29
-42
lines changed

6 files changed

+29
-42
lines changed

Tekst-Web/i18n/ui/deDE.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ browse:
204204
Klicken Sie hier, um eine URL zur aktuellen Belegstelle mit diesem Belegstellen-Alias
205205
zu kopieren. Tipp: Suchen Sie nach diesem Belegstellen-Alias in der Schnellsuche,
206206
um direkt zu dieser Belegstelle zu gelangen.
207+
genericPermalinkTip: Klicken Sie hier, um eine URL zur aktuellen Belegstelle zu kopieren.
208+
shareLocUrl: Belegstellen-URL teilen
207209
msgNoNearest: Es gibt keine weiteren Belegstellen mit Inhalten dieser Ressource in dieser Richtung.
208210
toolbar:
209211
tipSelectLocation: Belegstelle auswählen

Tekst-Web/i18n/ui/enUS.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ browse:
200200
aliasesTip: |
201201
Click here to copy a URL to the current location using this location alias.
202202
Hint: Search for this location alias in the Quick Search to directly jump to this location.
203+
genericPermalinkTip: Click here to copy a URL to the current location.
204+
shareLocUrl: Share location URL
203205
msgNoNearest: There are no more locations holding contents of this resource in this direction.
204206
toolbar:
205207
tipSelectLocation: Select location

Tekst-Web/package-lock.json

Lines changed: 0 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tekst-Web/src/components/browse/LocationAliasesWidget.vue

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import env from '@/env';
44
import { NFlex } from 'naive-ui';
55
66
defineProps<{
7+
locationId: string;
78
textSlug: string;
89
aliases?: string[];
910
}>();
@@ -13,16 +14,28 @@ const baseUrl = `${origin}/${env.WEB_PATH_STRIPPED}`.replace(/\/+$/, '');
1314

1415
<template>
1516
<n-flex align="center" class="my-lg">
17+
<template v-if="!!aliases?.length">
18+
<copy-to-clipboard-button
19+
v-for="alias in aliases"
20+
:key="alias"
21+
tertiary
22+
size="tiny"
23+
:text="`${baseUrl}/bookmark/${locationId}/${textSlug}/${alias}`"
24+
:title="$t('browse.location.aliasesTip')"
25+
show-msg
26+
>
27+
{{ alias }}
28+
</copy-to-clipboard-button>
29+
</template>
1630
<copy-to-clipboard-button
17-
v-for="alias in aliases"
18-
:key="alias"
31+
v-else
1932
tertiary
2033
size="tiny"
21-
:text="`${baseUrl}/bookmark/${textSlug}/${alias}`"
22-
:title="$t('browse.location.aliasesTip')"
34+
:text="`${baseUrl}/bookmark/${locationId}/${textSlug}`"
35+
:title="$t('browse.location.genericPermalinkTip')"
2336
show-msg
2437
>
25-
{{ alias }}
38+
{{ $t('browse.location.shareLocUrl') }}
2639
</copy-to-clipboard-button>
2740
</n-flex>
2841
</template>

Tekst-Web/src/router.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ const router = createRouter({
106106
beforeEnter: async (to) => await _resolveBrowseLocation(to.query),
107107
},
108108
{
109-
path: '/bookmark/:textSlug/:alias',
109+
path: '/bookmark/:locId+',
110110
name: 'bookmark',
111111
component: () => null,
112-
beforeEnter: async (to) => await _resolveBrowseLocation(to.params),
112+
// only the first locId param is used here and expected to be a valid ID,
113+
// the others are solely for holding pretty things to please the human eye
114+
beforeEnter: async (to) => await _resolveBrowseLocation({ locId: to.params.locId[0] }),
113115
},
114116
{
115117
path: '/search',

Tekst-Web/src/views/BrowseView.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ const browse = useBrowseStore();
2424
const state = useStateStore();
2525
const resources = useResourcesStore();
2626
27-
const showLocAliases = computed(
28-
() => state.pf?.state.showLocationAliases && !!browse.locationPathHead?.aliases?.length
29-
);
30-
3127
const catHiddenResCount = computed<Record<string, number>>(() =>
3228
Object.fromEntries(
3329
browse.resourcesCategorized.map((c) => [
@@ -88,8 +84,9 @@ onMounted(() => {
8884
</icon-heading>
8985

9086
<location-aliases-widget
91-
v-if="showLocAliases"
92-
:aliases="browse.locationPathHead?.aliases || undefined"
87+
v-if="browse.locationPathHead"
88+
:location-id="browse.locationPathHead.id"
89+
:aliases="browse.locationPathHead.aliases || undefined"
9390
:text-slug="state.textSlug"
9491
/>
9592
<location-metadata-content-tags v-if="!!embeddedMetadata.length" :contents="embeddedMetadata" />

0 commit comments

Comments
 (0)