aviary-ps/README.md

114 lines
3.4 KiB
Markdown
Raw Permalink Normal View History

2022-11-13 02:52:53 +00:00
# Aviary Web (PureScript)
Welcome to Aviary. This is the decode-only web frontend for viewing E2E
encrypted galleries on the web. This follows a protocol shared by
[`aviary-cli`][], which is (as of writing) the only way to create galleries.
This project is still pre-release. It works, but the protocol and the
application are both bound to go through heavy changes, and may be missing key
features. The most glaring of these, at time of writing, is the lack of
documentation.
## Building
This project is built with PureScript, and uses PureScript's package manager
`spago`, which you'll need to have installed. Visit [purescript.org][] for
information on how to do this.
### Development
For development builds, you can use the `spago bundle-app` command to generate
the `index.js` file. You may then proceed to the **Setup** section to set up a
webserver to work with.
### Production
For production builds, it is necessary to take several steps to reduce the file
size. You'll need to install a couple extra tools:
- [`lebab`][]
- [`uglify-js`][]
```bash
# Build the code
spago build
# Replace function(a) { b } with a => b
lebab --replace output/ --transform arrow,arrow-return
# Bundle the code into a single .js file, and minify
spago bundle-app --minify
# Perform some final optimizations
uglifyjs --compress --mangle --toplevel -- index.js > aviary.min.js
2022-11-13 02:52:53 +00:00
```
Aside: If you know a way to bring the file size down further, *please* open an issue!
You may now proceed to the **Setup** section.
## Setup
Aviary works with a [`0x0`]-compatible server as a backend. To set up a quick
server for development, follow these steps:
**Prerequisites:**
- Python3 with `pip`
2022-11-13 02:52:53 +00:00
- `git`
- A C++ compiler (e.g. `gcc`) & libc/python development headers
2022-11-13 02:52:53 +00:00
```bash
# Download 0x0
git clone https://git.0x0.st/mia/0x0
cd 0x0
# Set up the environment and install deps
python3 -m venv venv --prompt 0x0
source venv/bin/activate || source venv/bin/activate.fish
pip install wheel
2022-11-13 02:52:53 +00:00
pip install -r requirements.txt
pip install gunicorn
# Perform some configuration
mkdir instance
echo "
# Use a local sqlite3 database to store information
SQLALCHEMY_DATABASE_URI = 'sqlite:///database.db'
# Encrypted files really throw off mime guessers, which can cause some
# encrypted images to get rejected for having ELF headers (e.g. looking like
# executables). We don't want this, so we disable MIME filtering
FHOST_MIME_BLACKLIST = []
FHOST_EXT_OVERRIDE = dict()
# Images are rarely larger than 16 MB
MAX_CONTENT_LENGTH = 16 * 1024 * 1024
" > instance/config.py
# Setup the database
FLASK_APP=fhost flask db upgrade
mv database.db instance/
# Use the aviary index.html page as the 404 page
# CHANGE THE /path/to/aviary/index.html TO POINT TO index.html IN THIS REPO
2022-11-13 03:06:22 +00:00
ln -fs /path/to/aviary/dist/www/index.html templates/404.html
2022-11-13 02:52:53 +00:00
# Run the server
gunicorn fhost:app
```
You'll also need to serve the `aviary.min.js` file generated during the
2022-11-17 17:19:34 +00:00
**building** step at `/aviary.min.js`, and the `aviary.css` file in
`:dist/www/` at `/aviary.css`. This can be done using an external webserver.
A sample `Caddyfile` exists in `:dist/`. To use this, run the following
command from the `dist/` directory after filling in the `/path/to/0x0` with the
directory your instance of `0x0` is running in.
2022-11-13 02:52:53 +00:00
```bash
2022-11-13 03:06:22 +00:00
caddy run
2022-11-13 02:52:53 +00:00
```
[`aviary-cli`]: https://fem.mint.lgbt/Emi/aviary-cli
[purescript.org]: https://www.purescript.org/
[`lebab`]: https://github.com/lebab/lebab
[`uglify-js`]: https://www.npmjs.com/package/uglify-js