Skip to main content

Generate autoindex-style HTML for your directory listings.

Project description

manualindex

CI PyPI

Generate autoindex-style HTML for your directory listings.

Install

pip install manualindex

Or if you're using poetry:

poetry add manualindex

Manualindex supports Python 3.9 and above.

Usage

Manualindex can be used both as a library and as a command-line program.

CLI

python -m manualindex /path/to/dir

A Jinja template is used to generate the index.html files. To customise the template, you'll need to pass two flags:

python -m manualindex /path/to/dir --template-path /path/to/templates --template-name mytemplate.html.j2

For this example to work, there must be a file named mytemplate.html.j2 inside /path/to/templates.

Due to how the URL generation works, if your directory listings are not at the root of your domain, you'll need to pass the base URL path. For example, if your base URL is https://example.com/mydir/mysubdir/, you will need the following:

python -m manualindex /path/to/dir --base-urlpath /mydir/mysubdir/

You can customise the date format:

python -m manualindex /path/to/dir --date-format '%Y-%m-%d'

The default date format is %Y-%m-%d %H:%I.

To customise the timezone of the formatted timestamps:

python -m manualindex /path/to/dir --timezone Australia/Melbourne

The default timezone is UTC.

Library

To make use of all the defaults:

from pathlib import Path
from manualindex import generate_default

generate_default(Path("/path/to/dir"))

To customise the template generation options, but use the default template:

from pathlib import Path
from manualindex import default_template, generate

generate(
    Path("/path/to/dir"),
    default_template,
    base_urlpath="/mydir/mysubdir/",
    date_format = "%Y-%m-%d",
    date_tz="Australia/Melbourne",
)

The second parameter to generate() accepts any Jinja Template object, so you have full control over the output. Manualindex makes no assumptions about where the template comes from.

License

The code is available under the GPL Version 3.

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

manualindex-1.0.1.tar.gz (19.5 kB view hashes)

Uploaded Source

Built Distribution

manualindex-1.0.1-py3-none-any.whl (19.3 kB view hashes)

Uploaded Python 3

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