Merge branch 'rm-subdirectory' into 'main'
Remove subdirectory build support, FE_SUBDIRECTORY variable See merge request soapbox-pub/soapbox!3246
This commit is contained in:
commit
15483208ee
|
@ -1,44 +0,0 @@
|
||||||
import MockAdapter from 'axios-mock-adapter';
|
|
||||||
import { describe, expect, it } from 'vitest';
|
|
||||||
|
|
||||||
import { staticClient } from 'soapbox/api/index.ts';
|
|
||||||
import { mockStore } from 'soapbox/jest/test-helpers.tsx';
|
|
||||||
|
|
||||||
import {
|
|
||||||
FETCH_ABOUT_PAGE_REQUEST,
|
|
||||||
FETCH_ABOUT_PAGE_SUCCESS,
|
|
||||||
FETCH_ABOUT_PAGE_FAIL,
|
|
||||||
fetchAboutPage,
|
|
||||||
} from './about.ts';
|
|
||||||
|
|
||||||
describe('fetchAboutPage()', () => {
|
|
||||||
it('creates the expected actions on success', () => {
|
|
||||||
|
|
||||||
const mock = new MockAdapter(staticClient);
|
|
||||||
|
|
||||||
mock.onGet('/instance/about/index.html')
|
|
||||||
.reply(200, '<h1>Hello world</h1>');
|
|
||||||
|
|
||||||
const expectedActions = [
|
|
||||||
{ type: FETCH_ABOUT_PAGE_REQUEST, slug: 'index' },
|
|
||||||
{ type: FETCH_ABOUT_PAGE_SUCCESS, slug: 'index', html: '<h1>Hello world</h1>' },
|
|
||||||
];
|
|
||||||
const store = mockStore({});
|
|
||||||
|
|
||||||
return store.dispatch(fetchAboutPage()).then(() => {
|
|
||||||
expect(store.getActions()).toEqual(expectedActions);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('creates the expected actions on failure', () => {
|
|
||||||
const expectedActions = [
|
|
||||||
{ type: FETCH_ABOUT_PAGE_REQUEST, slug: 'asdf' },
|
|
||||||
{ type: FETCH_ABOUT_PAGE_FAIL, slug: 'asdf', error: new Error('Request failed with status code 404') },
|
|
||||||
];
|
|
||||||
const store = mockStore({});
|
|
||||||
|
|
||||||
return store.dispatch(fetchAboutPage('asdf')).catch(() => {
|
|
||||||
expect(store.getActions()).toEqual(expectedActions);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -9,7 +9,6 @@ import { compareId } from 'soapbox/utils/comparators.ts';
|
||||||
import { getFeatures, parseVersion, PLEROMA } from 'soapbox/utils/features.ts';
|
import { getFeatures, parseVersion, PLEROMA } from 'soapbox/utils/features.ts';
|
||||||
import { unescapeHTML } from 'soapbox/utils/html.ts';
|
import { unescapeHTML } from 'soapbox/utils/html.ts';
|
||||||
import { EXCLUDE_TYPES, NOTIFICATION_TYPES } from 'soapbox/utils/notification.ts';
|
import { EXCLUDE_TYPES, NOTIFICATION_TYPES } from 'soapbox/utils/notification.ts';
|
||||||
import { joinPublicPath } from 'soapbox/utils/static.ts';
|
|
||||||
|
|
||||||
import { fetchRelationships } from './accounts.ts';
|
import { fetchRelationships } from './accounts.ts';
|
||||||
import { fetchGroupRelationships } from './groups.ts';
|
import { fetchGroupRelationships } from './groups.ts';
|
||||||
|
@ -120,7 +119,7 @@ const updateNotificationsQueue = (notification: APIEntity, intlMessages: Record<
|
||||||
icon: notification.account.avatar,
|
icon: notification.account.avatar,
|
||||||
tag: notification.id,
|
tag: notification.id,
|
||||||
data: {
|
data: {
|
||||||
url: joinPublicPath('/notifications'),
|
url: '/notifications',
|
||||||
},
|
},
|
||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import KVStore from 'soapbox/storage/kv-store.ts';
|
||||||
import { removeVS16s } from 'soapbox/utils/emoji.ts';
|
import { removeVS16s } from 'soapbox/utils/emoji.ts';
|
||||||
import { getFeatures } from 'soapbox/utils/features.ts';
|
import { getFeatures } from 'soapbox/utils/features.ts';
|
||||||
|
|
||||||
import api, { staticClient } from '../api/index.ts';
|
import api from '../api/index.ts';
|
||||||
|
|
||||||
import type { AppDispatch, RootState } from 'soapbox/store.ts';
|
import type { AppDispatch, RootState } from 'soapbox/store.ts';
|
||||||
import type { APIEntity } from 'soapbox/types/entities.ts';
|
import type { APIEntity } from 'soapbox/types/entities.ts';
|
||||||
|
@ -86,7 +86,7 @@ const loadSoapboxConfig = () =>
|
||||||
|
|
||||||
const fetchSoapboxJson = (host: string | null) =>
|
const fetchSoapboxJson = (host: string | null) =>
|
||||||
(dispatch: AppDispatch) =>
|
(dispatch: AppDispatch) =>
|
||||||
staticClient.get('/instance/soapbox.json').then(({ data }) => {
|
fetch('/instance/soapbox.json').then((response) => response.json()).then((data) => {
|
||||||
if (!isObject(data)) throw 'soapbox.json failed';
|
if (!isObject(data)) throw 'soapbox.json failed';
|
||||||
dispatch(importSoapboxConfig(data, host));
|
dispatch(importSoapboxConfig(data, host));
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -15,8 +15,6 @@ const setupMock = (axios: AxiosInstance) => {
|
||||||
mocks.map(func => func(mock));
|
mocks.map(func => func(mock));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const staticClient = api.staticClient;
|
|
||||||
|
|
||||||
export const getLinks = (response: AxiosResponse): LinkHeader => {
|
export const getLinks = (response: AxiosResponse): LinkHeader => {
|
||||||
return new LinkHeader(response.headers?.link);
|
return new LinkHeader(response.headers?.link);
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,16 +82,6 @@ export const baseClient = (
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Dumb client for grabbing static files.
|
|
||||||
* It uses FE_SUBDIRECTORY and parses JSON if possible.
|
|
||||||
* No authorization is needed.
|
|
||||||
*/
|
|
||||||
export const staticClient = axios.create({
|
|
||||||
baseURL: BuildConfig.FE_SUBDIRECTORY,
|
|
||||||
transformResponse: [maybeParseJSON],
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stateful API client.
|
* Stateful API client.
|
||||||
* Uses credentials from the Redux store if available.
|
* Uses credentials from the Redux store if available.
|
||||||
|
|
|
@ -3,15 +3,12 @@
|
||||||
* @module soapbox/build-config
|
* @module soapbox/build-config
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line import/extensions
|
|
||||||
import trim from 'lodash/trim.js';
|
|
||||||
// eslint-disable-next-line import/extensions
|
// eslint-disable-next-line import/extensions
|
||||||
import trimEnd from 'lodash/trimEnd.js';
|
import trimEnd from 'lodash/trimEnd.js';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
NODE_ENV,
|
NODE_ENV,
|
||||||
BACKEND_URL,
|
BACKEND_URL,
|
||||||
FE_SUBDIRECTORY,
|
|
||||||
FE_INSTANCE_SOURCE_DIR,
|
FE_INSTANCE_SOURCE_DIR,
|
||||||
SENTRY_DSN,
|
SENTRY_DSN,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
@ -24,14 +21,9 @@ const sanitizeURL = (url: string | undefined = ''): string => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const sanitizeBasename = (path: string | undefined = ''): string => {
|
|
||||||
return `/${trim(path, '/')}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const env = {
|
const env = {
|
||||||
NODE_ENV: NODE_ENV || 'development',
|
NODE_ENV: NODE_ENV || 'development',
|
||||||
BACKEND_URL: sanitizeURL(BACKEND_URL),
|
BACKEND_URL: sanitizeURL(BACKEND_URL),
|
||||||
FE_SUBDIRECTORY: sanitizeBasename(FE_SUBDIRECTORY),
|
|
||||||
FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance',
|
FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance',
|
||||||
SENTRY_DSN,
|
SENTRY_DSN,
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,6 @@ import type { SoapboxEnv } from './build-config-compiletime.ts';
|
||||||
export const {
|
export const {
|
||||||
NODE_ENV,
|
NODE_ENV,
|
||||||
BACKEND_URL,
|
BACKEND_URL,
|
||||||
FE_SUBDIRECTORY,
|
|
||||||
FE_INSTANCE_SOURCE_DIR,
|
FE_INSTANCE_SOURCE_DIR,
|
||||||
SENTRY_DSN,
|
SENTRY_DSN,
|
||||||
} = import.meta.compileTime<SoapboxEnv>('./build-config-compiletime.ts');
|
} = import.meta.compileTime<SoapboxEnv>('./build-config-compiletime.ts');
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import unicodeMapping from 'soapbox/features/emoji/mapping.ts';
|
import unicodeMapping from 'soapbox/features/emoji/mapping.ts';
|
||||||
import { useSettings } from 'soapbox/hooks/useSettings.ts';
|
import { useSettings } from 'soapbox/hooks/useSettings.ts';
|
||||||
import { joinPublicPath } from 'soapbox/utils/static.ts';
|
|
||||||
|
|
||||||
import type { Map as ImmutableMap } from 'immutable';
|
import type { Map as ImmutableMap } from 'immutable';
|
||||||
|
|
||||||
|
@ -25,7 +24,7 @@ const Emoji: React.FC<IEmoji> = ({ emoji, emojiMap, hovered }) => {
|
||||||
className='emojione m-0 block'
|
className='emojione m-0 block'
|
||||||
alt={emoji}
|
alt={emoji}
|
||||||
title={title}
|
title={title}
|
||||||
src={joinPublicPath(`packs/emoji/${filename}.svg`)}
|
src={`/packs/emoji/${filename}.svg`}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (emojiMap.get(emoji as any)) {
|
} else if (emojiMap.get(emoji as any)) {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { isCustomEmoji } from 'soapbox/features/emoji/index.ts';
|
import { isCustomEmoji } from 'soapbox/features/emoji/index.ts';
|
||||||
import unicodeMapping from 'soapbox/features/emoji/mapping.ts';
|
import unicodeMapping from 'soapbox/features/emoji/mapping.ts';
|
||||||
import { joinPublicPath } from 'soapbox/utils/static.ts';
|
|
||||||
|
|
||||||
import type { Emoji } from 'soapbox/features/emoji/index.ts';
|
import type { Emoji } from 'soapbox/features/emoji/index.ts';
|
||||||
|
|
||||||
|
@ -21,7 +20,7 @@ const AutosuggestEmoji: React.FC<IAutosuggestEmoji> = ({ emoji }) => {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
url = joinPublicPath(`packs/emoji/${mapping.unified}.svg`);
|
url = `/packs/emoji/${mapping.unified}.svg`;
|
||||||
alt = emoji.native;
|
alt = emoji.native;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { removeVS16s, toCodePoints } from 'soapbox/utils/emoji.ts';
|
import { removeVS16s, toCodePoints } from 'soapbox/utils/emoji.ts';
|
||||||
import { joinPublicPath } from 'soapbox/utils/static.ts';
|
|
||||||
|
|
||||||
interface IEmoji extends React.ImgHTMLAttributes<HTMLImageElement> {
|
interface IEmoji extends React.ImgHTMLAttributes<HTMLImageElement> {
|
||||||
/** Unicode emoji character. */
|
/** Unicode emoji character. */
|
||||||
|
@ -23,7 +22,7 @@ const Emoji: React.FC<IEmoji> = (props): JSX.Element | null => {
|
||||||
<img
|
<img
|
||||||
draggable='false'
|
draggable='false'
|
||||||
alt={alt || emoji}
|
alt={alt || emoji}
|
||||||
src={src || joinPublicPath(`packs/emoji/${filename}.svg`)}
|
src={src || `/packs/emoji/${filename}.svg`}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,14 +2,12 @@ import spriteSheet from 'emoji-datasource/img/twitter/sheets/32.png';
|
||||||
import { Picker as EmojiPicker } from 'emoji-mart';
|
import { Picker as EmojiPicker } from 'emoji-mart';
|
||||||
import { useRef, useEffect } from 'react';
|
import { useRef, useEffect } from 'react';
|
||||||
|
|
||||||
import { joinPublicPath } from 'soapbox/utils/static.ts';
|
|
||||||
|
|
||||||
import data from '../data.ts';
|
import data from '../data.ts';
|
||||||
|
|
||||||
const getSpritesheetURL = () => spriteSheet;
|
const getSpritesheetURL = () => spriteSheet;
|
||||||
|
|
||||||
const getImageURL = (set: string, name: string) => {
|
const getImageURL = (_set: string, name: string) => {
|
||||||
return joinPublicPath(`/packs/emoji/${name}.svg`);
|
return `/packs/emoji/${name}.svg`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Picker: React.FC<any> = (props) => {
|
const Picker: React.FC<any> = (props) => {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { BrowserRouter, Switch, Redirect, Route } from 'react-router-dom';
|
||||||
import { CompatRouter } from 'react-router-dom-v5-compat';
|
import { CompatRouter } from 'react-router-dom-v5-compat';
|
||||||
|
|
||||||
import { openModal } from 'soapbox/actions/modals.ts';
|
import { openModal } from 'soapbox/actions/modals.ts';
|
||||||
import * as BuildConfig from 'soapbox/build-config.ts';
|
|
||||||
import LoadingScreen from 'soapbox/components/loading-screen.tsx';
|
import LoadingScreen from 'soapbox/components/loading-screen.tsx';
|
||||||
import { ScrollContext } from 'soapbox/components/scroll-context.tsx';
|
import { ScrollContext } from 'soapbox/components/scroll-context.tsx';
|
||||||
import SiteErrorBoundary from 'soapbox/components/site-error-boundary.tsx';
|
import SiteErrorBoundary from 'soapbox/components/site-error-boundary.tsx';
|
||||||
|
@ -48,7 +47,7 @@ const SoapboxMount = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SiteErrorBoundary>
|
<SiteErrorBoundary>
|
||||||
<BrowserRouter basename={BuildConfig.FE_SUBDIRECTORY}>
|
<BrowserRouter>
|
||||||
<CompatRouter>
|
<CompatRouter>
|
||||||
<ScrollContext>
|
<ScrollContext>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
/**
|
|
||||||
* Static: functions related to static files.
|
|
||||||
* @module soapbox/utils/static
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { join } from 'path-browserify';
|
|
||||||
|
|
||||||
import * as BuildConfig from 'soapbox/build-config.ts';
|
|
||||||
|
|
||||||
/** Gets the path to a file with build configuration being considered. */
|
|
||||||
export const joinPublicPath = (...paths: string[]): string => {
|
|
||||||
return join(BuildConfig.FE_SUBDIRECTORY, ...paths);
|
|
||||||
};
|
|
Loading…
Reference in New Issue