2024-11-16-Saturday


created: 2024-11-16 10:51 tags: - daily-notes


Saturday, November 16, 2024

<< Timestamps/2024/11-November/2024-11-15-Friday|Yesterday | Timestamps/2024/11-November/2024-11-17-Sunday|Tomorrow >>


🎯 Goal


🌟 Results


🌱 Next Time

  • Design CKeditor 5 layout for handling blog posts
  • Configure CKeditor 5 image uploading files (process outlined here) to match the uploading structure I was previously using with CKeditor 4.

📝 Notes

I'm trying to configure a custom page to handle 400 Errors. Unfortunately, since DEBUG=True in my local it gives me the standard page instead of my custom page:

--redacted--

Which now gives me the following error:

You're accessing the development server over HTTPS, but it only supports HTTP.

This was assisted by checking the ALLOWED_HOST in my config/settings.py:

# Force re-routing to secure (SSL) domain version using the SecurityMiddleware
if not DEBUG and '127.0.0.1' not in ALLOWED_HOSTS and 'localhost' not in ALLOWED_HOSTS:
    SECURE_SSL_REDIRECT = True
else:
    SECURE_SSL_REDIRECT = False

I also made sure to open the browser in incognito mode so that it didn't force the site into the SSL Encryption redirect. Now I can at least check the error pages:

--redacted--

I was able to configure this by explicitly specifying the path to the Django Template in the Django Route (i.e templates/maintenance/404.html). Now I finally have a custom 404 page!

--redacted--

I also added a page for 403 errors.

--redacted--

Now it's officially live on the Production server, nice!

--redacted--

This looks much nicer. A custom maintenance page isn't as necessary currently so I'll prioritize more high-value issues.

Next, I want to upgrade my CKeditor version to resolve the Update CKeditor Issue. I'm getting the following error from CKeditor:

This CKEditor 4.22.1 version is not secure. Consider [upgrading to the latest one](https://ckeditor.com/ckeditor-4-support/), 4.25.0-lts.

I upgraded to django-ckeditor version 6.7.1 and saw the following message when I ran my local dev server:

(ckeditor.W001) django-ckeditor bundles CKEditor 4.22.1 which isn't supported anmyore and which does have unfixed security issues, see for example https://ckeditor.com/cke4/release/CKEditor-4.24.0-LTS . You should consider strongly switching to a different editor (maybe CKEditor 5 respectively django-ckeditor-5 after checking whether the CKEditor 5 license terms work for you) or switch to the non-free CKEditor 4 LTS package. See https://ckeditor.com/ckeditor-4-support/ for more on this. (Note! This notice has been added by the django-ckeditor developers and we are not affiliated with CKSource and were not involved in the licensing change, so please refrain from complaining to us. Thanks.)

I was able to find a Stack Overflow Post that covered this exact issue. Thankfully, this github article covers exactly how to install / upgrade the editor to CKeditor 5. First, I uninstalled django-ckeditor via

pip uninstall django-ckeditor

then I installed django-ckeditor-5 via

pip install django-ckeditor-5

And froze the pip requirements via

pip freeze > requirements.txt

I followed the instructions here, but still needed a way to configure the Database Migrations due to how integrated the CKeditor RichTextUploadingFields were integrated into the construction of my Blog App's Blog Post models. Specifically, the first blog/migrations/0001_initial.py includes the line right at the top:

import ckeditor_uploader.fields

Which is no longer available. I modified my migrations to switch to the new CKeditor 5 field:

import django_ckeditor_5.fields

('project_description', django_ckeditor_5.fields.CKEditor5Field()),

Not sure I like the current options / layout for the new Ckeditor but it is available which is nice:

--redacted--

Of course the words are tough to read so I'll need to play with the CKEDITOR_5_CONFIGS.

It looks like I can specify different text editors for different places based on what I'm seeing in the CKEDITOR_5_CONFIGS dictionary. Specifically, I've been passing in the "default" context for all of my Django Models' ckeditor fields. For instance in my blog/models.py file I'm establishing the tagline to use the "default" for the config_name parameter:

tagline = CKEditor5Field(name='tagline', config_name="default"),

but that just seems to configure the editor to one type which is whatever params I established for "default". I could also have a custom rich text editor for say, comments as mentioned in the configs provided in github example:

"comment": {
        "language": {"ui": "en", "content": "ar"},
        "toolbar": [
            "heading",
            "|",
            "bold",
            "italic",
            "link",
            "bulletedList",
            "numberedList",
            "blockQuote",
        ],
    },

This allows me to have two different types of editors, one for taglines and another for actually writing out the blog posts:

--redacted--

There is still much more to configure here but I'll leave that for another time. For instance, while files are still uploaded they are just dropped into the same bucket here:

--redacted--

This should be in the /uploads folder, but it won't be handled the same way that logic was handled in CKeditor version 4. I'll have to resolve this as well as design the editor I use for my layout which could be fun. I'll leave those for next time.


Notes created today

List FROM "" WHERE file.cday = date("2024-11-16") SORT file.ctime asc

Notes last touched today

List FROM "" WHERE file.mday = date("2024-11-16") SORT file.mtime asc

(Template referenced from Dann Berg, can be found here)


Previous Note 2024-11-15-Friday Next Note 2024-11-17-Sunday