django-airplane


Namedjango-airplane JSON
Version 1.1.1 PyPI version JSON
download
home_pagehttps://github.com/cltrudeau/django-airplane
SummaryDjango app that caches CDN files for use when coding offline
upload_time2023-06-29 20:54:41
maintainer
docs_urlNone
authorChristopher Trudeau
requires_python
licenseMIT
keywords django cache offline cdn static
VCS
bugtrack_url
requirements context-temp coverage Django django-awl pudb pyflakes requests Sphinx sphinx-rtd-theme tox twine waelstow
Travis-CI No Travis.
coveralls test coverage No coveralls.
            django-airplane
***************

This app is to help in those situations where you can't get on the network but
you want to write some Django code.  Surround your static CDN references (like
jquery and the like) with this template tag and when you turn it on the URLs
will be re-written from a local copy.

Installation
============

In your settings file, add 'airplane' to your ``settings.INSTALLED_APPS`` field:

.. code-block:: python

    INSTALLED_APPS = (
        ...
        'airplane',
    )

Also in settings, make the following additions:

.. code-block:: python

    import airplane

    STATICFILES_DIRS = (
        airplane.cache_path(),
    )

    AIRPLANE_MODE = airplane.BUILD_CACHE
    #AIRPLANE_MODE = airplane.USE_CACHE
    #AIRPLANE_MODE = airplane.AUTO_CACHE

Now use the ``airplane`` tag in your templates

.. code-block:: html

    {% load airplanetags %}

    <html>
        <head>
            <link rel="stylesheet"
                href="{% airplane 'https://maxcdn.bootstrapcdn.com/bootstrap.min.css' %}">
        </head>
    </html>

Change the ``AIRPLANE_MODE`` setting to ``airplane.USE_CACHE`` and subsequent
calls to the ``{% airplane %}`` tag will return a reference to the locally 
cached version.


Settings
========

Airplane only does something if ``DEBUG=True`` and if you have an
``AIRPLANE_MODE`` value set to ``airplane.BUILD_CACHE``,
``airplane.USE_CACHE``, or ``airplane.AUTO_CACHE``.  If one of these
conditions is not met, the tag simply returns the value passed in.

For example, if ``DEBUG=False`` and your template contains:

.. code-block:: html

    <link rel="stylesheet"
        href="{% airplane 'https://maxcdn.bootstrapcdn.com/bootstrap.min.css' %}">


Then the above snippet renders as:

.. code-block:: html

    <link rel="stylesheet"
        href="https://maxcdn.bootstrapcdn.com/bootstrap.min.css">


When ``AIRPLANE_MODE`` is set to ``airplane.BUILD_CACHE`` any URLs passed in
are fetched and their contents added to a local cache.  The default local
cache is ``.airport_cache`` relative to the base directory of your project.

You can change the location of the cache by setting ``AIRPLANE_CACHE``.  The
setting accepts either fully qualified paths or paths relative to the
project's base directory.

.. code-block:: python

    # settings.py

    AIRPLANE_CACHE = /foo/bar/cache     # fully qualified

    # or

    AIRPLANE_CACHE = my_cache           # relative to settings.BASE_DIR

    # or nothing, defaults to settings.BASEDIR + '.airplane_cache'


Once you have cached all the files you are using, switch ``AIRPLANE_MODE`` to
``airplane.USE_CACHE``.  All URLs are now re-written to point to the contents
of the local cache.

Alternatively, you can set ``AIRPLANE_MODE`` to ``airplane.AUTO_CACHE`` and
the first call will cache the file and subsequent calls will use the cached
copy.

Commands
========

The following django commands come with airplane.

airinfo
-------

.. code-block:: sh

    $ ./manage.py airinfo
    Cache mode: AUTO_CACHE
    Cache directory: /Users/foo/sample_site/.airplane_cache
    Cache contents:
       https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css


This command takes no arguments and displays information about the cache. The
current mode, the path of the directory and any items cached inside are shown.


aircache
--------

.. code-block:: sh

    ./manage.py aircache https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css

This command takes a single URL as an argument and caches the contents of the
URL.

Schemaless URLs
===============

As airplane is a template tag library, it doesn't have access to the request
object at execution. In order to allow schemaless URLs, the code makes the
assumption that the schema is "https" if it is not given in the URL.

Limitations
===========

The intent of this library is to help you when you're using the Django
debugging server and in a situation where you can't easily get to the network.
Cached files are served using the django static server code, which means you
are limited by what kinds of files it can serve. The static server makes
guesses on the mimetype of the file based on file extensions. Airplane naively
copies the extension of the file so the cached file has the same ending. This
means URLs with weird extensions or those which static serve cannot guess at
mimetype, will cause problems. It is not recommended to use django-airplane
with files that don't end in typical extensions such as ".css", ".js", ".jpg",
".png" or ".gif".


