djangocms-snippet


Namedjangocms-snippet JSON
Version 5.0.2 PyPI version JSON
download
home_pageNone
SummaryAdds snippet plugin to django CMS.
upload_time2025-09-03 18:44:42
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseCopyright (c) 2011, Divio AG All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Divio AG nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIVIO AG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords
VCS
bugtrack_url
requirements asgiref build bump2version cfgv click distlib django django-classy-tags django-cms django-formtools django-sekizai django-treebeard djangocms-admin-style filelock identify importlib-metadata nodeenv packaging pip-tools platformdirs pre-commit pyproject-hooks pyyaml sqlparse tomli typing-extensions virtualenv wheel zipp
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==================
django CMS Snippet
==================

|pypi| |coverage| |python| |django| |djangocms| |djangocms4|


**django CMS Snippet** provides a plugin for `django CMS <http://django-cms.org>`_
to inject HTML, CSS or JavaScript snippets into your website.

This project is endorsed by the `django CMS Association <https://www.django-cms.org/en/about-us/>`_. Join us on `Slack <https://www.django-cms.org/slack/>`_.



Warning: We recommend using this plugin only during development::

    This plugin is a potential security hazard, since it allows authorized-
    users to place custom markup or Javascript on pages bypassing all of
    Django's normal sanitization mechanisms. This could be exploited by users
    with the right to add snippets to elevate their privileges to superusers.
    This plugin should only be used during the initial development phase for
    rapid prototyping and testing.

.. image:: preview.gif


*******************************************
Contribute to this project and win rewards
*******************************************

Because this is a an open-source project, we welcome everyone to
`get involved in the project <https://www.django-cms.org/en/contribute/>`_ and
`receive a reward <https://www.django-cms.org/en/bounty-program/>`_ for their contribution.
Become part of a fantastic community and help us make django CMS the best CMS in the world.

We'll be delighted to receive your
feedback in the form of issues and pull requests. Before submitting your
pull request, please review our `contribution guidelines
<http://docs.django-cms.org/en/latest/contributing/index.html>`_.

We're grateful to all contributors who have helped create and maintain this package.
Contributors are listed at the `contributors <https://github.com/django-cms/djangocms-snippet/graphs/contributors>`_
section.

One of the easiest contributions you can make is helping to translate this addon on
`Transifex <https://www.transifex.com/projects/p/djangocms-snippet/>`_.


Documentation
=============

See ``REQUIREMENTS`` in the `setup.py <https://github.com/divio/djangocms-snippet/blob/master/setup.py>`_
file for additional dependencies.


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

For a manual install:

* run ``pip install djangocms-snippet``
* add ``djangocms_snippet`` to your ``INSTALLED_APPS``
* run ``python manage.py migrate djangocms_snippet``

Djangocms-snippet uses the ace code editor which normally is loaded from a CDN.
If you prefer your application to provide the editor locally, you can change
the requirement from `djangocms_snippet` to `djangocms_snippet[static-ace]` and
add `djangocms_static_ace` to your project's `INSTALLED_APPS`.


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

To allow the contents of all snippets to be searchable, please set
``DJANGOCMS_SNIPPET_SEARCH`` to ``True`` in your settings::

    DJANGOCMS_SNIPPET_SEARCH = True

We are using `Ace <https://ace.c9.io/#nav=about>`_ as our editor of choice
to edit the snippet content. You can customize the
`theme <https://github.com/ajaxorg/ace/tree/master/lib/ace/theme>`_ and
`mode <https://github.com/ajaxorg/ace/tree/master/lib/ace/mode>`_ through::

    DJANGOCMS_SNIPPET_THEME = 'github'
    DJANGOCMS_SNIPPET_MODE = 'html'

If dynamic content is inserted (for example ``{% show_menu ... %}``), the plugin cache must be disabled,
please set ``DJANGOCMS_SNIPPET_CACHE`` to ``False`` in your settings::

    DJANGOCMS_SNIPPET_CACHE = False # default value is False

