Remove share path references
This commit is contained in:
parent
0ad1a519a4
commit
bc5efad5ca
@ -4,23 +4,14 @@ import {
|
||||
getPathComponents,
|
||||
isPathCamera,
|
||||
isPathCameraPhoto,
|
||||
isPathCameraPhotoShare,
|
||||
isPathCameraShare,
|
||||
isPathFilmSimulation,
|
||||
isPathFilmSimulationPhoto,
|
||||
isPathFilmSimulationPhotoShare,
|
||||
isPathFilmSimulationShare,
|
||||
isPathFocalLength,
|
||||
isPathFocalLengthPhoto,
|
||||
isPathFocalLengthPhotoShare,
|
||||
isPathFocalLengthShare,
|
||||
isPathPhoto,
|
||||
isPathPhotoShare,
|
||||
isPathProtected,
|
||||
isPathTag,
|
||||
isPathTagPhoto,
|
||||
isPathTagPhotoShare,
|
||||
isPathTagShare,
|
||||
} from '@/site/paths';
|
||||
import { TAG_HIDDEN } from '@/tag';
|
||||
|
||||
@ -32,7 +23,6 @@ const CAMERA_OBJECT = { make: CAMERA_MAKE, model: CAMERA_MODEL };
|
||||
const FILM_SIMULATION = 'acros';
|
||||
const FOCAL_LENGTH = 90;
|
||||
const FOCAL_LENGTH_STRING = `${FOCAL_LENGTH}mm`;
|
||||
const SHARE = 'share';
|
||||
|
||||
const PATH_ROOT = '/';
|
||||
const PATH_GRID = '/grid';
|
||||
@ -43,32 +33,21 @@ const PATH_OG_ALL = `${PATH_OG}/all`;
|
||||
const PATH_OG_SAMPLE = `${PATH_OG}/sample`;
|
||||
|
||||
const PATH_PHOTO = `/p/${PHOTO_ID}`;
|
||||
const PATH_PHOTO_SHARE = `${PATH_PHOTO}/${SHARE}`;
|
||||
|
||||
const PATH_TAG = `/tag/${TAG}`;
|
||||
const PATH_TAG_SHARE = `${PATH_TAG}/${SHARE}`;
|
||||
const PATH_TAG_PHOTO = `${PATH_TAG}/${PHOTO_ID}`;
|
||||
const PATH_TAG_PHOTO_SHARE = `${PATH_TAG_PHOTO}/${SHARE}`;
|
||||
|
||||
const PATH_TAG_HIDDEN = `/tag/${TAG_HIDDEN}`;
|
||||
const PATH_TAG_HIDDEN_SHARE = `${PATH_TAG_HIDDEN}/${SHARE}`;
|
||||
const PATH_TAG_HIDDEN_PHOTO = `${PATH_TAG_HIDDEN}/${PHOTO_ID}`;
|
||||
const PATH_TAG_HIDDEN_PHOTO_SHARE = `${PATH_TAG_HIDDEN_PHOTO}/${SHARE}`;
|
||||
|
||||
const PATH_CAMERA = `/shot-on/${CAMERA_MAKE}/${CAMERA_MODEL}`;
|
||||
const PATH_CAMERA_SHARE = `${PATH_CAMERA}/${SHARE}`;
|
||||
const PATH_CAMERA_PHOTO = `${PATH_CAMERA}/${PHOTO_ID}`;
|
||||
const PATH_CAMERA_PHOTO_SHARE = `${PATH_CAMERA_PHOTO}/${SHARE}`;
|
||||
|
||||
const PATH_FILM_SIMULATION = `/film/${FILM_SIMULATION}`;
|
||||
const PATH_FILM_SIMULATION_SHARE = `${PATH_FILM_SIMULATION}/${SHARE}`;
|
||||
const PATH_FILM_SIMULATION_PHOTO = `${PATH_FILM_SIMULATION}/${PHOTO_ID}`;
|
||||
const PATH_FILM_SIMULATION_PHOTO_SHARE = `${PATH_FILM_SIMULATION_PHOTO}/${SHARE}`;
|
||||
|
||||
const PATH_FOCAL_LENGTH = `/focal/${FOCAL_LENGTH_STRING}`;
|
||||
const PATH_FOCAL_LENGTH_SHARE = `${PATH_FOCAL_LENGTH}/${SHARE}`;
|
||||
const PATH_FOCAL_LENGTH_PHOTO = `${PATH_FOCAL_LENGTH}/${PHOTO_ID}`;
|
||||
const PATH_FOCAL_LENGTH_PHOTO_SHARE = `${PATH_FOCAL_LENGTH_PHOTO}/${SHARE}`;
|
||||
|
||||
describe('Paths', () => {
|
||||
it('can be protected', () => {
|
||||
@ -85,49 +64,22 @@ describe('Paths', () => {
|
||||
expect(isPathProtected(PATH_OG_ALL)).toBe(true);
|
||||
expect(isPathProtected(PATH_OG_SAMPLE)).toBe(true);
|
||||
expect(isPathProtected(PATH_TAG_HIDDEN)).toBe(true);
|
||||
expect(isPathProtected(PATH_TAG_HIDDEN_SHARE)).toBe(true);
|
||||
expect(isPathProtected(PATH_TAG_HIDDEN_PHOTO)).toBe(true);
|
||||
expect(isPathProtected(PATH_TAG_HIDDEN_PHOTO_SHARE)).toBe(true);
|
||||
});
|
||||
it('can be classified', () => {
|
||||
// Positive
|
||||
expect(isPathPhoto(PATH_PHOTO)).toBe(true);
|
||||
expect(isPathPhotoShare(PATH_PHOTO_SHARE)).toBe(true);
|
||||
expect(isPathTag(PATH_TAG)).toBe(true);
|
||||
expect(isPathTagShare(PATH_TAG_SHARE)).toBe(true);
|
||||
expect(isPathTagPhoto(PATH_TAG_PHOTO)).toBe(true);
|
||||
expect(isPathTagPhotoShare(PATH_TAG_PHOTO_SHARE)).toBe(true);
|
||||
expect(isPathCamera(PATH_CAMERA)).toBe(true);
|
||||
expect(isPathCameraShare(PATH_CAMERA_SHARE)).toBe(true);
|
||||
expect(isPathCameraPhoto(PATH_CAMERA_PHOTO)).toBe(true);
|
||||
expect(isPathCameraPhotoShare(PATH_CAMERA_PHOTO_SHARE)).toBe(true);
|
||||
expect(isPathFilmSimulation(PATH_FILM_SIMULATION)).toBe(true);
|
||||
expect(isPathFilmSimulationShare(PATH_FILM_SIMULATION_SHARE)).toBe(true);
|
||||
expect(isPathFilmSimulationPhoto(PATH_FILM_SIMULATION_PHOTO)).toBe(true);
|
||||
expect(isPathFilmSimulationPhotoShare(PATH_FILM_SIMULATION_PHOTO_SHARE)).toBe(true);
|
||||
expect(isPathFocalLength(PATH_FOCAL_LENGTH)).toBe(true);
|
||||
expect(isPathFocalLengthShare(PATH_FOCAL_LENGTH_SHARE)).toBe(true);
|
||||
expect(isPathFocalLengthPhoto(PATH_FOCAL_LENGTH_PHOTO)).toBe(true);
|
||||
expect(isPathFocalLengthPhotoShare(PATH_FOCAL_LENGTH_PHOTO_SHARE)).toBe(true);
|
||||
// Negative
|
||||
expect(isPathPhoto(PATH_TAG_PHOTO_SHARE)).toBe(false);
|
||||
expect(isPathPhotoShare(PATH_TAG_PHOTO)).toBe(false);
|
||||
expect(isPathTag(PATH_TAG_SHARE)).toBe(false);
|
||||
expect(isPathTagShare(PATH_TAG)).toBe(false);
|
||||
expect(isPathTagPhoto(PATH_PHOTO_SHARE)).toBe(false);
|
||||
expect(isPathTagPhotoShare(PATH_PHOTO)).toBe(false);
|
||||
expect(isPathCamera(PATH_TAG_SHARE)).toBe(false);
|
||||
expect(isPathCameraShare(PATH_TAG)).toBe(false);
|
||||
expect(isPathCameraPhoto(PATH_PHOTO_SHARE)).toBe(false);
|
||||
expect(isPathCameraPhotoShare(PATH_PHOTO)).toBe(false);
|
||||
expect(isPathFilmSimulation(PATH_TAG_SHARE)).toBe(false);
|
||||
expect(isPathFilmSimulationShare(PATH_TAG)).toBe(false);
|
||||
expect(isPathFilmSimulationPhoto(PATH_PHOTO_SHARE)).toBe(false);
|
||||
expect(isPathFilmSimulationPhotoShare(PATH_PHOTO)).toBe(false);
|
||||
expect(isPathFocalLength(PATH_FILM_SIMULATION)).toBe(false);
|
||||
expect(isPathFocalLengthShare(PATH_FILM_SIMULATION_SHARE)).toBe(false);
|
||||
expect(isPathFocalLengthPhoto(PATH_FILM_SIMULATION_PHOTO)).toBe(false);
|
||||
expect(isPathFocalLengthPhotoShare(PATH_FILM_SIMULATION_PHOTO_SHARE)).toBe(false);
|
||||
});
|
||||
it('can be parsed', () => {
|
||||
// Core
|
||||
@ -135,69 +87,38 @@ describe('Paths', () => {
|
||||
expect(getPathComponents(PATH_PHOTO)).toEqual({
|
||||
photoId: PHOTO_ID,
|
||||
});
|
||||
expect(getPathComponents(PATH_PHOTO_SHARE)).toEqual({
|
||||
photoId: PHOTO_ID,
|
||||
});
|
||||
// Tag
|
||||
expect(getPathComponents(PATH_TAG)).toEqual({
|
||||
tag: TAG,
|
||||
});
|
||||
expect(getPathComponents(PATH_TAG_SHARE)).toEqual({
|
||||
tag: TAG,
|
||||
});
|
||||
expect(getPathComponents(PATH_TAG_PHOTO)).toEqual({
|
||||
photoId: PHOTO_ID,
|
||||
tag: TAG,
|
||||
});
|
||||
expect(getPathComponents(PATH_TAG_PHOTO_SHARE)).toEqual({
|
||||
photoId: PHOTO_ID,
|
||||
tag: TAG,
|
||||
});
|
||||
// Camera
|
||||
expect(getPathComponents(PATH_CAMERA)).toEqual({
|
||||
camera: CAMERA_OBJECT,
|
||||
});
|
||||
expect(getPathComponents(PATH_CAMERA_SHARE)).toEqual({
|
||||
camera: CAMERA_OBJECT,
|
||||
});
|
||||
expect(getPathComponents(PATH_CAMERA_PHOTO)).toEqual({
|
||||
photoId: PHOTO_ID,
|
||||
camera: CAMERA_OBJECT,
|
||||
});
|
||||
expect(getPathComponents(PATH_CAMERA_PHOTO_SHARE)).toEqual({
|
||||
photoId: PHOTO_ID,
|
||||
camera: CAMERA_OBJECT,
|
||||
});
|
||||
// Film Simulation
|
||||
expect(getPathComponents(PATH_FILM_SIMULATION)).toEqual({
|
||||
simulation: FILM_SIMULATION,
|
||||
});
|
||||
expect(getPathComponents(PATH_FILM_SIMULATION_SHARE)).toEqual({
|
||||
simulation: FILM_SIMULATION,
|
||||
});
|
||||
expect(getPathComponents(PATH_FILM_SIMULATION_PHOTO)).toEqual({
|
||||
photoId: PHOTO_ID,
|
||||
simulation: FILM_SIMULATION,
|
||||
});
|
||||
expect(getPathComponents(PATH_FILM_SIMULATION_PHOTO_SHARE)).toEqual({
|
||||
photoId: PHOTO_ID,
|
||||
simulation: FILM_SIMULATION,
|
||||
});
|
||||
// Focal Length
|
||||
expect(getPathComponents(PATH_FOCAL_LENGTH)).toEqual({
|
||||
focal: FOCAL_LENGTH,
|
||||
});
|
||||
expect(getPathComponents(PATH_FOCAL_LENGTH_SHARE)).toEqual({
|
||||
focal: FOCAL_LENGTH,
|
||||
});
|
||||
expect(getPathComponents(PATH_FOCAL_LENGTH_PHOTO)).toEqual({
|
||||
photoId: PHOTO_ID,
|
||||
focal: FOCAL_LENGTH,
|
||||
});
|
||||
expect(getPathComponents(PATH_FOCAL_LENGTH_PHOTO_SHARE)).toEqual({
|
||||
photoId: PHOTO_ID,
|
||||
focal: FOCAL_LENGTH,
|
||||
});
|
||||
});
|
||||
it('can be escaped', () => {
|
||||
// Root
|
||||
@ -207,26 +128,17 @@ describe('Paths', () => {
|
||||
expect(getEscapePath(PATH_ADMIN)).toEqual(undefined);
|
||||
// Photo
|
||||
expect(getEscapePath(PATH_PHOTO)).toEqual(PATH_ROOT);
|
||||
expect(getEscapePath(PATH_PHOTO_SHARE)).toEqual(PATH_PHOTO);
|
||||
// Tag
|
||||
expect(getEscapePath(PATH_TAG)).toEqual(PATH_ROOT);
|
||||
expect(getEscapePath(PATH_TAG_SHARE)).toEqual(PATH_TAG);
|
||||
expect(getEscapePath(PATH_TAG_PHOTO)).toEqual(PATH_TAG);
|
||||
expect(getEscapePath(PATH_TAG_PHOTO_SHARE)).toEqual(PATH_TAG_PHOTO);
|
||||
// Camera
|
||||
expect(getEscapePath(PATH_CAMERA)).toEqual(PATH_ROOT);
|
||||
expect(getEscapePath(PATH_CAMERA_SHARE)).toEqual(PATH_CAMERA);
|
||||
expect(getEscapePath(PATH_CAMERA_PHOTO)).toEqual(PATH_CAMERA);
|
||||
expect(getEscapePath(PATH_CAMERA_PHOTO_SHARE)).toEqual(PATH_CAMERA_PHOTO);
|
||||
// Film Simulation
|
||||
expect(getEscapePath(PATH_FILM_SIMULATION)).toEqual(PATH_ROOT);
|
||||
expect(getEscapePath(PATH_FILM_SIMULATION_SHARE)).toEqual(PATH_FILM_SIMULATION);
|
||||
expect(getEscapePath(PATH_FILM_SIMULATION_PHOTO)).toEqual(PATH_FILM_SIMULATION);
|
||||
expect(getEscapePath(PATH_FILM_SIMULATION_PHOTO_SHARE)).toEqual(PATH_FILM_SIMULATION_PHOTO);
|
||||
// Focal Length
|
||||
expect(getEscapePath(PATH_FOCAL_LENGTH)).toEqual(PATH_ROOT);
|
||||
expect(getEscapePath(PATH_FOCAL_LENGTH_SHARE)).toEqual(PATH_FOCAL_LENGTH);
|
||||
expect(getEscapePath(PATH_FOCAL_LENGTH_PHOTO)).toEqual(PATH_FOCAL_LENGTH);
|
||||
expect(getEscapePath(PATH_FOCAL_LENGTH_PHOTO_SHARE)).toEqual(PATH_FOCAL_LENGTH_PHOTO);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { Photo, PhotoDateRange } from '@/photo';
|
||||
import { pathForCameraShare } from '@/site/paths';
|
||||
import PhotoHeader from '@/photo/PhotoHeader';
|
||||
import { Camera, cameraFromPhoto } from '.';
|
||||
import PhotoCamera from './PhotoCamera';
|
||||
@ -29,10 +28,10 @@ export default function CameraHeader({
|
||||
descriptionForCameraPhotos(photos, undefined, count, dateRange)}
|
||||
photos={photos}
|
||||
selectedPhoto={selectedPhoto}
|
||||
sharePath={pathForCameraShare(camera)}
|
||||
indexNumber={indexNumber}
|
||||
count={count}
|
||||
dateRange={dateRange}
|
||||
includeShareButton
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { Photo, PhotoDateRange } from '@/photo';
|
||||
import { descriptionForFocalLengthPhotos } from '.';
|
||||
import { pathForFocalLengthShare } from '@/site/paths';
|
||||
import PhotoHeader from '@/photo/PhotoHeader';
|
||||
import PhotoFocalLength from './PhotoFocalLength';
|
||||
|
||||
@ -30,10 +29,10 @@ export default function FocalLengthHeader({
|
||||
)}
|
||||
photos={photos}
|
||||
selectedPhoto={selectedPhoto}
|
||||
sharePath={pathForFocalLengthShare(focal)}
|
||||
indexNumber={indexNumber}
|
||||
count={count}
|
||||
dateRange={dateRange}
|
||||
includeShareButton
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -27,20 +27,20 @@ export default function PhotoHeader({
|
||||
entity,
|
||||
entityVerb = 'PHOTO',
|
||||
entityDescription,
|
||||
sharePath,
|
||||
indexNumber,
|
||||
count,
|
||||
dateRange,
|
||||
includeShareButton,
|
||||
}: {
|
||||
photos: Photo[]
|
||||
selectedPhoto?: Photo
|
||||
entity?: ReactNode
|
||||
entityVerb?: string
|
||||
entityDescription?: string
|
||||
sharePath?: string
|
||||
indexNumber?: number
|
||||
count?: number
|
||||
dateRange?: PhotoDateRange
|
||||
includeShareButton?: boolean
|
||||
} & PhotoSetCategory) {
|
||||
const { isGridHighDensity } = useAppState();
|
||||
|
||||
@ -138,7 +138,7 @@ export default function PhotoHeader({
|
||||
{headerType === 'photo-set'
|
||||
? <>
|
||||
{entityDescription}
|
||||
{sharePath &&
|
||||
{includeShareButton &&
|
||||
<ShareButton
|
||||
photos={photos}
|
||||
tag={tag}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { Photo, PhotoDateRange } from '@/photo';
|
||||
import { FilmSimulation, descriptionForFilmSimulationPhotos } from '.';
|
||||
import { pathForFilmSimulationShare } from '@/site/paths';
|
||||
import PhotoHeader from '@/photo/PhotoHeader';
|
||||
import PhotoFilmSimulation from
|
||||
'@/simulation/PhotoFilmSimulation';
|
||||
@ -28,10 +27,10 @@ export default function FilmSimulationHeader({
|
||||
photos, undefined, count, dateRange)}
|
||||
photos={photos}
|
||||
selectedPhoto={selectedPhoto}
|
||||
sharePath={pathForFilmSimulationShare(simulation)}
|
||||
indexNumber={indexNumber}
|
||||
count={count}
|
||||
dateRange={dateRange}
|
||||
includeShareButton
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -51,7 +51,6 @@ export const PATH_API_VERCEL_BLOB_UPLOAD = `${PATH_API_STORAGE}/vercel-blob`;
|
||||
export const PATH_API_PRESIGNED_URL = `${PATH_API_STORAGE}/presigned-url`;
|
||||
|
||||
// Modifiers
|
||||
const SHARE = 'share';
|
||||
const EDIT = 'edit';
|
||||
|
||||
export const PATHS_ADMIN = [
|
||||
@ -113,33 +112,18 @@ export const pathForPhoto = ({
|
||||
? `${pathForFocalLength(focal)}/${getPhotoId(photo)}`
|
||||
: `${PREFIX_PHOTO}/${getPhotoId(photo)}`;
|
||||
|
||||
export const pathForPhotoShare = (params: PhotoPathParams) =>
|
||||
`${pathForPhoto(params)}/${SHARE}`;
|
||||
|
||||
export const pathForTag = (tag: string) =>
|
||||
`${PREFIX_TAG}/${tag}`;
|
||||
|
||||
export const pathForTagShare = (tag: string) =>
|
||||
`${pathForTag(tag)}/${SHARE}`;
|
||||
|
||||
export const pathForCamera = ({ make, model }: Camera) =>
|
||||
`${PREFIX_CAMERA}/${parameterize(make, true)}/${parameterize(model, true)}`;
|
||||
|
||||
export const pathForCameraShare = (camera: Camera) =>
|
||||
`${pathForCamera(camera)}/${SHARE}`;
|
||||
|
||||
export const pathForFilmSimulation = (simulation: FilmSimulation) =>
|
||||
`${PREFIX_FILM_SIMULATION}/${simulation}`;
|
||||
|
||||
export const pathForFilmSimulationShare = (simulation: FilmSimulation) =>
|
||||
`${pathForFilmSimulation(simulation)}/${SHARE}`;
|
||||
|
||||
export const pathForFocalLength = (focal: number) =>
|
||||
`${PREFIX_FOCAL_LENGTH}/${focal}mm`;
|
||||
|
||||
export const pathForFocalLengthShare = (focal: number) =>
|
||||
`${pathForFocalLength(focal)}/${SHARE}`;;
|
||||
|
||||
export const absolutePathForPhoto = (params: PhotoPathParams) =>
|
||||
`${BASE_URL}${pathForPhoto(params)}`;
|
||||
|
||||
@ -176,76 +160,38 @@ export const absolutePathForFocalLengthImage =
|
||||
export const isPathPhoto = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_PHOTO}/[^/]+/?$`).test(pathname);
|
||||
|
||||
// p/[photoId]/share
|
||||
export const isPathPhotoShare = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_PHOTO}/[^/]+/${SHARE}/?$`).test(pathname);
|
||||
|
||||
// tag/[tag]
|
||||
export const isPathTag = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_TAG}/[^/]+/?$`).test(pathname);
|
||||
|
||||
// tag/[tag]/share
|
||||
export const isPathTagShare = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_TAG}/[^/]+/${SHARE}/?$`).test(pathname);
|
||||
new RegExp(`^${PREFIX_TAG}/[^/]+/?$`).test(pathname);;
|
||||
|
||||
// tag/[tag]/[photoId]
|
||||
export const isPathTagPhoto = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_TAG}/[^/]+/[^/]+/?$`).test(pathname);
|
||||
|
||||
// tag/[tag]/[photoId]/share
|
||||
export const isPathTagPhotoShare = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_TAG}/[^/]+/[^/]+/${SHARE}/?$`).test(pathname);
|
||||
|
||||
// shot-on/[make]/[model]
|
||||
export const isPathCamera = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_CAMERA}/[^/]+/[^/]+/?$`).test(pathname);
|
||||
|
||||
// shot-on/[make]/[model]/share
|
||||
export const isPathCameraShare = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_CAMERA}/[^/]+/[^/]+/${SHARE}/?$`).test(pathname);
|
||||
|
||||
// shot-on/[make]/[model]/[photoId]
|
||||
export const isPathCameraPhoto = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_CAMERA}/[^/]+/[^/]+/[^/]+/?$`).test(pathname);
|
||||
|
||||
// shot-on/[make]/[model]/[photoId]/share
|
||||
export const isPathCameraPhotoShare = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_CAMERA}/[^/]+/[^/]+/[^/]+/${SHARE}/?$`).test(pathname);
|
||||
|
||||
// film/[simulation]
|
||||
export const isPathFilmSimulation = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_FILM_SIMULATION}/[^/]+/?$`).test(pathname);
|
||||
|
||||
// film/[simulation]/share
|
||||
export const isPathFilmSimulationShare = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_FILM_SIMULATION}/[^/]+/${SHARE}/?$`).test(pathname);
|
||||
|
||||
// film/[simulation]/[photoId]
|
||||
export const isPathFilmSimulationPhoto = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_FILM_SIMULATION}/[^/]+/[^/]+/?$`).test(pathname);
|
||||
|
||||
// film/[simulation]/[photoId]/share
|
||||
export const isPathFilmSimulationPhotoShare = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_FILM_SIMULATION}/[^/]+/[^/]+/${SHARE}/?$`)
|
||||
.test(pathname);
|
||||
|
||||
// focal/[focal]
|
||||
export const isPathFocalLength = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_FOCAL_LENGTH}/[^/]+/?$`).test(pathname);
|
||||
|
||||
// focal/[focal]/share
|
||||
export const isPathFocalLengthShare = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_FOCAL_LENGTH}/[^/]+/${SHARE}/?$`).test(pathname);
|
||||
|
||||
// focal/[focal]/[photoId]
|
||||
export const isPathFocalLengthPhoto = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_FOCAL_LENGTH}/[^/]+/[^/]+/?$`).test(pathname);
|
||||
|
||||
// focal/[focal]/[photoId]/share
|
||||
export const isPathFocalLengthPhotoShare = (pathname = '') =>
|
||||
new RegExp(`^${PREFIX_FOCAL_LENGTH}/[^/]+/[^/]+/${SHARE}/?$`)
|
||||
.test(pathname);
|
||||
|
||||
export const checkPathPrefix = (pathname = '', prefix: string) =>
|
||||
pathname.toLowerCase().startsWith(prefix);
|
||||
|
||||
@ -278,13 +224,13 @@ export const getPathComponents = (pathname = ''): {
|
||||
const photoIdFromPhoto = pathname.match(
|
||||
new RegExp(`^${PREFIX_PHOTO}/([^/]+)`))?.[1];
|
||||
const photoIdFromTag = pathname.match(
|
||||
new RegExp(`^${PREFIX_TAG}/[^/]+/((?!${SHARE})[^/]+)`))?.[1];
|
||||
new RegExp(`^${PREFIX_TAG}/[^/]+/([^/]+)`))?.[1];
|
||||
const photoIdFromCamera = pathname.match(
|
||||
new RegExp(`^${PREFIX_CAMERA}/[^/]+/[^/]+/((?!${SHARE})[^/]+)`))?.[1];
|
||||
new RegExp(`^${PREFIX_CAMERA}/[^/]+/[^/]+/([^/]+)`))?.[1];
|
||||
const photoIdFromFilmSimulation = pathname.match(
|
||||
new RegExp(`^${PREFIX_FILM_SIMULATION}/[^/]+/((?!${SHARE})[^/]+)`))?.[1];
|
||||
new RegExp(`^${PREFIX_FILM_SIMULATION}/[^/]+/([^/]+)`))?.[1];
|
||||
const photoIdFromFocalLength = pathname.match(
|
||||
new RegExp(`^${PREFIX_FOCAL_LENGTH}/[0-9]+mm/((?!${SHARE})[^/]+)`))?.[1];
|
||||
new RegExp(`^${PREFIX_FOCAL_LENGTH}/[0-9]+mm/([^/]+)`))?.[1];
|
||||
const tag = pathname.match(
|
||||
new RegExp(`^${PREFIX_TAG}/([^/]+)`))?.[1];
|
||||
const cameraMake = pathname.match(
|
||||
@ -334,35 +280,13 @@ export const getEscapePath = (pathname?: string) => {
|
||||
(focal && isPathFocalLength(pathname))
|
||||
) {
|
||||
return PATH_ROOT;
|
||||
} else if (photoId && isPathTagPhotoShare(pathname)) {
|
||||
return pathForPhoto({ photo: photoId, tag });
|
||||
} else if (photoId && isPathCameraPhotoShare(pathname)) {
|
||||
return pathForPhoto({ photo: photoId, camera });
|
||||
} else if (photoId && isPathFilmSimulationPhotoShare(pathname)) {
|
||||
return pathForPhoto({ photo: photoId, simulation });
|
||||
} else if (photoId && isPathFocalLengthPhotoShare(pathname)) {
|
||||
return pathForPhoto({ photo: photoId, focal });
|
||||
} else if (photoId && isPathPhotoShare(pathname)) {
|
||||
return pathForPhoto({ photo: photoId });
|
||||
} else if (tag && (
|
||||
isPathTagPhoto(pathname) ||
|
||||
isPathTagShare(pathname)
|
||||
)) {
|
||||
} else if (tag && isPathTagPhoto(pathname)) {
|
||||
return pathForTag(tag);
|
||||
} else if (camera && (
|
||||
isPathCameraPhoto(pathname) ||
|
||||
isPathCameraShare(pathname)
|
||||
)) {
|
||||
} else if (camera && isPathCameraPhoto(pathname)) {
|
||||
return pathForCamera(camera);
|
||||
} else if (simulation && (
|
||||
isPathFilmSimulationPhoto(pathname) ||
|
||||
isPathFilmSimulationShare(pathname)
|
||||
)) {
|
||||
} else if (simulation && isPathFilmSimulationPhoto(pathname)) {
|
||||
return pathForFilmSimulation(simulation);
|
||||
} else if (focal && (
|
||||
isPathFocalLengthPhoto(pathname) ||
|
||||
isPathFocalLengthShare(pathname)
|
||||
)) {
|
||||
} else if (focal && isPathFocalLengthPhoto(pathname)) {
|
||||
return pathForFocalLength(focal);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { Photo, PhotoDateRange } from '@/photo';
|
||||
import PhotoTag from './PhotoTag';
|
||||
import { descriptionForTaggedPhotos, isTagFavs } from '.';
|
||||
import { pathForTagShare } from '@/site/paths';
|
||||
import PhotoHeader from '@/photo/PhotoHeader';
|
||||
import FavsTag from './FavsTag';
|
||||
|
||||
@ -30,10 +29,10 @@ export default function TagHeader({
|
||||
entityDescription={descriptionForTaggedPhotos(photos, undefined, count)}
|
||||
photos={photos}
|
||||
selectedPhoto={selectedPhoto}
|
||||
sharePath={pathForTagShare(tag)}
|
||||
indexNumber={indexNumber}
|
||||
count={count}
|
||||
dateRange={dateRange}
|
||||
includeShareButton
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user