django-node-assets


Namedjango-node-assets JSON
Version 0.9.13 PyPI version JSON
download
home_page
SummaryThe Django application that allows to install and serve assets via Node.js package manager infrastructure.
upload_time2023-08-31 21:44:13
maintainer
docs_urlNone
author
requires_python
licenseMIT License Copyright (c) 2023 Andrey Butenko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords django assets staticfiles node.js npm package.json
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ##################
Django-node-assets
##################

.. image:: https://badge.fury.io/py/django-node-assets.svg
    :target: https://badge.fury.io/py/django-node-assets

.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
    :target: https://pycqa.github.io/isort/

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black

.. image:: https://github.com/whitespy/django-node-assets/actions/workflows/code_quality_check.yml/badge.svg
    :target: https://github.com/whitespy/django-node-assets/actions/workflows/code_quality_check.yml

|

The Django application that allows to install and to serve static assets via Node.js package manager infrastructure.
The application exposes management command to install dependencies from your **package.json** and several static files
finders to find files from installed node packages and exclude metadata of node packages and unwanted files when
static files will be collected via Django`s **collectstatic** management command execution.

Features
--------

- Avoiding vendoring static assets in your repository like jQuery plugins, Bootstrap toolkit, etc
- Avoiding mess in **STATIC_ROOT** through exclusion node packages` metatadata and unwanted files
- Installing dependencies by Django`s management command

Installation
------------

.. code:: bash

    $ pip install django-node-assets

Configuration
-------------

Add 'django_node_assets' to your INSTALLED_APPS:

.. code:: python

    INSTALLED_APPS = [
        ...
        'django_node_assets',
    ]

Add NodeModulesFinder to STATICFILES_FINDERS:

.. code:: python

    STATICFILES_FINDERS = [
        'django.contrib.staticfiles.finders.FileSystemFinder',
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',
        'django_node_assets.finders.NodeModulesFinder',
    ]

Specify absolute path to the package.json file:

.. code:: python

    NODE_PACKAGE_JSON = '/var/assets/package.json'

.. note::

    A package.json must have the "dependencies" section and look like:

    .. code:: json

        {
            "dependencies": {
                "jquery": "^3.2.1",
                "bootstrap": "^3.3.5",
            }
        }

    Details here: https://docs.npmjs.com/files/package.json#dependencies


Specify the absolute path to a directory where the **nmpinstall** management command will install assets:

.. code:: python

    NODE_MODULES_ROOT = '/var/assets/node_modules'

.. note::

    A base dir must be called **node_modules**.

Override path to the node package manager executable (optional)

.. code:: python

    NODE_PACKAGE_MANAGER_EXECUTABLE = '/usr/local/bin/npm'

.. note::

    The node package manager must be already installed in your system.

Usage
-----

Call the **nmpinstall** management command to install dependencies specified in the package.json

.. code:: bash

    $ python manage.py npminstall

Use Django`s static template tag to link installed assets

