greenrivers / grav-plugin-webp

Grav Webp plugin.
MIT License
11 stars 0 forks source link

Path issues with custom admin routes #14

Closed diegomagikal closed 5 months ago

diegomagikal commented 5 months ago

Hi,

The plugin admin buttons don't work with custom admin routes or custom server paths, getting a 404 error.

I took a look at progressbar.js and I noticed the admin path is static, like:

 $.ajax({
            url: '/admin/plugins/webp/images',
            type: 'GET'
        }).

I usually change the admin route value on all my websites for security reasons (ex: /admin123), and my server URL is something like https://localhost/sites/foobar, so my final admin URL is https://localhost/sites/foobar/admin123, and not https://localhost/admin as your script suggests.

I think you could implement something like

<script> var adminroute = {{ base_url|e ~ config.plugins.admin.route }};</script>

in your twig files to pass the correct URL to JavaScript.

MajorKuprich commented 5 months ago

Hello @diegomagikal,

Thanks for Your report. As I noticed in grav-plugin-admin there is a place where admin route is defined (depends on config): https://github.com/getgrav/grav-plugin-admin/blob/develop/themes/grav/templates/partials/javascript-config.html.twig#L15 So I used window.GravAdmin.config to fix this problem.

Fixed in new release. Related commit: https://github.com/greenrivers/grav-plugin-webp/commit/3e330d18edd4044798fe03997a0cce5e8a3abe20

I would welcome Your feedback. :-)

diegomagikal commented 5 months ago

It worked, thanks :-)