Can you dynamically create action-file parameters?

I was just working on the problem of scooping up all in-head JavaScript and pushing it out to external files. To be clear, I’m not looking at grabbing the Freeway-generated “one script block to rule them all” that’s created by head.fwAddJavaScript() – I’m actually being more surgical, looking for script blocks added by other Actions that have a defined ID, scripts which were created by head.fwAdd(‘script’, true);.

The issue is that I cannot know how many other scripts may be on the same page, and I have no idea what they may name one another, so I can’t just stuff a bunch of file refs in the Action and assign them as I need them. (I suppose I could, but that would be icky on many different levels.)

Is there a way to push new action-file elements onto the fwParameters stack during an Action’s publish loop? Ideally I’d like to have a “find_or_create_file_parameter(name)” function if such a thing is possible.

Thanks in advance,

Walter


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Walter,
I’m hoping I’m wrong but I don’t think this is possible at the moment and you can’t dynamically allocate and use controls at run time. I would be a real bonus to be able to do this without having to write 500+ Action controls to handle file uploads. I’ve done this in the past and it is a pain to get up and running as well as slows Freeway down as it has to handle all of those hidden elements in the UI.

From your description it sounds like the Externalize Action does the same sort of ‘hunt and gather’ process and does so by searching for script tags in the page. This should find most script blocks that were added by the application or like-minded Actions. Actions that write their code to the page as text, there are still a few, will be missed.

One of the things that I found myself longing for a few months ago with a client Action I was creating was the ability for one Action to be able to dynamically apply another to a page, folder or item. In the end I had to duplicate one of my other Actions into the second Action. If, however, you had a page Action that could be applied multiple times then you could apply this and attach your file(s) to that for upload. A single, simple, Action could handle any number of uploads for you.

Back to your question… if all of the Actions you wanted to track placed variables in a known form into fwPage then you may be able to look for these and determine how many scripts you are looking for. I don’t think there are Action footprints that you can look for in the code that would naturally allow you to extract these scripts in a way that you want.

Are you looking to create an external script resource for each script on the page (one for carousel, another for lightbox etc)? Splitting the code up into functions and lines would be easy but without looking for code signatures I don’t know how you would group them into logical groups.
Regards,
Tim.

On 2 Jan 2013, at 17:06, Walter Lee Davis wrote:

I was just working on the problem of scooping up all in-head JavaScript and pushing it out to external files. To be clear, I’m not looking at grabbing the Freeway-generated “one script block to rule them all” that’s created by head.fwAddJavaScript() – I’m actually being more surgical, looking for script blocks added by other Actions that have a defined ID, scripts which were created by head.fwAdd(‘script’, true);.

The issue is that I cannot know how many other scripts may be on the same page, and I have no idea what they may name one another, so I can’t just stuff a bunch of file refs in the Action and assign them as I need them. (I suppose I could, but that would be icky on many different levels.)

Is there a way to push new action-file elements onto the fwParameters stack during an Action’s publish loop? Ideally I’d like to have a “find_or_create_file_parameter(name)” function if such a thing is possible.


FreewayActions.com - Freeware and commercial Actions for Freeway Express & Pro - http://www.freewayactions.com


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks for the confirmation, Tim. I hope to be able to do this some day too.

Ruby has this amazing master method (function in Ruby-ese) called method_missing(). Basically, it’s how all metaprogramming works in Ruby. You call a method that just doesn’t exist, like Person.find_by_star_wars_name(). That method isn’t written down anywhere, but there is a Person#star_wars_name() method, so method_missing says “I understand what find_by means”, then starts hunting up the inheritance chain for the rest and puts it together. That’s actually a very simplistic example, but I’ve only had a few sips of coffee.

It would be nice if fwParameters could gain some smarts like this, and would just assume that if you create a key on the main hash of parameters, you can store something there without having to declare it as an action-parameter of one sort or another first.

Walter

On Jan 3, 2013, at 6:33 AM, Tim Plumb wrote:

I’m hoping I’m wrong but I don’t think this is possible at the moment and you can’t dynamically allocate and use controls at run time.


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options