473,320 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

js -> REST API mapping

I'm looking for advice. I have been playing with Konfabulator which
embeds SpiderMonkey (apparently using the JavaScript 1.5 api) for
scripting "widgets" - various bits of eye candy that sit on your
desktop.

One widget I would like to build is a display of a person's flickr
photostream. Flickr has a nice API, available via REST, XML/RPC, and
SOAP. I'd like to map the flickr API to javascript, having it do url
fetches and parsing the resultant XML results "behind the scenes", but
I don't want to manually create every function, especially since there
would be a huge amount of redundancy in doing so. The scheme
programmer in me immediately reaches for macros, but it does not appear
that JavaScript has macros. It does appear to have first-order
functions, so my gears are still turning.

So my idea is to build an array of function names (as strings), args
(as an array of objects), and xpath expressions (as strings) and
somehow dynamically generate the necessary functions at load time. I'm
a bit stumped on how to get these functions to be available at the top
scoping level. I'm going to sit down with the ECMAScript ed. 3 spec
tonight, but, again, am interested in general advice.

Does anyone have any suggestions on a) how to do this or even better b)
other, better ideas on making this REST api available seamlessly via
JavaScript?

Jul 27 '05 #1
1 1627
jk******@gmail.com wrote:
I'm looking for advice. I have been playing with Konfabulator which
embeds SpiderMonkey (apparently using the JavaScript 1.5 api) for
scripting "widgets" - various bits of eye candy that sit on your
desktop.

One widget I would like to build is a display of a person's flickr
photostream. Flickr has a nice API, available via REST, XML/RPC, and
SOAP. I'd like to map the flickr API to javascript, having it do url
fetches and parsing the resultant XML results "behind the scenes", but
I don't want to manually create every function, especially since there
would be a huge amount of redundancy in doing so. The scheme
programmer in me immediately reaches for macros, but it does not appear
that JavaScript has macros. It does appear to have first-order
functions, so my gears are still turning.
I understand little of what you're saying, but I gather that you need
to either use a small number of functions to perform lots of tricks but
have a large number of names, or logically create a large number of
functions to each do a single, slightly different trick?

well...

Synopsis:
x = function ( arg1, arg2 ) {
// a function that does a large number of things, depending on args
}

y = x; // What's in a name?
z = x; // Just a reference, really.

x = 'code' +
'more code' +
'even more code!';

y = new Function( 'arg1', 'arg2', x );
z = new Function( 'arg1', x + 'still more code' );
So my idea is to build an array of function names (as strings), args
(as an array of objects), and xpath expressions (as strings) and
Don't know what an xpath is, but hey-- why use an array of function
names (as strings) when you can use an array of functions (as
references)?

x = [
function ( args ) { /* things that we do */ },
function ( args ) { /* other things that need doing */ },
function ( args ) { /* so much to do... */ }
];

x[0]( args ); // things that we do
x[1]( args ); // other things that need doing
somehow dynamically generate the necessary functions at load time. I'm
a bit stumped on how to get these functions to be available at the top
scoping level. I'm going to sit down with the ECMAScript ed. 3 spec
tonight, but, again, am interested in general advice.
See Synopsis above.
Does anyone have any suggestions on a) how to do this or even better b)
other, better ideas on making this REST api available seamlessly via
JavaScript?


Don't know the API, but hopefully the Synopsis helps.

It occurs to me that you might be trying to call functions in the API
by using same-named functions in JS.

REST = {
call: function ( fname, fargs ) {
// do the call for fname using fargs
// however it is that REST actually does these things
// Use other properties of your new REST object as needed
}
}

REST.call( 'get', [ thing1, thing2 ] );


Hopefully that helped you in some way.

Jul 28 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Richard Shea | last post by:
Hi - Is there a tool available which given a set of PHP scripts will analyse them and show you which function is called by which other function ? I'm looking for something which would allow me to...
2
by: Edward Patrick | last post by:
Hello, I would like to have one servlet serve all requests that do not require any "processing". For example, CSS's, JPG's, etc. I know I can accomlish this with an entry in WEB.XML: ...
18
by: Nicola Mingotti | last post by:
Hi , I obtained this result : ------ >>> '1' > 1 True ------ with python2.2.3 and 2.3.3 . (Yes , in python 2.2 i get 1 instead of True)
4
by: Heejeong Lee | last post by:
I am going to begin following project Description of the project: One of the proposed ways of storing XML is to "shred" the structure of the XML document and insert it into a relational...
1
by: Tommy | last post by:
I'm new to database design and management. I'm presently taking a course in this area. At the moment I just wanted to know when you have the following relationship: Entity 1...
1
by: Mike Strieder | last post by:
How can i get the text of the System.Type e.g. "base64Binary" from the .Net type "byte" I can not found any Function to give back this Schematype as string. thx for your help
26
by: myeates | last post by:
Hi Anyone ever done this? It looks like Python2.4 won't take a length arg Mathew
7
by: Electric Co. | last post by:
Hello, note: This is for a Faculty web site that is undergoing a migration to an open source solution so my motives are legit. I need to build a relay from IIS handling URL_A to a PHP server...
2
by: David Thielen | last post by:
Hi; I have a small XML file that I need to read/change from my app. Is there some easy way to map from XML to my objects so I can just read it in to my objects, change the objects as needed,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.