Skip to main content

Adds snippet plugin to django CMS.

Project description

pypi build coverage

django CMS Snippet provides a plugin for django CMS to inject HTML, CSS or JavaScript snippets into your website.

This addon is compatible with Divio Cloud and is also available on the django CMS Marketplace for easy installation.

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.
preview.gif

Contributing

This is a an open-source project. 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.

We’re grateful to all contributors who have helped create and maintain this package. Contributors are listed at the contributors section.

One of the easiest contributions you can make is helping to translate this addon on Transifex.

Documentation

See REQUIREMENTS in the setup.py file for additional dependencies:

python django djangocms

Installation

For a manual install:

  • run pip install djangocms-snippet

  • add djangocms_snippet to your INSTALLED_APPS

  • run python manage.py migrate djangocms_snippet

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 as our editor of choice to edit the snippet content. You can customize the theme and 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 True

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 %}

Running Tests

You can run tests by executing:

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangocms-snippet-3.0.0.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

djangocms_snippet-3.0.0-py3-none-any.whl (140.6 kB view details)

Uploaded Python 3

File details

Details for the file djangocms-snippet-3.0.0.tar.gz.

File metadata

  • Download URL: djangocms-snippet-3.0.0.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for djangocms-snippet-3.0.0.tar.gz
Algorithm Hash digest
SHA256 bb1963fc903ddabbe397e151160e3c5b489fcadd74f3f79e8ad270882ffdcb82
MD5 c881421469a5f7e07d6c2a29deec59d2
BLAKE2b-256 8b431c72bb8419e0478fecad7fe2865caeb76fb47c39be40ddaa341eb1b97264

See more details on using hashes here.

Provenance

File details

Details for the file djangocms_snippet-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: djangocms_snippet-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 140.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for djangocms_snippet-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ccc587ba6138aaee73f4e2358bfcd255c7001e958016bfbff8d141ea3bb92f2
MD5 c676f210de7ddb0ecb0a17599ecce30b
BLAKE2b-256 d59dfbe7837f815fa9aa836e4e4fd11ed9f2713f0940b110da0d30650ee98ef9

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page