Skip to content

Code plugin admin hardcodes URL to "ace" JS module #48

Closed
@greyhare

Description

@greyhare

Describe the bug
The Frontend "Code" plugin's admin templates have hardcoded URLs (including version numbers) for loading the JS for the "ace" module, which is used as a code editor. This breaks badly on systems without internet access.

To Reproduce
Steps to reproduce the behavior:

  1. Be offline, and have a properly setup development project, fully migrated.
  2. Run manage.py runserver as normal. Login as an admin, and edit a page. Add a Frontend Code plugin.
  3. In the admin pane that opens to edit the new plugin, there is just empty space next to "Code:". The plugin cannot be saved due to the missing field.
  4. Check Safari's debug console and see Failed to load resource: A server with the specified hostname could not be found. https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/ace.js

Expected behavior
Some kind of functioning code editor should appear. Or it should fallback to a textarea.

Screenshots
Not readily available due to network isolation, sorry.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser Safari
  • Version 15.6 (16613.3.9.1.7, 16613)

Additional context
The offending URL is in contrib/content/templates/djangocms_frontend/admin/code.html line 6:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/ace.js" integrity="sha512-6ts6Fu561/yzWvD6uwQp3XVYwiWNpWnZ0hdeQrETqtnQiGjTfOS06W76aUDnq51hl1SxXtJaqy7IsZ3oP/uZEg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

In django_bootstrap4, to solve a similar situation, I simply have to set the BOOTSTRAP4 setting, using code that looks something like:

BOOTSTRAP4 = {
    'css_url': f'{node_root}bootstrap/dist/css/bootstrap.css',
    'javascript_url': f'{node_root}bootstrap/dist/js/bootstrap.js',
    'jquery_url': f'{node_root}jquery/dist/jquery.js',
    'include_jquery': 'full'
}

I use npm to get Bootstrap (and jQuery and Popperjs) from our internal mirror. (Bootstrap5 doesn't use jQuery, but I do.)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions