Plugins (feincms3.plugins
)¶
Historical 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.NoembedValidationForm(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]¶
Tries fetching the oEmbed code for the given URL when cleaning form data
This isn’t active by default. If you want to validate URLs you should use the following snippet:
from app.pages import models from feincms3 import plugins class SomeAdmin(...): inlines = [ ... plugins.external.ExternalInline.create( model=models.External, form=plugins.external.NoembedValidationForm, ), ... ]
- clean()[source]¶
Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.
- property media¶
Return all media required to render the widgets on this form.
- feincms3.plugins.external.oembed_html(url, **kwargs)[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.oembed_json(url, *, cache_failures=True, force_refresh=False, params=None)[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
isTrue
(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.render_external(plugin, context=None, **kwargs)[source]¶
Render the plugin, embedding it in the appropriate markup for Foundation’s responsive-embed element
The HTML embed code is generated using
oembed_html()
. Maybe you want to take a look atfeincms3.embedding
for a less versatile but much faster alternative.
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.
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.
Rich text¶
- class feincms3.plugins.richtext.RichText(*args, **kwargs)[source]¶
Rich text plugin.
feincms3.inline_ckeditor.InlineCKEditorField
does all the heavy lifting.
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 theTEMPLATES
class variable. This method is a receiver of Django’sclass_prepared
signal.
- classmethod register_with(renderer, **kwargs)[source]¶
This helper registers the snippet plugin with a
TemplatePluginRenderer
while adding support for template-specific context functions. The templates specified using theTEMPLATES
class variable may contain a callable which receives the plugin instance and the template context and returns a context dictionary.
Deprecated plugins¶
Rich text support using django-ckeditor¶
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.old_richtext.RichText(*args, **kwargs)[source]¶
Rich text plugin
To use this, a django-ckeditor configuration named
richtext-plugin
is required. See the sectionHTML cleansing
for the recommended configuration.