Giter Club home page Giter Club logo

djangocms-snippet's Introduction

django CMS Snippet

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

djangocms-snippet's People

Contributors

akuryou avatar chive avatar czpython avatar digi604 avatar ericamador avatar filwaitman avatar finalangel avatar fp4code avatar mkoistinen avatar rage2000 avatar stefanfoulis avatar sveetch avatar vstoykov avatar vxsx avatar yakky avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.