# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['pelican', 'pelican.plugins.compressor']

package_data = \
{'': ['*']}

install_requires = \
['pelican>=4.5,<5.0', 'web-compressor>=0.4.2,<0.5.0']

extras_require = \
{'images': ['Pillow>=9.2,<10.0', 'pillow-avif-plugin>=1.2,<2.0'],
 'minify': ['tdewolff-minify>=2,<3']}

setup_kwargs = {
    'name': 'pelican-compressor',
    'version': '0.2.1',
    'description': "Pelican plugin wrapper for 'web-compressor'",
    'long_description': '# Pelican plugin for [`web-compressor`](https://codeberg.org/digitalbuero/web-compressor)\n\n`pelican-compress` optimizes any Pelican site\'s `output` - using sane defaults & insane tools.\n\n\n## Installation\n\nIt\'s available from [PyPi](https://pypi.org/project/pelican-compressor) using a package manager of your choice:\n\n```text\n# Using \'pip\'\npip install pelican-compressor\n\n# Using \'poetry\'\npoetry add pelican-compressor\n```\n\n\n## Getting started\n\nUsing `pelican-compressor` is straightforward:\n\n\n### Plugin\n\nAfter installing it, the following features are enabled by default:\n- minification of HTML files & web assets, such as CSS/JS, JSON & XML files\n- cachebusting assets, such as CSS/JS, JSON & XML files, fonts and images\n- creating SRI hashes for `link` & `script` tags\n\nSee \'Configuration\' below for full control over these processes and even more features, such as\n- optimizing all JPEG & PNG images\n- converting them to modern file formats such as AVIF/WebP\n- building CSP directives (including nonces for inline scripts & styles)\n\n\n### Commandline\n\nInstalling `pelican-compressor` also gives you access to [`webcompr`](https://codeberg.org/digitalbuero/web-compressor), which might be interesting for more flexibility.\n\n\n## Configuration\n\nThe following settings need to be prepended by `COMPRESSOR_` to work, eg for enabling AVIF/WebP generation, define `COMPRESSOR_ENABLE_MODERN_FORMATS = True` [in your settings](https://docs.getpelican.com/en/latest/settings.html#settings) (most likely `pelicanconf.py`).\n\n\n### General\n\n| Setting      | Type   | Default | Description              |\n| ------------ | ------ | ------- | ------------------------ |\n| `BLOCK_LIST` | `list` | `[]`    | Filenames to be excluded |\n\n\n### Asset minification\n\n| Setting             | Type                   | Default            | Description              |\n| ------------------- | ---------------------- | ------------------ | ------------------------ |\n| `ENABLE_MINIFY`     | `bool`                 | `true`             | Enables/disables feature |\n| `MINIFY_MEDIATYPES` | `list` or `re.Pattern` | HTML, CSS, JS, SVG | Files to be minified     |\n| `MINIFY_OPTIONS`    | `dict`                 | see below          | Minification settings    |\n\nFor available minification settings, see [here](https://github.com/tdewolff/minify/tree/master/bindings/py#usage).\n\n\n### Image optimizations\n\n| Setting                 | Type                   | Default | Description                |\n| ----------------------- | ---------------------- | ------- | -------------------------- |\n| `ENABLE_IMAGEOPTIM`     | `bool`                 | `false` | Enables/disables feature   |\n| `IMAGEOPTIM_MEDIATYPES` | `list` or `re.Pattern` | JPG/PNG | Files to be optimized      |\n| `JPEG_QUALITY`          | `int`                  | `85`    | JPEG output quality        |\n| `STRIP_METADATA`        | `bool`                 | `true`  | Whether to remove metadata |\n\n\n### Asset hashing / "cachebusting"\n\n| Setting            | Type                   | Default                      | Description                         |\n| ------------------ | ---------------------- | ---------------------------- | ----------------------------------- |\n`ENABLE_HASHING`     | `bool`                 | `true`                       | Enables/disables feature            |\n`HASHING_MEDIATYPES` | `list` or `re.Pattern` | CSS/JS files, fonts & images | Files to be hashed                  |\n`HASH_LENGTH`        | `int`                  | `10`                         | Length of appended hash string      |\n`HASH_MODIFIED`      | `bool`                 | `false`                      | Hash modified time or file contents |\n\n\n### AVIF / WebP generation\n\n| Setting               | Type   | Default           | Description               |\n| --------------------- | ------ | ----------------- | ------------------------- |\n`ENABLE_MODERN_FORMATS` | `bool` | `false`           | Enables/disables feature  |\n`AVIF_SETTINGS`         | `dict` | `{"quality": 90}` | AVIF settings (see below) |\n`WEBP_SETTINGS`         | `dict` | `{"method": 6}`   | WebP settings (see below) |\n\nAvailable WebP settings:\n- `lossless`\n- `quality`\n- `method`\n- `icc_profile`\n- `exif`\n\nFor more information, see [`Pillow` docs](https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html?highlight=webp#webp).\n\nAvailable AVIF settings:\n- `advanced`\n- `alpha_premultiplied`\n- `append_images`\n- `codec`\n- `duration`\n- `exif`\n- `icc_profile`\n- `qmax`\n- `qmin`\n- `quality`\n- `range`\n- `speed`\n- `subsampling`\n- `tile_rows`\n- `xmp` / `XML:com.adobe.xmp`\n\n**Note**: AVIF generation is provided through a plugin, which [hasn\'t made it into `Pillow`\'s core yet](https://github.com/python-pillow/Pillow/pull/5201), so consider this feature as being experimental!\n\nFor more information (eg default values), check out the `info.get()` calls inside the `_save()` method, courtesy of the [`pillow_avif` plugin](https://github.com/fdintino/pillow-avif-plugin/blob/master/src/pillow_avif/AvifImagePlugin.py#L114).\n\n\n### Subresource integrity\n\n| Setting    | Type  | Default    | Description                 |\n| ---------- | ----- | ---------- | --------------------------- |\n`ENABLE_SRI` | `str` | `true`     | Enables/disables feature    |\n`SRI_DIGEST` | `str` | `\'sha512\'` | Cryptographic digest to use |\n\n\n### Content security policy\n\n| Setting        | Type   | Default            | Description                 |\n| -------------- | ------ | ------------------ | --------------------------- |\n`ENABLE_CSP`     | `bool` | `false`            | Enables/disables feature    |\n`CSP_DIGEST`     | `str`  | `\'sha512\'`         | Cryptographic digest to use |\n`CSP_NONCE`      | `str`  | `uuid.uuid4().hex` | Random nonce to be used     |\n`CSP_DIRECTIVES` | `dict` | `{}`               | CSP directives (see below)  |\n\nWhen creating a [content security policy](https://www.w3.org/TR/CSP3), you might want to start with something restrictive and go from there:\n\n```python\nCOMPRESSOR_ENABLE_CSP = True\nCOMPRESSOR_CSP_DIRECTIVES = {\n    "default-src": "none",\n    "script-src": "\'strict-dynamic\'",\n    "object-src": "none",\n    "base-uri": "none",\n},\n```\n\n\n### Hooks\n\nIt\'s also prossible to assign functions to be called right before this plugin (`PRE_HOOK`) or immediately thereafter (`POST_HOOK`), eg for creating image variants (such as placeholders for lazyloading). Each function receives the argument `asset`, which is a tuple consisting of the `pathlib.Path` to each asset file and a `str` representing its MIME type:\n\n```python\n# pelicanconf.py\n\nCOMPRESSOR_PRE_HOOK = lambda asset: (\n    # Unpack asset file & mediatype\n    file_path, mime_type = asset\n\n    # If image file ..\n    if mime_type == "image/jpeg":\n        # .. do something\n)\n```\n\n\n## Roadmap\n\n- [x] Update `README.md`\n- [ ] Add tests\n',
    'author': 'Digitalbüro',
    'author_email': 'post@digitalbuero.eu',
    'maintainer': 'Martin Folkers',
    'maintainer_email': 'hello@twobrain.io',
    'url': 'https://digitalbuero.eu',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'extras_require': extras_require,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
