Plugins (feincms3.plugins)

Note

The content types in FeinCMS had ways to process requests and responses themselves, the .process() and .finalize() methods. feincms3 plugins do not offer this. The feincms3 way to achieve the same thing is by using apps or by adding the functionality in your own views (which are much simpler than the view in FeinCMS was).

External

Uses the Noembed oEmbed service to embed (almost) arbitrary URLs. Depends on requests.

class feincms3.plugins.external.External(*args, **kwargs)[source]

External content plugin

class feincms3.plugins.external.ExternalInline(parent_model, admin_site)[source]

Content editor inline using the ExternalForm to verify whether the given URL is embeddable using oEmbed or not.

form

alias of ExternalForm

feincms3.plugins.external.oembed_json(url, *, cache_failures=True)[source]

Asks Noembed for the embedding HTML code for arbitrary URLs. Sites supported include Youtube, Vimeo, Twitter and many others.

Successful embeds are always cached for 30 days.

Failures are cached if cache_failures is True (the default). The durations are as follows:

  • Connection errors are cached 60 seconds with the hope that the connection failure is only transient.
  • HTTP errors codes and responses in an unexpected format (no JSON) are cached for 24 hours.

The return value is always a dictionary, but it may be empty.

feincms3.plugins.external.oembed_html(url, *, cache_failures=True)[source]

Wraps oembed_json(), but only returns the HTML part of the OEmbed response.

The return value is always either a HTML fragment or an empty string.

feincms3.plugins.external.render_external(plugin, **kwargs)[source]

Render the plugin, embedding it in the appropriate markup for Foundation’s responsive-embed element (https://foundation.zurb.com/sites/docs/responsive-embed.html)

HTML

Plugin providing a simple textarea where raw HTML, CSS and JS code can be entered.

Most useful for people wanting to shoot themselves in the foot.

class feincms3.plugins.html.HTML(*args, **kwargs)[source]

Raw HTML plugin

class feincms3.plugins.html.HTMLInline(parent_model, admin_site)[source]

Just available for consistency, absolutely no difference to a standard ContentEditorInline.

feincms3.plugins.html.render_html(plugin, **kwargs)[source]

Return the HTML code as safe string so that it is not escaped. Of course the contents are not guaranteed to be safe at all

Images

Provides an image plugin with support for setting the primary point of interest. This is very useful especially when cropping images. Depends on django-imagefield.

class feincms3.plugins.image.Image(*args, **kwargs)[source]

Image plugin

class feincms3.plugins.image.ImageInline(parent_model, admin_site)[source]

Image inline

feincms3.plugins.image.render_image(plugin, **kwargs)[source]

Return a simple, unscaled version of the image

Rich text

Provides a rich text area whose content is automatically cleaned using a very restrictive allowlist of tags and attributes.

Depends on django-ckeditor and html-sanitizer.

class feincms3.plugins.richtext.RichText(*args, **kwargs)[source]

Rich text plugin

To use this, a django-ckeditor configuration named richtext-plugin is required. See the section HTML cleansing for the recommended configuration.

class feincms3.plugins.richtext.RichTextInline(parent_model, admin_site)[source]

The only difference with the standard ContentEditorInline is that this inline adds the feincms3/plugin_ckeditor.js file which handles the CKEditor widget activation and deactivation inside the content editor.

feincms3.plugins.richtext.render_richtext(plugin, **kwargs)[source]

Return the text of the rich text plugin as a safe string (mark_safe)

Snippets

Plugin for including template snippets through the CMS

class feincms3.plugins.snippet.Snippet(*args, **kwargs)[source]

Template snippet plugin

static fill_template_name_choices(sender, **kwargs)[source]

Fills in the choices for template_name from the TEMPLATES class variable. This method is a receiver of Django’s class_prepared signal.

classmethod register_with(renderer)[source]

This helper registers the snippet plugin with a TemplatePluginRenderer while adding support for template-specific context functions. The templates specified using the TEMPLATES class variable may contain a callable which receives the plugin instance and the template context and returns a context dictionary.

class feincms3.plugins.snippet.SnippetInline(parent_model, admin_site)[source]

Snippet inline does nothing special, it simply exists for consistency with the other feincms3 plugins

feincms3.plugins.snippet.render_snippet(plugin, **kwargs)[source]

Renders the selected template using render_to_string

Versatile images

Provides an image plugin with support for setting the primary point of interest. This is very useful especially when cropping images. Depends on django-versatileimagefield.

Note

While this plugin works well too the recommended image plugin is feincms3.plugins.image.

class feincms3.plugins.versatileimage.Image(*args, **kwargs)[source]

Image plugin

class feincms3.plugins.versatileimage.AlwaysChangedModelForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

This ModelForm’s has_changed method always returns True. This is a workaround for the problem where Django’s inlines do not detect changes in MultiValueField (which is used to set the PPOI – primary point of interest – in django-versatileimagefield).

https://github.com/respondcreate/django-versatileimagefield/issues/44

has_changed()[source]

Return True if data differs from initial.

class feincms3.plugins.versatileimage.ImageInline(parent_model, admin_site)[source]

Image inline using the AlwaysChangedModelForm to work around a bug where PPOI modifications were not picked up.

form

alias of AlwaysChangedModelForm

feincms3.plugins.versatileimage.render_image(plugin, **kwargs)[source]

Return a simple, unscaled version of the image