Mangane/README.md

203 lines
6 KiB
Markdown
Raw Normal View History

2020-06-10 20:32:03 +02:00
# Soapbox FE
2020-03-28 22:06:29 +01:00
2020-05-24 15:57:41 +02:00
![Soapbox FE Screenshot](soapbox-screenshot.png)
2020-06-10 20:32:03 +02:00
**Soapbox FE** is a frontend for Pleroma with a focus on custom branding and ease of use.
It's part of the [Soapbox](https://soapbox.pub) project.
2020-04-30 18:39:50 +02:00
# :rocket: Deploy on Pleroma
2020-04-26 23:30:39 +02:00
2020-06-10 20:32:03 +02:00
Installing Soapbox FE on an existing Pleroma server is extremely easy.
2020-04-26 23:30:39 +02:00
Just ssh into the server and download a .zip of the latest build:
```sh
2020-06-14 20:50:27 +02:00
curl -L https://gitlab.com/soapbox-pub/soapbox-fe/-/jobs/artifacts/v1.0.0/download?job=build-production -o soapbox-fe.zip
2020-04-26 23:30:39 +02:00
```
Then unpack it into Pleroma's `instance` directory:
```sh
busybox unzip soapbox-fe.zip -o -d /opt/pleroma/instance
```
**That's it!** :tada:
2020-06-10 20:32:03 +02:00
**Soapbox FE is installed.**
2020-04-26 23:30:39 +02:00
The change will take effect immediately, just refresh your browser tab.
It's not necessary to restart the Pleroma service.
2020-06-10 20:32:03 +02:00
To remove Soapbox FE and revert to the default pleroma-fe, simply `rm /opt/pleroma/instance/index.html` (you can delete other stuff in there too, but be careful not to delete your own HTML files).
## How does it work?
Soapbox FE is a [single-page application (SPA)](https://en.wikipedia.org/wiki/Single-page_application) that runs entirely in the browser with JavaScript.
It has a single HTML file, `index.html`, responsible only for loading the required JavaScript and CSS.
It interacts with the backend through [XMLHttpRequest (XHR)](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest).
It incorporates much of the [Mastodon API](https://docs.joinmastodon.org/methods/) used by Pleroma and Mastodon, but requires many [Pleroma-specific features](https://docs-develop.pleroma.social/backend/API/differences_in_mastoapi_responses/) in order to function.
2020-04-26 23:30:39 +02:00
2020-04-30 18:42:09 +02:00
# Running locally
2020-04-07 03:30:05 +02:00
To get it running, just clone the repo:
```sh
2020-04-07 03:30:05 +02:00
git clone https://gitlab.com/soapbox-pub/soapbox-fe.git
cd soapbox-fe
```
Ensure that Node.js and Yarn are installed, then install dependencies:
```sh
2020-04-07 03:30:05 +02:00
yarn
```
Finally, run the dev server:
```sh
yarn start
2020-04-07 03:30:05 +02:00
```
2020-04-21 20:34:18 +02:00
**That's it!** :tada:
2020-04-07 03:30:05 +02:00
It will serve at `http://localhost:3036` by default.
It will proxy requests to the backend for you.
2020-04-21 20:34:18 +02:00
For Pleroma running on `localhost:4000` (the default) no other changes are required, just start a local Pleroma server and it should begin working.
### Troubleshooting: `ERROR: NODE_ENV must be set`
Create a `.env` file if you haven't already.
```sh
cp .env.example .env
```
And ensure that it contains `NODE_ENV=development`.
Try again.
2020-04-21 20:34:18 +02:00
## Developing against a live backend
2020-06-10 20:32:03 +02:00
You can also run Soapbox FE locally with a live production server as the backend.
2020-04-21 20:34:18 +02:00
2020-06-27 04:19:35 +02:00
> **Note:** Whether or not this works depends on your production server. It does not seem to work with Cloudflare or VanwaNet.
2020-04-21 20:39:30 +02:00
2020-04-21 20:34:18 +02:00
To do so, just copy the env file:
```sh
cp .env.example .env
```
And edit `.env`, setting the configuration like this:
```sh
BACKEND_URL="https://pleroma.example.com"
PROXY_HTTPS_INSECURE=true
```
You will need to restart the local development server for the changes to take effect.
2020-04-07 03:30:05 +02:00
2020-04-30 18:42:09 +02:00
## Local Dev Configuration
2020-04-21 20:34:18 +02:00
The following configuration variables are supported supported in local development.
Edit `.env` to set them.
All configuration is optional, except `NODE_ENV`.
#### `NODE_ENV`
The Node environment.
2020-06-10 20:32:03 +02:00
Soapbox FE checks for the following options:
2020-06-10 20:32:03 +02:00
- `development` - What you should use while developing Soapbox FE.
- `production` - Use when compiling to deploy to a live server.
- `test` - Use when running automated tests.
2020-04-21 20:34:18 +02:00
#### `BACKEND_URL`
URL to the backend server.
Can be http or https, and can include a port.
For https, be sure to also set `PROXY_HTTPS_INSECURE=true`.
**Default:** `http://localhost:4000`
#### `PROXY_HTTPS_INSECURE`
Allows using an HTTPS backend if set to `true`.
This is needed if `BACKEND_URL` or `PATRON_URL` are set to an `https://` value.
[More info](https://stackoverflow.com/a/48624590/8811886).
**Default:** `false`
# Yarn Commands
The following commands are supported.
You must set `NODE_ENV` to use these commands.
To do so, you can add the following line to your `.env` file:
```sh
NODE_ENV=development
```
#### Local dev server
2020-04-14 23:50:42 +02:00
- `yarn dev` - Exact same as above, aliased to `yarn start` for convenience.
#### Building
- `yarn build` - Compile without a dev server, into `/static` directory.
#### Translations
- `yarn manage:translations` - Normalizes translation files. Should always be run after editing i18n strings.
#### Tests
2020-04-14 20:07:40 +02:00
- `yarn test` - Runs all tests.
- `yarn test:lint` - Runs all linter tests.
- `yarn test:lint:js` - Runs only JavaScript linter.
- `yarn test:lint:sass` - Runs only SASS linter.
- `yarn test:jest` - Frontend unit tests.
# Contributing
We welcome contributions to this project. To contribute, first review the [Contributing doc](docs/contributing.md)
Additional supporting documents include:
* [Soapbox History](docs/history.md)
* [Redux Store Map](docs/history.md)
# Customization
Soapbox supports customization of the user interface, to allow per instance branding and other features. Current customization features include:
2020-06-10 20:32:03 +02:00
* Instance name
* Site logo
* Favicon
* About page
* Terms of Service page
2020-05-29 00:52:35 +02:00
* Privacy Policy page
* Copyright Policy (DMCA) page
* Promo panel list items, e.g. blog site link
2020-05-29 00:52:35 +02:00
* Soapbox extensions, e.g. Patron module
* Default settings, e.g. default theme
Customization details can be found in the [Customization doc](docs/customization.md)
2020-06-10 20:32:03 +02:00
# License & Credits
Soapbox FE is based on [Gab Social](https://code.gab.com/gab/social/gab-social)'s frontend which is in turn based on [Mastodon](https://github.com/tootsuite/mastodon/)'s frontend.
2020-03-28 22:06:29 +01:00
2020-06-10 20:32:03 +02:00
Soapbox FE is free software: you can redistribute it and/or modify
2020-03-28 22:06:29 +01:00
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2020-06-10 20:32:03 +02:00
Soapbox FE is distributed in the hope that it will be useful,
2020-03-28 22:06:29 +01:00
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
2020-06-10 20:32:03 +02:00
along with Soapbox FE. If not, see <https://www.gnu.org/licenses/>.