views:

759

answers:

5

We want to create a widget platform for a particular website.

I couldn't find any articles on doing this, but what I need right now is for someone to point me in the right direction.

What framework should we use? I am proficient with RoR, and okay with Java/.Net, but I don't know if doing this in rails is easy because I can't see how this will be like the usual web application.

A lot of widget platforms allow third party developers to use Javascript. How easy will this be, will we have to create a interpreter or something like that?

What kind of architecture should we follow? Do we store widgets in the database?

A: 

What exactly are you trying to do?

Is your website new? or does it already exist in a certain enviroment?

I would suggest that you might construct your page from an xml template, and use some sort of custom sax parser to replace references to widgets with chunks of html on the server, you could use xslt, but I suspect it would be easier to invoke arbitrary code with the sax parser.

I like java, because that's my space, but I'm sure ruby and .net to creditable jobs of simple dom manipulations.

3rd party developers could provide the above-mentioned chunks of html, with included script-tags to provide whatever functionality they want.

NSherwin
We're actually working on a prototype, so while the website already exists, we can also create our own mockup.I am assuming you are talking about a server side sax parser, to work with third party widgets, which we can allow to invoke arbitrary code, perhaps using a tag library interface similar to JSTL?I'm getting a better idea of the general direction to take, but I will wait a bit more before I pick the best answer. Thanks!
Jaryl
+1  A: 
Alexander Kosenkov
By the way - you just *can not* allow pepole to submit any <script> tags to your server. This is extremely dangerous for website visitors' security
Alexander Kosenkov
Understood. Anyway, I've looked at Portlets, and they look like a a pretty good fit for what we're doing. I'd want to see how easy it is to build something given that it is a prototype.
Jaryl
A: 

I guess the questions I have are:

  • What do you mean by widget, and

  • What do you mean by "From Scratch"?

If by "from scratch" you mean you don't want to just skin previously existing widgets, I would start by picking a javascript framework that met your specs (jquery, dojo, aria, etc.) and then seeing if they can stretch as far as you can push them. (this is assuming you don't mind the widgets being open-source. Also that you can either make up for any lack of accessibility or don't see that as an issue.)

I would not rely on server-side for more than outputing the code, saving changes, and loading saved data for the widget. If you are already going to need ajax to pass interactions from the client to the server, why stall out the widget making the server pay attention to the other mechanics of the widget?

I would not use Java, but for the same reason NSherwin would. It's not my forte. But I also think that we are moving beyond the reliance on compilers and full-blown apps for getting things executed on the web. Java will have it's place for the foreseeable future, but we don't need to lean on it (or Flash, for that matter) when our browsers (and developers!) can do the work faster and with less overhead. (Not to mention that this could HELP accessibility and usability. Think mobile phones not needing a special app for viewing Facebook or Twitter!)

All of this changes a bit based on my first question: What do you mean by widget? If you mean an appointment calendar, or a photo frame, or countdown timer (God, I'm boring, sorry), then keep everything I said above in mind. Use php or RoR to generate the code, js via a good framework to make it tick, and ajax to either xml to MySQL to handle interactions beyond event handling.

But if what you want is a widget for visitors to play pac-man, or design their dream home floorplan, or something really math/graphics heavy, I would then bow out to those who know a lot more than I do about Java/Flash. I think the day is coming where I can bang a drum even in those cases, but getting something even close today is not worth the man-hours.

Here is something I am currently struggling with that may help refine your needs...

Let's imagine a widget like the Southwest Airlines Ding! desktop widget, but on the web. It will alert you the moment a good deal comes up. Time is of the essense because there are limited spots. Do you have the browser query the server every half-second to see if there is an update? Do you set up a DB that, on update, sends out a crontask to the server to run a script that updates an xml file that is much easier for the browser to check for filesize changes? And all of this so that the user can here a DING without having to hit refresh (which would probably produce a less-efficient version of the same strain on the server)?

I have a js script that queries the cookie for the active page every half-second so the user get's a warning when they are about to be kicked out. I'm sure there is some event listener that could maybe eliminate the need for looping, but is there an equivalent for when something happens on the server and the browser is just hanging out?

Just my thoughts on widgets and web-apps. Hope it was helpful.

Anthony
I'm very much inclined to roll my own, since in our case, learning is one of objectives of this project. That being said, I hope that 10 weeks would be enough to come up with a quick and dirty prototype.
Jaryl
A: 

You are looking for http://jswaf.googlecode.com/

I'm a co-author of that tool... But the version of it available online is way out of date.

I have a much better version available on my home computers, but unfortunately I can't access it for the next two months :(


If you want to write a framework of your own from scratch, even the version availbale online now will give you a pretty good idea of how to go about it.

Yea, you are right: to create a runtime widget, you need to use interpreters. Fortunately, youcan directly use the javascript interpreter available in the browser.

Its all in JSWAF's code.

Please do send in comments about JSWAF, especially if you find something goofy about it.

Cheers, jrh.

Here Be Wolves
You do finally use the interpreter in the browser, but don't you have to parse and potentially change the resulting Javascript? You may want to place certain limits for security, or give widget developers some special functions or something.
Jaryl
Yes. The interpreter is just the javascript interpreter in the browser. About the special functions for the developers, there are some that help widgets interact with other widgets in a very "orthogonal and controlled" way. But there are no special security features in place.. partly coz there is no cross-domain javascript involved: all the widgets are under the site owner's control.
Here Be Wolves
A: 

I've created own widget set for my projects not long ago. It was not bad. On the other hand it wasn't as good as ExtJS, so I moved finally to this widget set recently. For your purposes, please take a look at Ext-GWT widget library.

Thevs