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

package_dir = \
{'': 'src'}

packages = \
['django_wools',
 'django_wools.management.commands',
 'django_wools.templatetags']

package_data = \
{'': ['*'], 'django_wools': ['templates/wools/*', 'templates/wools/images/*']}

install_requires = \
['django>1.7.0',
 'fonttools[woff]>=4.21.1,<5.0.0',
 'httpx>=0.17.0,<0.18.0',
 'minify-html>=0.4.3,<0.5.0',
 'psutil>2.0.0',
 'tqdm>3.0.0',
 'zopflipy>1.1']

setup_kwargs = {
    'name': 'django-wools',
    'version': '0.2.0a6',
    'description': 'Django tools from WITH',
    'long_description': 'Django Wools\n============\n\nDjango tools from WITH.\n\nThat\'s a collection of things that we at [WITH](https://with-madrid.com/) got\ntired of copy/pasting in every project.\n\n## Install\n\n```\npip install django_wools\n```\n\n## Included Wools\n\n### Storage\n\n#### `django_wools.storage.GzipManifestStaticFilesStorage`\n\nThat\'s a sub-class of the \n[ManifestStaticFilesStorage](https://docs.djangoproject.com/en/3.0/ref/contrib/staticfiles/#manifeststaticfilesstorage)\nbut that makes sure that along with all the files comes a `.gz` version which\nis easy to pick up for nginx (or other static files server).\n\n### Middlewares\n\n#### `django_wools.middlewares.NowMiddleware`\n\nSuppose that you have a content that is available up until a given date. When\nthe date is passed then everything related to this content expires. However,\nin order to do this, you\'re probably going to make several request, possibly in\nloosely connected parts of your code. In those cases, when looking at the time,\nthe clock will show different value as the time passes between calls. It means\nthat you could very well end up with one half of your code considering that the\nobject is still valid but the other half that it expired.\n\nIn order to prevent this, the simplest is to consider that the time is fixed\nand that the code executes instantly at the moment of the request. The goal\nof this middleware is to save the current time at each request and then to\nprovide an easy way to get the current time through the request.\n\nIf the middleware is activated, you should be able to get the time like this:\n\n```python\nfrom time import sleep\nfrom django.shortcuts import render\n\ndef my_view(request):\n    print(f"Now is {request.now()}")\n    sleep(42)\n    print(f"Now is still {request.now()}")\n\n    return render(request, "something.html", {"now": request.now()})\n```\n\n#### `django_wools.middlewares.SlowMiddleware`\n\nWhen developing a SPA or hybrid app, you want to make sure that the app is\nstructurally ready to handle load times from the server, even if the connection\nis a bit shaky. Also, you want to make sure that not too many requests are\nsent.\n\nIn order for you to fully realize how slow your website is going to be on a bad\nconnection, th e SlowMiddleware will automatically add a delay before replying\nto each request.\n\nAdd this to your `settings.py`\n\n```python\nMIDDLEWARE = [\n    # ...\n    "django_wools.middlewares.SlowMiddleware",\n]\n\nSLOW_MIDDLEWARE_LATENCY = 1 if DEBUG else 0\n```\n\nBy doing this, your requests will be added a 1s delay if the `DEBUG` mode is\nenabled.\n\n### Database\n\n#### `django_wools.db.require_lock`\n\nProvides a way to explicitly generate a PostgreSQL lock on a table.\n\nBy example:\n\n```python\nfrom django.db.transaction import atomic\nfrom django_wools.db import require_lock\n\nfrom my_app.models import MyModel\n\n\n@atomic\n@require_lock(MyModel, \'ACCESS EXCLUSIVE\')\ndef myview(request):\n    # do stuff here\n```\n\n### Wagtail Images\n\nSeveral Wagtail-specific tags are provided to deal with images and more\nspecifically responsive images. To use it:\n\n1. Add `django_wools` to `INSTALLED_APPS`\n2. Import `wools_for_wt_images` from your template\n\n```\n{% load wools_for_wt_images %}\n```\n\nSome specific settings can be set:\n\n- `WOOLS_MAX_PIXEL_RATIO` _(default: `3`)_ &mdash; Highest device pixel ratio\n  to support.\n- `WOOLS_INCREMENT_STEP_PERCENT` _(default: `(sqrt(2) - 1) * 100`)_ &mdash; The\n  percentage of increase from the base density to the next one. The default\n  values will generate `x1`, `x2` and `x4` with intermediate values that are\n  `x1.4142` and `x2.8284`.\n\nAll the tags will be default generate WebP images with a PNG fallback. The\nfallback can be changed to JPEG and the main format has to be WebP.\n\n#### `image_fixed_size`\n\nThis tag will generate a `<picture>` tag for an image whose size in pixels you\nknown in advance. That picture size will be enforced in the HTML code with\ninline properties.\n\nUsage:\n\n```\n{% image_fixed_size max-500x500 %}\n```\n\nThe arguments to this tag, in order, are:\n\n- `image` &mdash; The Wagtail-compatible image itself\n- `spec` &mdash; A spec like you would give to Wagtail (`fill-500x500`,\n   `max-500x500`, etc)\n- `css_class` &mdash; CSS class that will be added to the root <picture> element.\n- `fallback_format` &mdash; The format to fallback in case the browser doesn\'t\n  support WebP. Can either be `"jpeg"` or `"png"`. Defaults to `"png"`.\n- `lossless` &mdash; A boolean to enable losslessness of WebP. This does not\n  affect the fallback format, so if you want a lossless fallback as well you\'ll\n  need to use PNG.\n\n### Fonts\n\nWools offers a way to easily download and manage fonts from Google fonts or\nother pluggable providers. The current version only works with Google fonts,\nhowever you are free to create your own sources and converters that will be\nable to work out what you need.\n\n#### Getting started\n\nThe first thing would be to put the font families that you want into the\n`settings.py` of your project. By example:\n\n```python\nWOOLS_FONTS_FAMILIES = [\n    (\'google\', \'Roboto\'),\n    (\'google\', \'Nunito\'),\n]\n```\n\nHere we\'re getting Roboto and Nunito from Google Fonts.\n\n> *Note* &mdash; Please make sure that `django_wools` is in your\n> `INSTALLED_APPS` for this to work.\n\nNow let\'s run the download command:\n\n```\n./manage.py wools_import_fonts\n```\n\nAnd finally, let\'s put this tag in your page\'s HTML:\n\n```html\n{% load wools_fonts %}\n\n<!DOCTYPE html>\n<html class="no-js" lang="{{ CURRENT_LANG }}">\n<head>\n    <meta charset="utf-8" />\n    <meta name="viewport" content="width=device-width, initial-scale=1" />\n\n    <title>{{ title }}</title>\n\n    {% fonts_head %}\n</head>\n</html>\n```\n\nAnd that\'s it! The fonts you asked for will be loaded automatically.\n\n#### Configuration options\n\nThere is several settings that you can adjust.\n\n##### `WOOLS_FONTS_DIR`\n\nDirectory name relative to the static root where the files will be stored.\n\n> *Default*: `"fonts"`\n\n##### `WOOLS_STATIC_ROOT`\n\nAbsolute path to the static root that you want to use to store the fonts. If\nset to none, the first value from `STATICFILES_DIRS` will be used instead.\n\n> *Default*: `None`\n\n##### `WOOLS_FAMILIES`\n\nFont families that you want to load. It\'s a list of (provider, family) tuples.\n\nInstead of providing tuples, you can provide \n`django_wools.settings_types.FontFamily` instances directly. In case you don\'t\nprovide them, the tuple will be passed as *args to the constructor of\n`FontFamily`.\n\n> *Default*: `[]`\n\n##### `WOOLS_FONTS_PROVIDERS`\n\nDictionary of available font providers. The key is the name of the provider\nwhile the value is the FQN of the class.\n\nIf you want to provide your own provider, you can specifcy any class as long as\nit implements the `django_wools.fonts.WoolFontProvider` interface.\n\n> *Default*: `{"google": "django_wools.fonts.GoogleFontsProvider"}`\n\n##### `WOOLS_FONTS_FORMATS`\n\nList of font formats that you want. Choices are `ttf`, `woff`, `woff2`, `eot`,\n`svg`, `otf`. You can also directly provide instances of\n`django_wools.settings_types.FontFormat`.\n\nFont formats will be proposed in the same order to the browser.\n\n> *Default*: `[FontFormat.woff2, FontFormat.ttf]`\n\n##### `WOOLS_FONTS_CONVERSIONS`\n\nFont sources will provide the fonts in a given format (most likely TTF) but in\norder to produce the formats expected by `WOOLS_FONTS_FORMATS` you need to\nconvert those fonts.\n\nThis is a dictionary that as key takes a tuple of (from_format, to_format) and\nas value a sequential list of converters to use.\n\nBy example, suppose that you only have "TTF to WOFF2" and "EOT to TTF" avaible\nand your source is in EOT while formats are TTF and WOFF2. In that case you can\nspecificy that the conversion from "EOT to WOFF2" goes through TTF.\n\n> *Default*:\n\n```python\n{\n    (FontFormat.ttf, FontFormat.woff): ["django_wools.fonts.TtfToWoff"],\n    (FontFormat.ttf, FontFormat.woff2): ["django_wools.fonts.TtfToWoff2"],\n}\n```\n',
    'author': 'Rémy Sanchez',
    'author_email': 'remy.sanchez@with-madrid.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/WithIO/django-wools',
    'package_dir': package_dir,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.6,<4.0',
}


setup(**setup_kwargs)
