Add sanitized rich-text descriptions for content assets
Introduce HtmlTextField, which cleans submitted HTML with nh3 against a tag/attribute allowlist, and use it for ContentAsset.description via Meta.field_classes. Edit descriptions with TinyMCE and render the sanitized HTML on the asset page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3fe49b47ea
commit
5bb9a70c11
@@ -0,0 +1,16 @@
|
||||
<script type="application/javascript">
|
||||
tinymce.init({
|
||||
selector: '{{ selector }}',
|
||||
license_key: 'gpl',
|
||||
menubar: '',
|
||||
toolbar: 'undo redo | bold italic | bullist numlist | link emoticons',
|
||||
plugins: [
|
||||
'link', 'emoticons', 'lists'
|
||||
],
|
||||
setup: function (editor) {
|
||||
editor.on('change', function () {
|
||||
tinymce.triggerSave();
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -30,7 +30,7 @@
|
||||
<dt class="col-sm-3">Title</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.title }}</dd>
|
||||
<dt class="col-sm-3">Description</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.description|linebreaksbr|default:"—" }}</dd>
|
||||
<dd class="col-sm-9">{{ content_asset.description|default:"—"|safe }}</dd>
|
||||
<dt class="col-sm-3">Release date</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.release_date|default:"—" }}</dd>
|
||||
<dt class="col-sm-3">Series / Collection</dt>
|
||||
@@ -72,4 +72,6 @@
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endwith %}
|
||||
{% include 'includes/_tinymce.html' with selector="textarea#id_description" %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user