Allow features overrides, document `custom/` directory

This commit is contained in:
Alex Gleason 2022-03-03 23:05:37 -06:00
parent 4543e943dd
commit afb7827f40
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 55 additions and 2 deletions

View File

@ -4,6 +4,19 @@ import { createSelector } from 'reselect';
import gte from 'semver/functions/gte'; import gte from 'semver/functions/gte';
import lt from 'semver/functions/lt'; import lt from 'semver/functions/lt';
// FIXME: We have to use a dynamic import to trick Webpack into treating it as
// optional, but this causes custom locales to become part of the main chunk.
const importCustom = path => {
try {
return require(`custom/${path}.json`);
} catch(e) {
return {};
}
};
// Import custom overrides, if exists
const overrides = importCustom('features');
const any = arr => arr.some(Boolean); const any = arr => arr.some(Boolean);
// For uglification // For uglification
@ -16,7 +29,7 @@ export const getFeatures = createSelector([instance => instance], instance => {
const features = instance.getIn(['pleroma', 'metadata', 'features'], ImmutableList()); const features = instance.getIn(['pleroma', 'metadata', 'features'], ImmutableList());
const federation = instance.getIn(['pleroma', 'metadata', 'federation'], ImmutableMap()); const federation = instance.getIn(['pleroma', 'metadata', 'federation'], ImmutableMap());
return { return Object.assign({
bookmarks: any([ bookmarks: any([
v.software === MASTODON && gte(v.compatVersion, '3.1.0'), v.software === MASTODON && gte(v.compatVersion, '3.1.0'),
v.software === PLEROMA && gte(v.version, '0.9.9'), v.software === PLEROMA && gte(v.version, '0.9.9'),
@ -93,7 +106,7 @@ export const getFeatures = createSelector([instance => instance], instance => {
v.software === MASTODON && gte(v.compatVersion, '3.2.0'), v.software === MASTODON && gte(v.compatVersion, '3.2.0'),
v.software === PLEROMA && gte(v.version, '2.4.50'), v.software === PLEROMA && gte(v.version, '2.4.50'),
]), ]),
}; }, overrides);
}); });
export const parseVersion = version => { export const parseVersion = version => {

View File

@ -1,5 +1,45 @@
# Build Configuration # Build Configuration
Soapbox supports compile-time customizations in the form of environment variables and a gitignored `custom/` directory.
## `custom/` directory
You can place files into the `custom/` directory to customize the Soapbox build.
### Custom locales (`custom/locales/*.json`)
It is possible to override locale messages by creating a file for each language, eg `custom/locales/en.json`.
In this file, add only the messages you want to be overridden.
For example:
```json
{
"account.posts": "Poasts",
"account.posts_with_replies": "Poasts & Replies",
"compose.submit_success": "Your poast was sent!",
"compose_form.publish": "Poast"
}
```
These messages will be merged into the language file shipped with Soapbox.
### Feature overrides (`custom/features.json`)
You can create a file called `custom/features.json` to disable version-checking and force some features on or off.
For example:
```json
{
"bookmarks": false,
"lists": false,
"quotePosts": true
}
```
See `app/soapbox/utils/features.js` for the full list of features.
## Environment variables
When compiling Soapbox FE, environment variables may be passed to change the build itself. When compiling Soapbox FE, environment variables may be passed to change the build itself.
For example: For example: