Skip to content

Commit 5d1fdfe

Browse files
committed
leveraging ckeditor and static url
1 parent d20bcfb commit 5d1fdfe

File tree

5 files changed

+7
-16
lines changed

5 files changed

+7
-16
lines changed

mod_app/static/ckeditor/ckeditor/plugins/popout/plugin.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ CKEDITOR.plugins.add("popout", {
77
var newWindow = window.open("", "_blank", "width=800,height=600");
88
// make sure new editor gets config
99
var originalConfig = editor.config;
10-
var ckeditorBasePath =
11-
"https://moddevbucket.s3.eu-west-2.amazonaws.com/static/ckeditor/ckeditor/";
10+
var ckeditorBasePath = `${editor.config.staticUrl}ckeditor/ckeditor/`;
11+
console.log("path", ckeditorBasePath);
12+
// "https://moddevbucket.s3.eu-west-2.amazonaws.com/static/ckeditor/ckeditor/";
1213
// styling and qol bits
1314
var btnStyle =
1415
"background-color: #23a1cc; border: none;border-radius: 4px; color: white; padding: 1rem 1.2rem; text-align: center; text-decoration: none; display: flex; font-size: 16px; margin: 0.8rem; cursor: pointer; justify-self: center";

mod_app/views.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import boto3
22
import re
3-
4-
import os
5-
from django.conf import settings
63
from django.contrib.auth.decorators import login_required
7-
from django.http import JsonResponse, HttpResponse
4+
from django.http import JsonResponse
85
from django.shortcuts import render
96
from django.template.defaultfilters import striptags
107
from django.views import View
@@ -128,12 +125,3 @@ def get(self, request):
128125

129126
def custom_404(request, exception=None):
130127
return render(request, "404.html", {}, status=404)
131-
132-
133-
def ckeditor_script(request):
134-
script_path = os.path.join(settings.STATIC_ROOT, "ckeditor", "ckeditor.js")
135-
136-
with open(script_path, "r") as script_file:
137-
script_content = script_file.read()
138-
139-
return HttpResponse(script_content, content_type="application/javascript")

museum_of_dreams_project/settings/aws.py

+2
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@
5757

5858

5959
S3_BROWSER_SETTINGS = "djangoS3Browser"
60+
61+
CKEDITOR_CONFIGS["default"]["staticUrl"] = f"{STATIC_URL}"

museum_of_dreams_project/settings/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
"filebrowserBrowseUrl": "/view_bucket_items/",
156156
"versionCheck": False,
157157
"language": "en-gb",
158+
"staticUrl": f"{STATIC_URL}",
158159
},
159160
}
160161

museum_of_dreams_project/urls.py

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
path("grappelli/", include("grappelli.urls")),
3030
path("grappelli-docs/", include("grappelli.urls_docs")),
3131
path("ckeditor/", include("ckeditor_uploader.urls")),
32-
path("ckeditor-script/", views.ckeditor_script, name="ckeditor_script"),
3332
path("admin/", admin.site.urls, name=admin),
3433
path("logout", LogoutView.as_view(next_page="/"), name="logout"),
3534
path(

0 commit comments

Comments
 (0)