django CMS 4 and later
----------------------

If you use djangocms-versioning or djangocms-moderation, you can have snippets versioned and moderated by
adding the following to your settings::

    DJANGOCMS_SNIPPET_VERSIONING = True  # Set to version with djangocms-versioning
    DJANGOCMS_SNIPPET_MODERATION = True  # Set to moderate with djangocms-moderation

If you enable versioning (e.g., set `DJANGOCMS_SNIPPET_VERSIONING = True`) for djangocms-snippets in a project that already contains snippets, you will need to create `Version` objects for those existing snippets using the `create_version` management command provided by djangocms-versioning.

Template tag
------------

You can also use a template tag to render a snippet rather than a plugin::

    {% load snippet_tags %}
    {% snippet_fragment [reference] %}

Replace ``[reference]`` with either:

* The snippet ID, e.g. ``{% snippet_fragment 42 %}``
* The snippet slug, e.g. ``{% snippet_fragment 'my-snippet' %}``
* The snippet instance, e.g. ``{% snippet_fragment instance.snippet %}``

Optionally provide a fallback if there is no matching id/slug/instance::

    {% snippet_fragment 'my-snippet' or %}
        ... your content fallback here ...
    {% endsnippet_fragment %}


Known Issues
------------

When adding a snippet with the `object` or `embed` tag as root element, the CMS toolbar crashes, making any further
editing of the page difficult or impossible. A workaround is to just put those elements inside a `div` tag.


Running Tests
-------------

You can run tests by executing::

    virtualenv env
    source env/bin/activate
    pip install -r tests/requirements.txt
    python setup.py test


.. |pypi| image:: https://badge.fury.io/py/djangocms-snippet.svg
    :target: http://badge.fury.io/py/djangocms-snippet
.. |coverage| image:: https://codecov.io/gh/django-cms/djangocms-snippet/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/django-cms/djangocms-snippet
.. |python| image:: https://img.shields.io/badge/python-3.9+-blue.svg
    :target: https://pypi.org/project/djangocms-snippet/
.. |django| image:: https://img.shields.io/badge/django-4.2+-blue.svg
    :target: https://www.djangoproject.com/
.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.11-blue.svg
    :target: https://www.django-cms.org/
