Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Extendables: a framework for Adobe ExtendScript

Community Beginner ,
Nov 01, 2010 Nov 01, 2010

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 a similar message over at my blog, but feel free to continue the conversation over here.)

TOPICS
Scripting
10.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2010 Nov 01, 2010

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 01, 2010 Nov 01, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 01, 2010 Nov 01, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 01, 2010 Nov 01, 2010

JavaScript 1.6+, DOM shortcuts, CommonJS-type namespaces, unit testing, UI library... this framework seems to have all the right ideas!

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 01, 2010 Nov 01, 2010

Thanks Michiel and Harbs!

@Harbs: that's right on the money, the Extendables UI library makes UI development a little easier and faster, but its main purpose is to get rid of messy code that intermingles structure and presentation. I'm curious to see what you come up with.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2010 Nov 01, 2010

Nice work, Stijn!

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 06, 2010 Nov 06, 2010

This is an amazing and huge project!

Thanks for sharing 🙂

@+

Marc

[ Question: how behave Extendables' conditional #include directives when compiling a project as .jsxbin? ]

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 06, 2010 Nov 06, 2010

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 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 06, 2010 Nov 06, 2010

Hi Stijn,

Sorry for the rejection of your comment: Indiscripts spam filter is probably too harsh -- although I still get a lot of unfiltered ads...

Let's continue the discussion by email...

@+

Marc

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 07, 2010 Nov 07, 2010

Hi Stijn,

I can't wait to give your framework a try. I was getting sick using ESTK

As others pointed out, thanks for sharing you very expected project !

Loic

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 10, 2010 Nov 10, 2010

First try here:

http://www.indiscripts.com/post/2010/11/my-first-extendables-script-for-indesign

(Unicode Character infos box using the Extendables' http library.)

Cool!

Marc

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 07, 2011 Dec 07, 2011

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));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 07, 2011 Dec 07, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 07, 2011 Dec 07, 2011

Cool, thanks. I have just seen your post already there as a feature request. I did reply to your post and also added a new issue too. Also, I want to know when this will be implemented and do you know whom do I need to talk to on this?

Thanks so much for the help,

Murali

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 07, 2011 Dec 07, 2011

Honestly, I don't know. It would probably be a quick fix and I intend to do a round of bugfixing at some point in the not-so-far feature, but I'm currently not doing any InDesign scripting professionally, so it's kind of at the back of my list of priorities. Sorry.

Stijn

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 02, 2015 Apr 02, 2015

Stijn Debrouwere wrote:

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.

I see the project URL is now debrouwere/Extendables · GitHub instead? The original repo just redirects to this new one.

Also, is the issue tracker removed here for some reason? There are only pull requests and nowhere to view or create issues.

Would be good to know which forks are most active if this project hasn't been active anymore. Though 39 forks to look through is a lot.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 21, 2015 Mar 21, 2015

Hi,

i love the framework very much! Currently i have problems with the download of a webservice´s response if it contains chinese and thai characters.

I use http.get(...) and then new File with encoding UTF-8 and write byteOrderMark \uFEFF and unix linefeed. Always the chinese / russian or thai characters

are discontinued/broken somewhere in the middle and then the xml cloing tag of this text is missing.

What is the preferred way for download and local save of such content? Does http.get support this wide unicode characters?

Many regards,

Sven

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 02, 2015 Apr 02, 2015

(I've put up a similar message over at my blog, but feel free to continue the conversation over here.)

I notice the blog post has no section for comments. And Github has no "discussion" capability. So I assume continuing conversation about Extendables would be via Twitter, or email, found on your about page of your blog? If not discussing here that is.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 13, 2016 Feb 13, 2016
LATEST

Pretty cool idea. I checked your library and I saw a lot of useful things.

Anyway I had something else in mind. Something a web developer could work with and I didn't see stuff like that in your library (while quickly scanning, maybe you have things like that?)

IMO, ExtendScript for Photoshop is really in need of short easy functions.

Example:

select("layername").move(100,100);

select("layername").dup().move(200,200);

More like jQuery thing with Photoshop layers.

Here is the code I wrote for it (Its badly written, but I wasn't really trying)

function select(name) {

    var doc = app.activeDocument; var o;

    if (typeof name == "object") o = name;

    if (typeof name== "undefined") o = doc.activeLayer;

    if (typeof name=="string") o = doc.artLayers.getByName(name);

    o.move = function (fX,fY) {

      fLayer = this;

      var Position = fLayer.bounds;

      Position[0] = fX - Position[0];

      Position[1] = fY - Position[1];

      fLayer.translate(-Position[0],-Position[1]);

    }

    o.dup = function() {

       var z = this.duplicate();

       return select(z);

       }

  return o;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines