A PureScript web frontend for the Aviary protocol
Go to file
Emi Simpson 96808a5648
Split CSS out into its own file
2022-11-17 12:19:34 -05:00
dist Split CSS out into its own file 2022-11-17 12:19:34 -05:00
src Improve the rendering of errors on thumbnails & rendered images 2022-11-17 12:05:25 -05:00
test Began work on a PureScript Aviary implementation 2022-10-09 20:03:03 -04:00
.editorconfig Add editor config 2022-11-05 15:51:57 -04:00
.gitignore Began work on a PureScript Aviary implementation 2022-10-09 20:03:03 -04:00
README.md Split CSS out into its own file 2022-11-17 12:19:34 -05:00
format.proto Predict the correct size of full images 2022-11-09 17:44:35 -05:00
packages.dhall Made a whole bunch of changes 2022-10-24 15:10:30 -04:00
spago.dhall Partially sequentialize code for loading adjacent images on focus 2022-11-16 17:12:53 -05:00

README.md

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:

# 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

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
  • git
  • A C++ compiler (e.g. gcc) & libc/python development headers
# 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
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
ln -fs /path/to/aviary/dist/www/index.html templates/404.html

# Run the server
gunicorn fhost:app

You'll also need to serve the aviary.min.js file generated during the 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.

caddy run