.. code:: html

    {% load static %}

    <link rel="stylesheet" type="text/css" href="{% static 'bootstrap/dist/css/bootstrap.min.css' %}">
    <!-- Some amazing markup -->
    <script src="{% static 'jquery/dist/jquery.min.js' %}"></script>
    <script src="{% static 'bootstrap/dist/js/bootstrap.js' %}"></script>

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "django-node-assets",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django,assets,staticfiles,Node.js,npm,package.json",
    "author": "",
    "author_email": "Andrey Butenko <whitespysoftware@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c3/a7/7fb0af0245406754295cac45eb18994eaab4099281210468b6a83f77d5d7/django-node-assets-0.9.13.tar.gz",
    "platform": null,
    "description": "##################\nDjango-node-assets\n##################\n\n.. image:: https://badge.fury.io/py/django-node-assets.svg\n    :target: https://badge.fury.io/py/django-node-assets\n\n.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336\n    :target: https://pycqa.github.io/isort/\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n\n.. image:: https://github.com/whitespy/django-node-assets/actions/workflows/code_quality_check.yml/badge.svg\n    :target: https://github.com/whitespy/django-node-assets/actions/workflows/code_quality_check.yml\n\n|\n\nThe Django application that allows to install and to serve static assets via Node.js package manager infrastructure.\nThe application exposes management command to install dependencies from your **package.json** and several static files\nfinders to find files from installed node packages and exclude metadata of node packages and unwanted files when\nstatic files will be collected via Django`s **collectstatic** management command execution.\n\nFeatures\n--------\n\n- Avoiding vendoring static assets in your repository like jQuery plugins, Bootstrap toolkit, etc\n- Avoiding mess in **STATIC_ROOT** through exclusion node packages` metatadata and unwanted files\n- Installing dependencies by Django`s management command\n\nInstallation\n------------\n\n.. code:: bash\n\n    $ pip install django-node-assets\n\nConfiguration\n-------------\n\nAdd 'django_node_assets' to your INSTALLED_APPS:\n\n.. code:: python\n\n    INSTALLED_APPS = [\n        ...\n        'django_node_assets',\n    ]\n\nAdd NodeModulesFinder to STATICFILES_FINDERS:\n\n.. code:: python\n\n    STATICFILES_FINDERS = [\n        'django.contrib.staticfiles.finders.FileSystemFinder',\n        'django.contrib.staticfiles.finders.AppDirectoriesFinder',\n        'django_node_assets.finders.NodeModulesFinder',\n    ]\n\nSpecify absolute path to the package.json file:\n\n.. code:: python\n\n    NODE_PACKAGE_JSON = '/var/assets/package.json'\n\n.. note::\n\n    A package.json must have the \"dependencies\" section and look like:\n\n    .. code:: json\n\n        {\n            \"dependencies\": {\n                \"jquery\": \"^3.2.1\",\n                \"bootstrap\": \"^3.3.5\",\n            }\n        }\n\n    Details here: https://docs.npmjs.com/files/package.json#dependencies\n\n\nSpecify the absolute path to a directory where the **nmpinstall** management command will install assets:\n\n.. code:: python\n\n    NODE_MODULES_ROOT = '/var/assets/node_modules'\n\n.. note::\n\n    A base dir must be called **node_modules**.\n\nOverride path to the node package manager executable (optional)\n\n.. code:: python\n\n    NODE_PACKAGE_MANAGER_EXECUTABLE = '/usr/local/bin/npm'\n\n.. note::\n\n    The node package manager must be already installed in your system.\n\nUsage\n-----\n\nCall the **nmpinstall** management command to install dependencies specified in the package.json\n\n.. code:: bash\n\n    $ python manage.py npminstall\n\nUse Django`s static template tag to link installed assets\n\n.. code:: html\n\n    {% load static %}\n\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"{% static 'bootstrap/dist/css/bootstrap.min.css' %}\">\n    <!-- Some amazing markup -->\n    <script src=\"{% static 'jquery/dist/jquery.min.js' %}\"></script>\n    <script src=\"{% static 'bootstrap/dist/js/bootstrap.js' %}\"></script>\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Andrey Butenko  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "The Django application that allows to install and serve assets via Node.js package manager infrastructure.",
    "version": "0.9.13",
    "project_urls": {
        "GitHub": "https://github.com/whitespy/django-node-assets"
    },
    "split_keywords": [
        "django",
        "assets",
        "staticfiles",
        "node.js",
        "npm",
        "package.json"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c688a99a3c2d6c85880b9e256104f3c18c06130605e38b1ce24d9be87c6eb49",
                "md5": "69637c40401ee100570829a4320b8d40",
                "sha256": "c1178faf152cb3acf89d586bd7f994c9dc36c9a5c21fe71556c25388c0f8d60f"
            },
            "downloads": -1,
            "filename": "django_node_assets-0.9.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "69637c40401ee100570829a4320b8d40",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6806,
            "upload_time": "2023-08-31T21:44:10",
            "upload_time_iso_8601": "2023-08-31T21:44:10.942233Z",
            "url": "https://files.pythonhosted.org/packages/5c/68/8a99a3c2d6c85880b9e256104f3c18c06130605e38b1ce24d9be87c6eb49/django_node_assets-0.9.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c3a77fb0af0245406754295cac45eb18994eaab4099281210468b6a83f77d5d7",
                "md5": "85bec3b954686a8476bde28216668db3",
                "sha256": "16aa86798f35e47c6b0c6f506b08cad6fdfc02223ba0cc0c4cb1c9d1778bbb9b"
            },
            "downloads": -1,
            "filename": "django-node-assets-0.9.13.tar.gz",
            "has_sig": false,
            "md5_digest": "85bec3b954686a8476bde28216668db3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6156,
            "upload_time": "2023-08-31T21:44:13",
            "upload_time_iso_8601": "2023-08-31T21:44:13.772792Z",
            "url": "https://files.pythonhosted.org/packages/c3/a7/7fb0af0245406754295cac45eb18994eaab4099281210468b6a83f77d5d7/django-node-assets-0.9.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-31 21:44:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "whitespy",
    "github_project": "django-node-assets",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-node-assets"
}
        
Elapsed time: 0.11481s