Giter VIP home page Giter VIP logo

Comments (4)

pdelboca avatar pdelboca commented on July 28, 2024

I'm having the exact same issue. I tried to debug it today but couldn't find any reasonable solution. Looks like there is something wrong on how ckanext-pages is serving/accessing webassets.

I also don't understand why is appending /pages_edit/ when debug=False.

@smotornyuk any idea what is going on here?

from ckanext-pages.

smotornyuk avatar smotornyuk commented on July 28, 2024

Sure. Don't blame webassets, ckanext-pages just didn't configure CKEditor properly.

CKEditor is an enterprise solution. It comes with themes, plugins, and modules. How can CKEditor load modules in runtime? Probably, using some assumptions. For example, CKEditor may assume that plugin xxx will be available as public xxx.js file. Does it mean, that CKEditor should append the following tag to the page, whenever it enables the xxx plugin in runtime?:

<script src="/xxx.js">Cannot load xxx plugin for CKEditor</script>

Answer: almost. Not every system serves public files from the site root. From my experience, some /public/, /static/, /assets/ prefix is usually used. That's why CKEditor is trying to be smart(and it usually works). It checks the origin of ckeditor.js. It's almost safe to assume, that ckeditor.js is loaded from a public source, thus all its plugins can be loaded from the same path.

For example. if ckeditor.js is loaded from /x/y/z/ckeditor.js, it will try to load xxx.js from the same place - /x/y/z/ceditor.js.

And it works in debug mode because every file is loaded separately. ckeditor.js loaded from the public folder, available at the site root(/ckeditor.js), so do all the plugins.

What happens in production mode? All files are compiled into a single huge main.js. There are no more cketior.js. CKEditor cannot identify a public folder for the current portal. It searches for the source of the script that initialized CKEditor instead. Is it /webassets/ckanext-pages/main.js? Yes. Probably, it should load xxx plugins from /webassets/ckanext-pages/xxx.js then? No. All the plugins, translations, etc are not included in webassets and are not served by them. CKEditor has to load them from the public path(in your case unless you are using custom site root) it's /.

How we can tell CKEditor to use a custom public path? By setting global variable CKEDITOR_BASEPATH. For example, in this case, something like this will solve the problem:

<script>window.CKEDITOR_BASEPATH = "/"</script>   

You may want to use ckan.SITE_ROOT instead of hardcoding /, but in this case, you have to make sure, that CKAN's JS is loaded before your script.

from ckanext-pages.

pdelboca avatar pdelboca commented on July 28, 2024

Thanks for your answer @smotornyuk .

I'm just trying to understand what changed since this feature stop working when updating from 2.9 to 2.10. That's why I'm pointing to ckanext-pages registering or loading assets differently than before.

CKAN 2.9 with ckanext-pages v0.3.7:
Screenshot from 2023-06-07 12-05-07

CKAN 2.10 with ckanext-pages v0.5.1:

Screenshot from 2023-06-07 12-13-17

That's why I'm trying to get more insights on how webassets are handled. I'll keep looking into this!

from ckanext-pages.

smotornyuk avatar smotornyuk commented on July 28, 2024

I suspect, somebody has overriden this hack

from ckanext-pages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.