Compare commits
2
Commits
3fe49b47ea
...
e582cb9234
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e582cb9234 | ||
|
|
5bb9a70c11 |
+1
-1
@@ -13,5 +13,5 @@ __pycache__/
|
|||||||
|
|
||||||
db.sqlite3
|
db.sqlite3
|
||||||
privatestudio/settings/local.py
|
privatestudio/settings/local.py
|
||||||
static/
|
privatestudio/static/bundle/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import nh3
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
from django.forms import Textarea
|
||||||
|
|
||||||
|
NH3_TAGS = {
|
||||||
|
"a",
|
||||||
|
"p",
|
||||||
|
"strong",
|
||||||
|
"img",
|
||||||
|
"ul",
|
||||||
|
"ol",
|
||||||
|
"li",
|
||||||
|
"b",
|
||||||
|
"s",
|
||||||
|
"u",
|
||||||
|
}
|
||||||
|
|
||||||
|
NH3_ATTR = {
|
||||||
|
"a": {
|
||||||
|
"href",
|
||||||
|
"target",
|
||||||
|
},
|
||||||
|
"img": {
|
||||||
|
"alt",
|
||||||
|
"src",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class HtmlTextField(forms.CharField):
|
||||||
|
widget = Textarea
|
||||||
|
|
||||||
|
def to_python(self, value):
|
||||||
|
value = super().to_python(value)
|
||||||
|
if value not in self.empty_values:
|
||||||
|
value = nh3.clean(
|
||||||
|
value,
|
||||||
|
tags=NH3_TAGS,
|
||||||
|
attributes=NH3_ATTR,
|
||||||
|
)
|
||||||
|
return value
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from privatestudio.studio.models import ContentAsset
|
from privatestudio.studio.models import ContentAsset
|
||||||
|
from privatestudio.fields import HtmlTextField
|
||||||
|
|
||||||
|
|
||||||
class ContentAssetForm(forms.ModelForm):
|
class ContentAssetForm(forms.ModelForm):
|
||||||
@@ -14,6 +15,9 @@ class ContentAssetForm(forms.ModelForm):
|
|||||||
"release_date": forms.DateInput(attrs={"type": "date"}, format="%Y-%m-%d"),
|
"release_date": forms.DateInput(attrs={"type": "date"}, format="%Y-%m-%d"),
|
||||||
"description": forms.Textarea(attrs={"rows": 4}),
|
"description": forms.Textarea(attrs={"rows": 4}),
|
||||||
}
|
}
|
||||||
|
field_classes = {
|
||||||
|
"description": HtmlTextField,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, *args, studio, **kwargs):
|
def __init__(self, *args, studio, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
{# <meta name="description" content="{{ page.search_description }}" />#}
|
{# <meta name="description" content="{{ page.search_description }}" />#}
|
||||||
{# {% endif %}#}
|
{# {% endif %}#}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link rel="icon" href="{% static 'favicon.ico' %}" sizes="any" />
|
||||||
|
<link rel="icon" href="{% static 'favicon.svg' %}" type="image/svg+xml" />
|
||||||
|
<link rel="apple-touch-icon" href="{% static 'apple-touch-icon.png' %}" />
|
||||||
|
|
||||||
{# Force all links in the live preview panel to be opened in a new tab #}
|
{# Force all links in the live preview panel to be opened in a new tab #}
|
||||||
{% if request.in_preview_panel %}
|
{% if request.in_preview_panel %}
|
||||||
|
|||||||
@@ -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>
|
<dt class="col-sm-3">Title</dt>
|
||||||
<dd class="col-sm-9">{{ content_asset.title }}</dd>
|
<dd class="col-sm-9">{{ content_asset.title }}</dd>
|
||||||
<dt class="col-sm-3">Description</dt>
|
<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>
|
<dt class="col-sm-3">Release date</dt>
|
||||||
<dd class="col-sm-9">{{ content_asset.release_date|default:"—" }}</dd>
|
<dd class="col-sm-9">{{ content_asset.release_date|default:"—" }}</dd>
|
||||||
<dt class="col-sm-3">Series / Collection</dt>
|
<dt class="col-sm-3">Series / Collection</dt>
|
||||||
@@ -72,4 +72,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
{% include 'includes/_tinymce.html' with selector="textarea#id_description" %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ dependencies = [
|
|||||||
"whitenoise~=6.11.0",
|
"whitenoise~=6.11.0",
|
||||||
"pytz~=2026.5",
|
"pytz~=2026.5",
|
||||||
"django-allauth[socialaccount]~=65.0.2",
|
"django-allauth[socialaccount]~=65.0.2",
|
||||||
|
"nh3==0.2.20",
|
||||||
]
|
]
|
||||||
dynamic = ["version"]
|
dynamic = ["version"]
|
||||||
|
|
||||||
|
|||||||
@@ -16,3 +16,11 @@ form.simpleform label {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.tox-tinymce div.tox-promotion {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
//span.tox-statusbar__branding {
|
||||||
|
// display: none;
|
||||||
|
//}
|
||||||
|
|||||||
Reference in New Issue
Block a user