mikespub-org / seblucas-cops

Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...)
http://blog.slucas.fr/en/oss/calibre-opds-php-server
GNU General Public License v2.0
55 stars 7 forks source link

Kindle customize broken again #57

Closed dunxd closed 9 months ago

dunxd commented 9 months ago

Changing templates in the Kindle Experimental Browser has stopped working again - none of the cookies are getting changed.

I traced it back to 359f76b on the 19th Sept. In 57d6ddb it works.

If I restore util.js from 57d6ddb things start working again.

git restore -s 57d6ddb -- util.js

I'll look in more detail when I can.

mikespub commented 9 months ago

Well, Twig hasn't moved back since then, so the culprit is likely to be the 3rd parameter in initializeAjax(). But wasn't Kindle supposed to be using server-side rendering instead of client-side anyway? So perhaps it's the refresh on style change that broke it...

What kind of requests are you seeing in your server logs when you hit that page in COPS on Kindle?

dunxd commented 9 months ago

Yes - I've narrowed it down to the changes to initateAjax(). Default variable values in functions were introduced in ES6, and the old Kindles only support ES5. See #58

When browsing with the Kindle it is using server-side rendering, I haven't figured out how to get the php built in web server to show me more than what is requested, but given when server side rendering was broken I was initially seeing it on my Kindle so I am pretty confident.

Even with server side rendering, some functions in util.js are still required, and I expect any syntax error (as far as ES5 is concerned) might cause issues.

Given that it is possible to specify a different util.js for different templates, we could split off a separate Kindle template. How hard would it be to force that template if Kindle is detected ignoring all cookies? My next template is going to be something targetted at Kindle - I already have a name - kind2kindle.

dunxd commented 9 months ago

Here is a reference to some(all?) changes between ES5 and ES6. I guess there may be more to check since we are on ES15 now. :-| Not that I am suggesting you check. I'll be getting chatGPT to do that from now on.

mikespub commented 9 months ago

Thanks again for all the investigation. As I mentioned in #58 if we ever expand what's in util.js I would indeed consider splitting off an ES5 variant for very old e-readers, but right now I'm happy to keep it running ;-)