Supports
========

django-airplane has been tested with:

* Python 3.8-3.11 and Django 4.1
* Python 3.8-3.11 and Django 4.2

Older versions tested against Django 2.2 and 3.2, nothing has changed since
then that should break, but these are no longer test targets

Docs
====

Docs available at: http://django-airplane.readthedocs.io/en/latest/

Source: https://github.com/cltrudeau/django-airplane

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cltrudeau/django-airplane",
    "name": "django-airplane",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django,cache,offline,CDN,static",
    "author": "Christopher Trudeau",
    "author_email": "ctrudeau+pypi@arsensa.com",
    "download_url": "https://files.pythonhosted.org/packages/3b/81/8de68b6729b8388acf30d2d24abb12ca91f09611c1c0a9d70ea742557070/django-airplane-1.1.1.tar.gz",
    "platform": null,
    "description": "django-airplane\n***************\n\nThis app is to help in those situations where you can't get on the network but\nyou want to write some Django code.  Surround your static CDN references (like\njquery and the like) with this template tag and when you turn it on the URLs\nwill be re-written from a local copy.\n\nInstallation\n============\n\nIn your settings file, add 'airplane' to your ``settings.INSTALLED_APPS`` field:\n\n.. code-block:: python\n\n    INSTALLED_APPS = (\n        ...\n        'airplane',\n    )\n\nAlso in settings, make the following additions:\n\n.. code-block:: python\n\n    import airplane\n\n    STATICFILES_DIRS = (\n        airplane.cache_path(),\n    )\n\n    AIRPLANE_MODE = airplane.BUILD_CACHE\n    #AIRPLANE_MODE = airplane.USE_CACHE\n    #AIRPLANE_MODE = airplane.AUTO_CACHE\n\nNow use the ``airplane`` tag in your templates\n\n.. code-block:: html\n\n    {% load airplanetags %}\n\n    <html>\n        <head>\n            <link rel=\"stylesheet\"\n                href=\"{% airplane 'https://maxcdn.bootstrapcdn.com/bootstrap.min.css' %}\">\n        </head>\n    </html>\n\nChange the ``AIRPLANE_MODE`` setting to ``airplane.USE_CACHE`` and subsequent\ncalls to the ``{% airplane %}`` tag will return a reference to the locally \ncached version.\n\n\nSettings\n========\n\nAirplane only does something if ``DEBUG=True`` and if you have an\n``AIRPLANE_MODE`` value set to ``airplane.BUILD_CACHE``,\n``airplane.USE_CACHE``, or ``airplane.AUTO_CACHE``.  If one of these\nconditions is not met, the tag simply returns the value passed in.\n\nFor example, if ``DEBUG=False`` and your template contains:\n\n.. code-block:: html\n\n    <link rel=\"stylesheet\"\n        href=\"{% airplane 'https://maxcdn.bootstrapcdn.com/bootstrap.min.css' %}\">\n\n\nThen the above snippet renders as:\n\n.. code-block:: html\n\n    <link rel=\"stylesheet\"\n        href=\"https://maxcdn.bootstrapcdn.com/bootstrap.min.css\">\n\n\nWhen ``AIRPLANE_MODE`` is set to ``airplane.BUILD_CACHE`` any URLs passed in\nare fetched and their contents added to a local cache.  The default local\ncache is ``.airport_cache`` relative to the base directory of your project.\n\nYou can change the location of the cache by setting ``AIRPLANE_CACHE``.  The\nsetting accepts either fully qualified paths or paths relative to the\nproject's base directory.\n\n.. code-block:: python\n\n    # settings.py\n\n    AIRPLANE_CACHE = /foo/bar/cache     # fully qualified\n\n    # or\n\n    AIRPLANE_CACHE = my_cache           # relative to settings.BASE_DIR\n\n    # or nothing, defaults to settings.BASEDIR + '.airplane_cache'\n\n\nOnce you have cached all the files you are using, switch ``AIRPLANE_MODE`` to\n``airplane.USE_CACHE``.  All URLs are now re-written to point to the contents\nof the local cache.\n\nAlternatively, you can set ``AIRPLANE_MODE`` to ``airplane.AUTO_CACHE`` and\nthe first call will cache the file and subsequent calls will use the cached\ncopy.\n\nCommands\n========\n\nThe following django commands come with airplane.\n\nairinfo\n-------\n\n.. code-block:: sh\n\n    $ ./manage.py airinfo\n    Cache mode: AUTO_CACHE\n    Cache directory: /Users/foo/sample_site/.airplane_cache\n    Cache contents:\n       https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css\n\n\nThis command takes no arguments and displays information about the cache. The\ncurrent mode, the path of the directory and any items cached inside are shown.\n\n\naircache\n--------\n\n.. code-block:: sh\n\n    ./manage.py aircache https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css\n\nThis command takes a single URL as an argument and caches the contents of the\nURL.\n\nSchemaless URLs\n===============\n\nAs airplane is a template tag library, it doesn't have access to the request\nobject at execution. In order to allow schemaless URLs, the code makes the\nassumption that the schema is \"https\" if it is not given in the URL.\n\nLimitations\n===========\n\nThe intent of this library is to help you when you're using the Django\ndebugging server and in a situation where you can't easily get to the network.\nCached files are served using the django static server code, which means you\nare limited by what kinds of files it can serve. The static server makes\nguesses on the mimetype of the file based on file extensions. Airplane naively\ncopies the extension of the file so the cached file has the same ending. This\nmeans URLs with weird extensions or those which static serve cannot guess at\nmimetype, will cause problems. It is not recommended to use django-airplane\nwith files that don't end in typical extensions such as \".css\", \".js\", \".jpg\",\n\".png\" or \".gif\".\n\n\nSupports\n========\n\ndjango-airplane has been tested with:\n\n* Python 3.8-3.11 and Django 4.1\n* Python 3.8-3.11 and Django 4.2\n\nOlder versions tested against Django 2.2 and 3.2, nothing has changed since\nthen that should break, but these are no longer test targets\n\nDocs\n====\n\nDocs available at: http://django-airplane.readthedocs.io/en/latest/\n\nSource: https://github.com/cltrudeau/django-airplane\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django app that caches CDN files for use when coding offline",
    "version": "1.1.1",
    "project_urls": {
        "Homepage": "https://github.com/cltrudeau/django-airplane"
    },
    "split_keywords": [
        "django",
        "cache",
        "offline",
        "cdn",
        "static"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fb36d6ddf6c8991292c969af8db626ea4072f6e70c01a19c9c45bac64e6132f9",
                "md5": "7d9904b9f891c4ac8f1a5c851591d1c2",
                "sha256": "3aeefdd5ccfe43d3d24a13b6b26fe3a1b49d05823a20208f1378649922d011ff"
            },
            "downloads": -1,
            "filename": "django_airplane-1.1.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7d9904b9f891c4ac8f1a5c851591d1c2",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 10770,
            "upload_time": "2023-06-29T20:54:40",
            "upload_time_iso_8601": "2023-06-29T20:54:40.364168Z",
            "url": "https://files.pythonhosted.org/packages/fb/36/d6ddf6c8991292c969af8db626ea4072f6e70c01a19c9c45bac64e6132f9/django_airplane-1.1.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b818de68b6729b8388acf30d2d24abb12ca91f09611c1c0a9d70ea742557070",
                "md5": "9622c96a270a3e6fa8a68d2f8e182f9e",
                "sha256": "4adbbc138cf9365ebd58f408f37edeefbed354a5f7e6b6ee735bb637d6e28314"
            },
            "downloads": -1,
            "filename": "django-airplane-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9622c96a270a3e6fa8a68d2f8e182f9e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10833,
            "upload_time": "2023-06-29T20:54:41",
            "upload_time_iso_8601": "2023-06-29T20:54:41.632727Z",
            "url": "https://files.pythonhosted.org/packages/3b/81/8de68b6729b8388acf30d2d24abb12ca91f09611c1c0a9d70ea742557070/django-airplane-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-29 20:54:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cltrudeau",
    "github_project": "django-airplane",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "context-temp",
            "specs": [
                [
                    "==",
                    "0.11.2"
                ]
            ]
        },
        {
            "name": "coverage",
            "specs": [
                [
                    "==",
                    "7.2.7"
                ]
            ]
        },
        {
            "name": "Django",
            "specs": [
                [
                    "==",
                    "4.2.2"
                ]
            ]
        },
        {
            "name": "django-awl",
            "specs": [
                [
                    "==",
                    "1.8.0"
                ]
            ]
        },
        {
            "name": "pudb",
            "specs": [
                [
                    "==",
                    "2022.1.3"
                ]
            ]
        },
        {
            "name": "pyflakes",
            "specs": [
                [
                    "==",
                    "3.0.1"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.31.0"
                ]
            ]
        },
        {
            "name": "Sphinx",
            "specs": [
                [
                    "==",
                    "6.2.1"
                ]
            ]
        },
        {
            "name": "sphinx-rtd-theme",
            "specs": [
                [
                    "==",
                    "1.2.2"
                ]
            ]
        },
        {
            "name": "tox",
            "specs": [
                [
                    "==",
                    "3.28.0"
                ]
            ]
        },
        {
            "name": "twine",
            "specs": [
                [
                    "==",
                    "4.0.2"
                ]
            ]
        },
        {
            "name": "waelstow",
            "specs": [
                [
                    "==",
                    "0.11.1"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "django-airplane"
}
        
Elapsed time: 0.08107s