Skip to main content

Generates indexes for cloud buckets from NGINX Fancyindex themes

Project description

Cloud FancyIndex

I like NGINX fancyindex module (https://www.nginx.com/resources/wiki/modules/fancy_index/). With a good theme it can make your auto-indexed file trash look like solid SP500 company's Website with a few directives in web server config.

But future is coming and we are moving to cloud storages.

  • Pros: you'll have built-in scalability, speed, and multi-zones for your files.
  • Cons: these cloud buckets have no indexes (or they don't look so cool as old good NGINX fancyindex themes).

Of course you can make an application which gets bucket contents and displays to to user in a nice way. But for what, if the files are static? Let's build static indexes! And let's add fancyindex themes for them!

Uploading

  • To upload files to Google Cloud Storage, you need to be logged in with local gcloud app. cs-index-upload.sh actually calls gsutil rsync

  • To upload to Amazon S3 or compatible, install and configure s3cmd

Installation

pip3 install cloud-fancyindex

You also need to install cloudindex package as well.

Usage

  • cloud-fancyindex-generator CLI tool - generates index.html files (by default in ./_build/html )

  • You must also download some fancy index theme, e.g. https://github.com/TheInsomniac/Nginx-Fancyindex-Theme. Actually it's compatible with almost all themes you can find or create.

Note: theme is placed in /fancyindex bucket directory. In case theme loads any stuff (css/js etc.) from other directory, correct paths in its header / footer.

Note: you need to rebuild index (at least partial one) every time you upload new file to bucket. Sad, but true.

Example:

cloud-index [options] <bucket> | cloud-fancyindex-generator -t <template> -F <themepath> -D <output>

Usage in real life

E.g. you have a cool build script which makes your project tarball and uploads it to /releases/${VERSION}/blahblahblah path into cloud bucket. To re-index the path, put the following string in your script after upload command:

cd /path/to/cloud-fancyindex && make prefix=/releases/${VERSION} pub

Nuts and bolts

  • Unfortunately it's impossible to implement sorting, as it called a server request with a query string only NGINX can understand. Maybe I'll do sorting with JS, some day.

  • But a bonus - now you can easily display sizes of folders (or directories (or bucket paths (etc)))

  • S3 actually has real "folders" (at least emulates them), so index generation can be more optimal. But then we'll lose unification.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloud-fancyindex-0.0.1.tar.gz (3.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page