.. |djangocms4| image:: https://img.shields.io/badge/django%20CMS-4%2B-blue.svg
    :target: https://www.django-cms.org/

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "djangocms-snippet",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Django CMS Association and contributors <info@django-cms.org>",
    "keywords": null,
    "author": null,
    "author_email": "Divio AG <info@divio.ch>",
    "download_url": "https://files.pythonhosted.org/packages/42/51/9c7f181024280920d5c1a347ad69c22c788fa9508b123992dbacacd64bfd/djangocms_snippet-5.0.2.tar.gz",
    "platform": null,
    "description": "==================\ndjango CMS Snippet\n==================\n\n|pypi| |coverage| |python| |django| |djangocms| |djangocms4|\n\n\n**django CMS Snippet** provides a plugin for `django CMS <http://django-cms.org>`_\nto inject HTML, CSS or JavaScript snippets into your website.\n\nThis project is endorsed by the `django CMS Association <https://www.django-cms.org/en/about-us/>`_. Join us on `Slack <https://www.django-cms.org/slack/>`_.\n\n\n\nWarning: We recommend using this plugin only during development::\n\n    This plugin is a potential security hazard, since it allows authorized-\n    users to place custom markup or Javascript on pages bypassing all of\n    Django's normal sanitization mechanisms. This could be exploited by users\n    with the right to add snippets to elevate their privileges to superusers.\n    This plugin should only be used during the initial development phase for\n    rapid prototyping and testing.\n\n.. image:: preview.gif\n\n\n*******************************************\nContribute to this project and win rewards\n*******************************************\n\nBecause this is a an open-source project, we welcome everyone to\n`get involved in the project <https://www.django-cms.org/en/contribute/>`_ and\n`receive a reward <https://www.django-cms.org/en/bounty-program/>`_ for their contribution.\nBecome part of a fantastic community and help us make django CMS the best CMS in the world.\n\nWe'll be delighted to receive your\nfeedback in the form of issues and pull requests. Before submitting your\npull request, please review our `contribution guidelines\n<http://docs.django-cms.org/en/latest/contributing/index.html>`_.\n\nWe're grateful to all contributors who have helped create and maintain this package.\nContributors are listed at the `contributors <https://github.com/django-cms/djangocms-snippet/graphs/contributors>`_\nsection.\n\nOne of the easiest contributions you can make is helping to translate this addon on\n`Transifex <https://www.transifex.com/projects/p/djangocms-snippet/>`_.\n\n\nDocumentation\n=============\n\nSee ``REQUIREMENTS`` in the `setup.py <https://github.com/divio/djangocms-snippet/blob/master/setup.py>`_\nfile for additional dependencies.\n\n\nInstallation\n------------\n\nFor a manual install:\n\n* run ``pip install djangocms-snippet``\n* add ``djangocms_snippet`` to your ``INSTALLED_APPS``\n* run ``python manage.py migrate djangocms_snippet``\n\nDjangocms-snippet uses the ace code editor which normally is loaded from a CDN.\nIf you prefer your application to provide the editor locally, you can change\nthe requirement from `djangocms_snippet` to `djangocms_snippet[static-ace]` and\nadd `djangocms_static_ace` to your project's `INSTALLED_APPS`.\n\n\nConfiguration\n-------------\n\nTo allow the contents of all snippets to be searchable, please set\n``DJANGOCMS_SNIPPET_SEARCH`` to ``True`` in your settings::\n\n    DJANGOCMS_SNIPPET_SEARCH = True\n\nWe are using `Ace <https://ace.c9.io/#nav=about>`_ as our editor of choice\nto edit the snippet content. You can customize the\n`theme <https://github.com/ajaxorg/ace/tree/master/lib/ace/theme>`_ and\n`mode <https://github.com/ajaxorg/ace/tree/master/lib/ace/mode>`_ through::\n\n    DJANGOCMS_SNIPPET_THEME = 'github'\n    DJANGOCMS_SNIPPET_MODE = 'html'\n\nIf dynamic content is inserted (for example ``{% show_menu ... %}``), the plugin cache must be disabled,\nplease set ``DJANGOCMS_SNIPPET_CACHE`` to ``False`` in your settings::\n\n    DJANGOCMS_SNIPPET_CACHE = False # default value is False\n\ndjango CMS 4 and later\n----------------------\n\nIf you use djangocms-versioning or djangocms-moderation, you can have snippets versioned and moderated by\nadding the following to your settings::\n\n    DJANGOCMS_SNIPPET_VERSIONING = True  # Set to version with djangocms-versioning\n    DJANGOCMS_SNIPPET_MODERATION = True  # Set to moderate with djangocms-moderation\n\nIf you enable versioning (e.g., set `DJANGOCMS_SNIPPET_VERSIONING = True`) for djangocms-snippets in a project that already contains snippets, you will need to create `Version` objects for those existing snippets using the `create_version` management command provided by djangocms-versioning.\n\nTemplate tag\n------------\n\nYou can also use a template tag to render a snippet rather than a plugin::\n\n    {% load snippet_tags %}\n    {% snippet_fragment [reference] %}\n\nReplace ``[reference]`` with either:\n\n* The snippet ID, e.g. ``{% snippet_fragment 42 %}``\n* The snippet slug, e.g. ``{% snippet_fragment 'my-snippet' %}``\n* The snippet instance, e.g. ``{% snippet_fragment instance.snippet %}``\n\nOptionally provide a fallback if there is no matching id/slug/instance::\n\n    {% snippet_fragment 'my-snippet' or %}\n        ... your content fallback here ...\n    {% endsnippet_fragment %}\n\n\nKnown Issues\n------------\n\nWhen adding a snippet with the `object` or `embed` tag as root element, the CMS toolbar crashes, making any further\nediting of the page difficult or impossible. A workaround is to just put those elements inside a `div` tag.\n\n\nRunning Tests\n-------------\n\nYou can run tests by executing::\n\n    virtualenv env\n    source env/bin/activate\n    pip install -r tests/requirements.txt\n    python setup.py test\n\n\n.. |pypi| image:: https://badge.fury.io/py/djangocms-snippet.svg\n    :target: http://badge.fury.io/py/djangocms-snippet\n.. |coverage| image:: https://codecov.io/gh/django-cms/djangocms-snippet/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/django-cms/djangocms-snippet\n.. |python| image:: https://img.shields.io/badge/python-3.9+-blue.svg\n    :target: https://pypi.org/project/djangocms-snippet/\n.. |django| image:: https://img.shields.io/badge/django-4.2+-blue.svg\n    :target: https://www.djangoproject.com/\n.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.11-blue.svg\n    :target: https://www.django-cms.org/\n.. |djangocms4| image:: https://img.shields.io/badge/django%20CMS-4%2B-blue.svg\n    :target: https://www.django-cms.org/\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2011, Divio AG\n        All rights reserved.\n        \n        Redistribution and use in source and binary forms, with or without\n        modification, are permitted provided that the following conditions are met:\n            * Redistributions of source code must retain the above copyright\n              notice, this list of conditions and the following disclaimer.\n            * Redistributions in binary form must reproduce the above copyright\n              notice, this list of conditions and the following disclaimer in the\n              documentation and/or other materials provided with the distribution.\n            * Neither the name of Divio AG nor the\n              names of its contributors may be used to endorse or promote products\n              derived from this software without specific prior written permission.\n        \n        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n        DISCLAIMED. IN NO EVENT SHALL DIVIO AG BE LIABLE FOR ANY\n        DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n        ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n        ",
    "summary": "Adds snippet plugin to django CMS.",
    "version": "5.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/django-cms/djangocms-snippet/issues",
        "Changelog": "https://github.com/django-cms/djangocms-snippet/blob/master/CHANGELOG.rst",
        "Repository": "https://github.com/django-cms/djangocms-snippet",
        "Support": "https://www.django-cms.org/slack/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0092cf1c4714cec92683a0c7564ee268311faa4a8bb0a722af269e26998bcd92",
                "md5": "db9ac63fd46f776c018396775339785f",
                "sha256": "42fdf0a37a80175184197315fc20475a1e019b72d01cc1621c04f3cb7d0f797c"
            },
            "downloads": -1,
            "filename": "djangocms_snippet-5.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db9ac63fd46f776c018396775339785f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 156575,
            "upload_time": "2025-09-03T18:44:40",
            "upload_time_iso_8601": "2025-09-03T18:44:40.996417Z",
            "url": "https://files.pythonhosted.org/packages/00/92/cf1c4714cec92683a0c7564ee268311faa4a8bb0a722af269e26998bcd92/djangocms_snippet-5.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "42519c7f181024280920d5c1a347ad69c22c788fa9508b123992dbacacd64bfd",
                "md5": "c0722a5bd0b5c449b93a77dcb4feb794",
                "sha256": "d3b19abc62b8f665e104b7aa5489292b397e46d61fc4f3ee27b7f122d8b8bb65"
            },
            "downloads": -1,
            "filename": "djangocms_snippet-5.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c0722a5bd0b5c449b93a77dcb4feb794",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 44141,
            "upload_time": "2025-09-03T18:44:42",
            "upload_time_iso_8601": "2025-09-03T18:44:42.417599Z",
            "url": "https://files.pythonhosted.org/packages/42/51/9c7f181024280920d5c1a347ad69c22c788fa9508b123992dbacacd64bfd/djangocms_snippet-5.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-03 18:44:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "django-cms",
    "github_project": "djangocms-snippet",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "asgiref",
            "specs": [
                [
                    "==",
                    "3.8.1"
                ]
            ]
        },
        {
            "name": "build",
            "specs": [
                [
                    "==",
                    "1.2.1"
                ]
            ]
        },
        {
            "name": "bump2version",
            "specs": [
                [
                    "==",
                    "1.0.1"
                ]
            ]
        },
        {
            "name": "cfgv",
            "specs": [
                [
                    "==",
                    "3.4.0"
                ]
            ]
        },
        {
            "name": "click",
            "specs": [
                [
                    "==",
                    "8.1.7"
                ]
            ]
        },
        {
            "name": "distlib",
            "specs": [
                [
                    "==",
                    "0.3.8"
                ]
            ]
        },
        {
            "name": "django",
            "specs": [
                [
                    "==",
                    "4.2.13"
                ]
            ]
        },
        {
            "name": "django-classy-tags",
            "specs": [
                [
                    "==",
                    "4.1.0"
                ]
            ]
        },
        {
            "name": "django-cms",
            "specs": [
                [
                    "==",
                    "4.1.1"
                ]
            ]
        },
        {
            "name": "django-formtools",
            "specs": [
                [
                    "==",
                    "2.5.1"
                ]
            ]
        },
        {
            "name": "django-sekizai",
            "specs": [
                [
                    "==",
                    "4.1.0"
                ]
            ]
        },
        {
            "name": "django-treebeard",
            "specs": [
                [
                    "==",
                    "4.7.1"
                ]
            ]
        },
        {
            "name": "djangocms-admin-style",
            "specs": [
                [
                    "==",
                    "3.3.1"
                ]
            ]
        },
        {
            "name": "filelock",
            "specs": [
                [
                    "==",
                    "3.14.0"
                ]
            ]
        },
        {
            "name": "identify",
            "specs": [
                [
                    "==",
                    "2.5.36"
                ]
            ]
        },
        {
            "name": "importlib-metadata",
            "specs": [
                [
                    "==",
                    "7.1.0"
                ]
            ]
        },
        {
            "name": "nodeenv",
            "specs": [
                [
                    "==",
                    "1.8.0"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "24.0"
                ]
            ]
        },
        {
            "name": "pip-tools",
            "specs": [
                [
                    "==",
                    "7.4.1"
                ]
            ]
        },
        {
            "name": "platformdirs",
            "specs": [
                [
                    "==",
                    "4.2.2"
                ]
            ]
        },
        {
            "name": "pre-commit",
            "specs": [
                [
                    "==",
                    "3.7.1"
                ]
            ]
        },
        {
            "name": "pyproject-hooks",
            "specs": [
                [
                    "==",
                    "1.1.0"
                ]
            ]
        },
        {
            "name": "pyyaml",
            "specs": [
                [
                    "==",
                    "6.0.1"
                ]
            ]
        },
        {
            "name": "sqlparse",
            "specs": [
                [
                    "==",
                    "0.5.0"
                ]
            ]
        },
        {
            "name": "tomli",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "typing-extensions",
            "specs": [
                [
                    "==",
                    "4.11.0"
                ]
            ]
        },
        {
            "name": "virtualenv",
            "specs": [
                [
                    "==",
                    "20.26.2"
                ]
            ]
        },
        {
            "name": "wheel",
            "specs": [
                [
                    "==",
                    "0.43.0"
                ]
            ]
        },
        {
            "name": "zipp",
            "specs": [
                [
                    "==",
                    "3.19.1"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "djangocms-snippet"
}
        
Elapsed time: 2.48648s