From 8c5e4591a60d369fe51f57d60da89fedfeffb66c Mon Sep 17 00:00:00 2001 From: Emi Simpson Date: Sun, 13 Nov 2022 00:23:46 -0500 Subject: [PATCH] Learn from experience & rename output JS --- README.md | 22 ++++++++++------------ dist/Caddyfile | 17 ++++++++++++++--- dist/www/index.html | 2 +- dist/www/index.js | 1 - 4 files changed, 25 insertions(+), 17 deletions(-) delete mode 120000 dist/www/index.js diff --git a/README.md b/README.md index 0e6807e..163540c 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ lebab --replace output/ --transform arrow,arrow-return spago bundle-app --minify # Perform some final optimizations -uglifyjs --compress --mangle --toplevel --mangle-props -- index.js > index.js +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! @@ -52,8 +52,9 @@ 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` +- Python3 with `pip` - `git` +- A C++ compiler (e.g. `gcc`) & libc/python development headers ```bash # Download 0x0 @@ -61,8 +62,9 @@ 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 +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 @@ -72,10 +74,6 @@ 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 @@ -98,10 +96,10 @@ ln -fs /path/to/aviary/dist/www/index.html templates/404.html 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 -the `dist/` directory. +You'll also need to serve the `aviary.min.js` file generated during the +**building** step at `/aviary.min.js`. 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. ```bash caddy run diff --git a/dist/Caddyfile b/dist/Caddyfile index c6800a8..b19232c 100644 --- a/dist/Caddyfile +++ b/dist/Caddyfile @@ -1,5 +1,16 @@ http://localhost:6660 { - root www/ - file_server /index.js - reverse_proxy localhost:8000 + route { + file_server /aviary.min.js { + pass_thru + root www/ + } + reverse_proxy localhost:8000 { + @accel header X-Accel-Redirect * + handle_response @accel { + root * /path/to/0x0/ + rewrite * {rp.header.X-Accel-Redirect} + file_server + } + } + } } diff --git a/dist/www/index.html b/dist/www/index.html index b912994..05f773e 100644 --- a/dist/www/index.html +++ b/dist/www/index.html @@ -203,7 +203,7 @@ p { border-radius: 50%; } - + diff --git a/dist/www/index.js b/dist/www/index.js deleted file mode 120000 index e234193..0000000 --- a/dist/www/index.js +++ /dev/null @@ -1 +0,0 @@ -../index.js \ No newline at end of file