Howdy folks,
New here, but I come bearing gifts. I've just open-sourced Extendables, a small framework that simplifies ExtendScript coding. Check it out at http://extendables.org and the documentation at http://extendables.org/docs/.
Extendables isn't a whiz-bang does-everything-for-you kind of framework, but if you're doing any serious scripting, it will definitely make your life easier. It includes some of the newer Javascript 1.6+ Array methods like forEach, useful shortcuts/monkeypatches and modules for logging, HTTP connections and creating user interfaces. Plus a bunch of other stuff.
With the rise of server-side Javascript (you might've heard of node.js, Narwhal or Rhino), there's a growing number of libraries and frameworks out there which don't depend on a browser to work, so the timing felt right to tap into that ecosystem as well for our own profit. For example unit testing is provided by a slightly tweaked Jasmine, which is a great DOM-less Javascript testing framework.
Do note that this release is halfway between a teaser and a working product. Some parts aren't feature-complete, like the HTTP library. Other parts are experimental. There's no common style yet. The UI helpers have a domain-specific language vibe and so does the unit testing library. The HTTP library and a couple of other parts work entirely getter/setter-based (think jQuery). But in other parts I've tried to stay close to how ExtendScript works out of the box, so that it'd feel intuitive for long-time scripters.
It's pretty stable, but I've only been able to test it out on my own system (InDesign CS4 — that's all I have a license for), so I've labeled it an alpha release regardless.
If you're up for that, do feel free to contribute via GitHub, either by helping to flesh out the core framework, by reviewing the documentation or by making your own module packages. There's already a lot of collective wisdom and code snippets out there, and it probably wouldn't hurt to bring some of that together and release it as proper packages.
I guess what I'm saying is: try it out, skim through the docs, let me know what you like, don't like or would like to see. I'd be happy to keep in touch with any tester over Google Talk, mail or IRC, to help sort out any inevitable kinks you might encounter.
(I've put up a similar message over at my blog, but feel free to continue the conversation over here.)
Hi Stijn, and welcome to the party!
(Your extendables.org links return a 502 for now, but that may get fixed automagically.)
How does this work? I mean, not down to the nitty gritty internal details, but in practice -- is this a replacement for the system-wide Javascript parser? Can I write my scripts as usual, save them into ID's Scripts folder, and run them from within ID?
Yes, a little DNS issue that should magically disappear soon :-)
Extendables is actually a framework or a library, depending on how you use it. If you just include the extendables.jsx file at the top of a script, you get a bunch of extra methods on top of existing object prototypes (like String, Array, ...) and a couple of libraries you can load in using var lib = require("thislibrary"); So you don't need to change existing scripts: you just get a bunch of extra stuff that's there if you want it, or that you can ignore if you don't.
But you can also create your own libraries/modules, and those do need a certain directory and code layout to get picked up by Extendables. Modules serve mainly to be able to separate helper libraries from your actual script, and to be able to load those libraries using require(). The advantage to modules is mainly that you don't have to pollute your global namespace, because require() puts whatever functions and variables you make available inside of your module into a variable, whereas with #include, you never really know what you're getting unless you check the included file.
Hope that helps.
Stijn
Hi Stijn and welcome!
Nice work!
I've actually been doing some work myself recently on converting my personal UI library into something which can be consumed by the general public. Mine is more geared towards increased functionality and ease of creating standard elements. It's not as fine-grained as what you've done.
Harbs
Hi Marc,
Thanks! I tried to mail you earlier in the hopes you'd have some time to put up a short message on Indiscripts, but my message got rejected as spam so I guess that never reached you.
As it happens, I've been thinking about how to do jsxbins for larger projects, and for Extendables-based projects especially. #include statements are not be the biggest problem — require() and extract() statements probably are. I guess that's the drawback of the module loader system.
I've been working on a Python script that inlines every last bit of code, producing a single (huge) file that would contain Extendables, any other packages plus your own script files. It works by replacing every include, require and extract with the files it actually loads, as well as by expanding certain variables like $.fileName. Once you have that file, you can easily run it through the Google Closure Compiler and/or make a jsxbin out of that. I'm thinking of open-sourcing that script, though I'm still in doubt — I do have to make some money, after all :-)
First try here:
http://www.indiscripts.com/post/2010/11/my-first-extendables-script-fo r-indesign
(Unicode Character infos box using the Extendables' http library.)
Cool!
Marc
Hello,
I have been trying to use this framework with Indesign, but I am unable to get it working. I will appreciate your help on this. Below is the code that I am trying.
So far, what I have understood is that this framework does not work with any authentication parameters and I think I have seen some where that it's not yet implemented. Is that correct? If so, could some one help me on how would I be able to get this working?
Thank you so much for the help.
Indesign code:
| var auth=new Object(); | |
| auth.username="admin"; | |
| auth.password="admin"; | |
| var auth = { username:'admin', password:'admin'}; | |
| var response = http.get("http://localhost:4502/content/geometrixx/en/company/news/articles/jcr: content/par/text.html",auth,5); | |
| alert(response.body); | |
| if (response.status_code == 200) { | |
| alert(response.body); | |
| } else { | |
| alert("Connection failed"); | |
| } |
Result:
It fails at the runtime by pointing the ExtendScript debugger at the line number 137 in object.conversions.jsx. The line 137 is : throw RangeError("This method cannot convert from {} to {}".format(this.prototype.name, type));
Hey Krishna! Thanks for giving Extendables a try. That code looks correct. Could you file a bug report at https://github.com/stdbrouw/Extendables/issues? It'd also be very helpful to know what version of InDesign you're using, because that can make a big difference.
North America
Europe, Middle East and Africa
Asia Pacific
Copyright © 2012 Adobe Systems Incorporated. All rights reserved.
Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy (updated 07-14-2009).