fix: TinyMCE lokal bereitstellen und Rich-Text-Migration ergänzen
This commit is contained in:
@@ -15,7 +15,7 @@ Ein in NetBox integriertes Markdown-Wiki für Betriebsdokumentationen und Anleit
|
|||||||
|
|
||||||
## Kompatibilität
|
## Kompatibilität
|
||||||
|
|
||||||
Die Version `0.2.0` zielt auf NetBox 4.x (mindestens 4.0). Vor einem produktiven Rollout sollte das Plugin gegen die konkret eingesetzte NetBox-Minor-Version in einer Testinstanz geprüft werden.
|
Die Version `0.2.1` zielt auf NetBox 4.x (mindestens 4.0). Vor einem produktiven Rollout sollte das Plugin gegen die konkret eingesetzte NetBox-Minor-Version in einer Testinstanz geprüft werden.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -64,7 +64,6 @@ PLUGINS_CONFIG = {
|
|||||||
"netbox_documentation": {
|
"netbox_documentation": {
|
||||||
"max_import_size_mb": 25,
|
"max_import_size_mb": 25,
|
||||||
"keep_imported_file": True,
|
"keep_imported_file": True,
|
||||||
"editor_script_url": "https://cdn.jsdelivr.net/npm/tinymce@7/tinymce.min.js",
|
|
||||||
"allowed_object_types": [
|
"allowed_object_types": [
|
||||||
"dcim.region",
|
"dcim.region",
|
||||||
"dcim.site",
|
"dcim.site",
|
||||||
@@ -79,7 +78,7 @@ PLUGINS_CONFIG = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Der Rich-Text-Editor wird standardmäßig über jsDelivr geladen. In abgeschotteten Netzen kann TinyMCE 7 lokal unter NetBox `STATIC_ROOT` bereitgestellt und `editor_script_url` auf die interne URL gesetzt werden. Das verwendete TinyMCE wird im GPL-Modus betrieben. Kann das Script nicht geladen werden, bleibt als Rückfall ein normales HTML-Textfeld verfügbar.
|
TinyMCE wird als Python-Abhängigkeit des Plugins installiert und durch `collectstatic` lokal bereitgestellt. Der Editor benötigt deshalb weder Zugriff auf ein CDN noch einen API-Key. Das verwendete TinyMCE wird im GPL-Modus betrieben. Kann das Script nicht geladen werden, bleibt als Rückfall ein normales HTML-Textfeld verfügbar.
|
||||||
|
|
||||||
Danach die Migrationen und statischen Dateien aktualisieren und NetBox neu starten:
|
Danach die Migrationen und statischen Dateien aktualisieren und NetBox neu starten:
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ class DocumentationConfig(PluginConfig):
|
|||||||
name = "netbox_documentation"
|
name = "netbox_documentation"
|
||||||
verbose_name = "Dokumentation"
|
verbose_name = "Dokumentation"
|
||||||
description = "Wiki und Office-Dokumentation direkt in NetBox"
|
description = "Wiki und Office-Dokumentation direkt in NetBox"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
author = "NetBox Documentation Contributors"
|
author = "NetBox Documentation Contributors"
|
||||||
base_url = "documentation"
|
base_url = "documentation"
|
||||||
min_version = "4.0.0"
|
min_version = "4.0.0"
|
||||||
|
django_apps = ["tinymce"]
|
||||||
default_settings = {
|
default_settings = {
|
||||||
"allowed_object_types": [
|
"allowed_object_types": [
|
||||||
"dcim.region", "dcim.site", "dcim.location", "dcim.rack",
|
"dcim.region", "dcim.site", "dcim.location", "dcim.rack",
|
||||||
@@ -17,8 +18,6 @@ class DocumentationConfig(PluginConfig):
|
|||||||
],
|
],
|
||||||
"max_import_size_mb": 25,
|
"max_import_size_mb": 25,
|
||||||
"keep_imported_file": True,
|
"keep_imported_file": True,
|
||||||
# Can be replaced with a locally hosted TinyMCE bundle for offline use.
|
|
||||||
"editor_script_url": "https://cdn.jsdelivr.net/npm/tinymce@7/tinymce.min.js",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class Migration(migrations.Migration):
|
|||||||
("custom_field_data", models.JSONField(blank=True, default=dict, encoder=netbox.models.features.CustomFieldJSONEncoder)),
|
("custom_field_data", models.JSONField(blank=True, default=dict, encoder=netbox.models.features.CustomFieldJSONEncoder)),
|
||||||
("title", models.CharField(max_length=200)), ("slug", models.SlugField(max_length=200, unique=True)),
|
("title", models.CharField(max_length=200)), ("slug", models.SlugField(max_length=200, unique=True)),
|
||||||
("body", models.TextField(blank=True, help_text="Markdown")), ("summary", models.CharField(blank=True, max_length=500)),
|
("body", models.TextField(blank=True, help_text="Markdown")), ("summary", models.CharField(blank=True, max_length=500)),
|
||||||
("body_format", models.CharField(choices=[("html", "Rich Text"), ("markdown", "Markdown")], default="html", max_length=10)),
|
|
||||||
("is_published", models.BooleanField(default=True)),
|
("is_published", models.BooleanField(default=True)),
|
||||||
("tags", models.ManyToManyField(blank=True, related_name="netbox_documentation_document_items", to="extras.tag")),
|
("tags", models.ManyToManyField(blank=True, related_name="netbox_documentation_document_items", to="extras.tag")),
|
||||||
], options={"ordering": ("title",), "permissions": (("import_document", "Can import office documents"),)}),
|
], options={"ordering": ("title",), "permissions": (("import_document", "Can import office documents"),)}),
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [("netbox_documentation", "0001_initial")]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="document",
|
||||||
|
name="body_format",
|
||||||
|
field=models.CharField(
|
||||||
|
choices=(("html", "Rich Text"), ("markdown", "Markdown")),
|
||||||
|
default="html",
|
||||||
|
max_length=10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
{% extends 'generic/object_edit.html' %}
|
{% extends 'generic/object_edit.html' %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script src="{{ config.editor_script_url }}" referrerpolicy="origin"></script>
|
<script src="{% static 'tinymce/tinymce.min.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
if (typeof tinymce === 'undefined') {
|
if (typeof tinymce === 'undefined') {
|
||||||
|
|||||||
+2
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "netbox-documentation"
|
name = "netbox-documentation"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
description = "Integrated Markdown wiki and office document importer for NetBox"
|
description = "Integrated Markdown wiki and office document importer for NetBox"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
@@ -16,6 +16,7 @@ dependencies = [
|
|||||||
"tabulate>=0.9,<1",
|
"tabulate>=0.9,<1",
|
||||||
"bleach[css]>=6.2,<7",
|
"bleach[css]>=6.2,<7",
|
||||||
"markdown>=3.7,<4",
|
"markdown>=3.7,<4",
|
||||||
|
"django-tinymce>=5,<6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
|
|||||||
Reference in New Issue
Block a user