Added README and setup help
This commit is contained in:
parent
aae4a2138e
commit
54cf627a01
113
README.md
Normal file
113
README.md
Normal file
|
@ -0,0 +1,113 @@
|
|||
# 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 --mangle-props -- index.js > index.js
|
||||
```
|
||||
|
||||
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:**
|
||||
- Python, `pip`, and `venv`
|
||||
- `git`
|
||||
|
||||
```bash
|
||||
# Download 0x0
|
||||
git clone https://git.0x0.st/mia/0x0
|
||||
cd 0x0
|
||||
|
||||
# Set up the environment and install deps
|
||||
python -m venv venv --prompt 0x0
|
||||
source venv/bin/activate.sh || source venv/bin/activate.fish
|
||||
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'
|
||||
|
||||
# Have the webserver deal with sending files rather than 0x0
|
||||
USE_X_SENDFILE = True
|
||||
FHOST_USE_X_ACCEL_REDIRECT = False
|
||||
|
||||
# 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
|
||||
ln -fs /path/to/aviary/www/index.html templates/404.html
|
||||
|
||||
# Run the server
|
||||
gunicorn fhost:app
|
||||
```
|
||||
|
||||
You'll also need to serve the `index.js` file generated during the **building**
|
||||
step at `/index.js`. This can be done using an external webserver. A sample
|
||||
`Caddyfile` exists in `:dist/`. To use this, run the following command from
|
||||
root of `aviary`'s repository:
|
||||
|
||||
```bash
|
||||
caddy run -config dist/Caddyfile
|
||||
```
|
||||
|
||||
[`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
|
5
dist/Caddyfile
vendored
Normal file
5
dist/Caddyfile
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
http://localhost:6660 {
|
||||
root www/
|
||||
file_server /index.js
|
||||
reverse_proxy localhost:8000
|
||||
}
|
1
www/index.js
Symbolic link
1
www/index.js
Symbolic link
|
@ -0,0 +1 @@
|
|||
../index.js
|
Loading…
Reference in a new issue