Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
ebl_buildJs
Simple plugin that takes the javascript files located in your theme js directory and builds the script tags for them. Built on 4.9. Haven’t tested on anything lower. Works on my local install. I couldn’t stomach using the <txp:css> tag for javascript, so I hacked this together. Very loosely tested.
Aside: I really like the export functionality in 4.9
Offline
Re: ebl_buildJs
Cool! Nice idea to simply bring in all js from a specific directory. Thanks for developing this. I’ll check it out when I’m back at work next week.
I guess it could be extended for other asset types too, not just js. A question: How does it handle nested folders? e.g. a common structure for ES modules, or for dynamically loading js sub-packages as needed.
For the future, it would be great if one could incorporate a nonce in the script tag (see, for example, this discussion).
TXP Builders – finely-crafted code, design and txp
Online
Re: ebl_buildJs
It’s a quick and dirty first-draft proof of concept plugin. My ideal would be to have javascript alternatively embedded within the database, or optionally for especially large libraries, linked to files uploaded to the js directory, similar to what we do with images. Future work on this would allow that, and for loading scripts in a particular order.
Regarding the nonce? Probably not happening unless and until the code for it is finalized and documented in 4.9. I saw the github commit for it, but uh, don’t quite grok it yet.
Last edited by TheEric (2025-01-05 07:53:47)
Offline
Re: ebl_buildJs
TheEric wrote #338666:
My ideal would be to have javascript alternatively embedded within the database, or optionally for especially large libraries, linked to files uploaded to the js directory, similar to what we do with images. Future work on this would allow that, and for loading scripts in a particular order.
IIRC, that is what spf_js does. Not sure about the output order, though.
Regarding the nonce? Probably not happening unless and until the code for it is finalized and documented in 4.9. I saw the github commit for it, but uh, don’t quite grok it yet.
Yeah, I understand. The method you link to is for the admin side. That’s pretty easy to realise using the \Textpattern\UI\Style and \Textpattern\UI\Script classes (perhaps useful for your other plugin).
There’s not (currently) a corresponding flag for a public-side nonce. That’s partially what my GitHub issue was about. What you could do is provide a form
attribute along with a placeholder for the src
rather than hard-coded output, so that users could craft their own output. If you look in taghandlers.php you’ll see that various txp-internal tags have a form attribute as an alternative to default code output.
TXP Builders – finely-crafted code, design and txp
Online
Pages: 1