- Notifications
You must be signed in to change notification settings - Fork52
django CMS Snippet provides a plugin for django CMS to inject HTML, CSS or JavaScript snippets into your website.
License
django-cms/djangocms-snippet
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
django CMS Snippet provides a plugin fordjango CMSto inject HTML, CSS or JavaScript snippets into your website.
This project is endorsed by thedjango CMS Association. Join us onSlack.
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 ofDjango's normal sanitization mechanisms. This could be exploited by userswith the right to add snippets to elevate their privileges to superusers.This plugin should only be used during the initial development phase forrapid prototyping and testing.
Because this is a an open-source project, we welcome everyone toget involved in the project andreceive a reward 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 yourfeedback in the form of issues and pull requests. Before submitting yourpull request, please review ourcontribution guidelines.
We're grateful to all contributors who have helped create and maintain this package.Contributors are listed at thecontributorssection.
One of the easiest contributions you can make is helping to translate this addon onTransifex.
SeeREQUIREMENTS
in thesetup.pyfile for additional dependencies.
For a manual install:
- run
pip install djangocms-snippet
- add
djangocms_snippet
to yourINSTALLED_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 changethe requirement from djangocms_snippet to djangocms_snippet[static-ace] andadd djangocms_static_ace to your project's INSTALLED_APPS.
To allow the contents of all snippets to be searchable, please setDJANGOCMS_SNIPPET_SEARCH
toTrue
in your settings:
DJANGOCMS_SNIPPET_SEARCH = True
We are usingAce as our editor of choiceto edit the snippet content. You can customize thetheme andmode 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 setDJANGOCMS_SNIPPET_CACHE
toFalse
in your settings:
DJANGOCMS_SNIPPET_CACHE = False # default value is False
If you use djangocms-versioning or djangocms-moderation, you can have snippets versioned and moderated byadding the following to your settings:
DJANGOCMS_SNIPPET_VERSIONING = True # Set to version with djangocms-versioningDJANGOCMS_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.
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 %}
When adding a snippet with the object or embed tag as root element, the CMS toolbar crashes, making any furtherediting of the page difficult or impossible. A workaround is to just put those elements inside a div tag.
You can run tests by executing:
virtualenv envsource env/bin/activatepip install -r tests/requirements.txtpython setup.py test
About
django CMS Snippet provides a plugin for django CMS to inject HTML, CSS or JavaScript snippets into your website.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.