kwebio / kweb-core

A Kotlin web framework
https://docs.kweb.io/book
GNU Lesser General Public License v3.0
969 stars 57 forks source link

Add option to self-host toastify #347

Closed floscher closed 2 years ago

floscher commented 2 years ago

When I played around a bit with kweb, I noticed that the page I built makes requests to the 3rd party service JsDelivr.

I would like it if the app relied on as few external services that were hardcoded into it, like Jsdelivr.net in these places: https://github.com/kwebio/kweb-core/blob/14a72c8e378c8285a8480e547005ccd15e1aa101/src/main/kotlin/kweb/html/HtmlDocumentSupplier.kt#L42 https://github.com/kwebio/kweb-core/blob/14a72c8e378c8285a8480e547005ccd15e1aa101/src/main/kotlin/kweb/html/HtmlDocumentSupplier.kt#L56

Since these links always download the latest available version, this could also over time lead to issues when a new toastify version comes out. Then apps built with kweb would automatically switch to the new version with which they might not have been tested with.

So I think there should be an option to at least override where these files are loaded from. Or maybe toastify could be packaged at build time with my app and served through my own backend.

This might not be the optimal solution for everyone, some probably prefer to use a CDN for such files, but I often prefer to self-host these things to be on the safe side regarding privacy and availability of the service, even if it impacts performance a bit.


Thanks for the great project, love the idea. I'll definitely play around with it some more, looks really promising so far!

sanity commented 2 years ago

I agree we shouldn't be using a CDN here, we should put it in src/resources and load it using the StaticFilesPlugin, similar to how the fomanticUIPlugin does it, although it shouldn't be a plugin because it's required by default.

sanity commented 2 years ago

I'm not sure when I'll get to this but if you'd like to take a stab at making the change I'd be happy to provide pointers and accept a pull request. If you need this urgently and don't think you can tackle it yourself let me know.

sanity commented 2 years ago

This is deployed in 1.0.1.

floscher commented 2 years ago

@sanity Thank you very much for fixing this so quickly! :rocket: