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.

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 2.7, 3.3 or higher

  • Django 1.8 or higher

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'

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

Project details


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-2.0.0.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

djangocms_snippet-2.0.0-py2-none-any.whl (138.5 kB view details)

Uploaded Python 2

File details

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

File metadata

File hashes

Hashes for djangocms-snippet-2.0.0.tar.gz
Algorithm Hash digest
SHA256 c30c4915ba2c3541464741e570d4d042f8d7ec936709ff6f181245b4cbb1b1bb
MD5 80eceb8710212616dc3ff164ced8d5ed
BLAKE2b-256 c125e2641a3cec21159503edcb7a39fc4d0567587b8a94693d50ce5daf7a44a9

See more details on using hashes here.

Provenance

File details

Details for the file djangocms_snippet-2.0.0-py2-none-any.whl.

File metadata

File hashes

Hashes for djangocms_snippet-2.0.0-py2-none-any.whl
Algorithm Hash digest
SHA256 d243e9c1add4a2c239197004e3a6386a26a90b9e82f19f7011ba9d5b34411d57
MD5 d2130fc34f020b0fce1d1f14d1a67f84
BLAKE2b-256 9c0cc3f36c96e9b54e031f2976a31e7424eeaacc2ef809f98c8e760dd96a70eb

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