PBI - emulate WebDialogs in a browser?
-
Although I've been able to use a browser (eg, Safari) to debug HTML, CSS, and JavaScript content stored in static files, I can't do this with dynamically loaded content. Nor can I test things that depend on communication between Ruby and JavaScript code.
So, I'd like a way to emulate WebDialogs in a browser. My Partly-Baked Idea (PBI) goes something like this:
-
Create a simple HTML/JS file for testing (eg, a header and a checkbox, where the checkbox is supposed to control the color of the header, via a Ruby round trip). Wrap the "location=" call in a JS method, for flexibility.
-
Get the file working with a SketchUp plugin, using callbacks, etc.
-
Get the file working with a simple web app, using (say) Rack or Sinatra.
-
Find a way to emulate the needed parts of the web app under SketchUp.
-
Fold the emulation code into the WebDialog class.
Comments, clues, suggestions?
-r
-
-
I have some encouraging progress to report. I now have a proxy server, based on EventMachine, that works on Mac OS X 10.5.8 (Mac Pro).
The server should be able to provide asynchronous communication between a SketchUp plugin and JavaScript code in any browser capable of handling WebSockets (eg, Chrome, Safari). See my wiki pages for more information:
- http://cfcl.com/twiki/bin/view/Projects/SketchUp/WD_WoR_BrowserDialog - project overview
- http://cfcl.com/twiki/bin/view/Projects/SketchUp/WD_WoR_BD_Server - server details
I'm now getting ready to create some Ruby and JavaScript methods to emulate the WebDialog API. I'll report any substantial progress if and when it occurs...
Meanwhile, I'd love to have someone try out the proxy server on something other than a Mac. Aside from letting me know about (and possibly resolve) portability issues, this could help me to create setup and usage notes for Windows, WINE, etc.
-r
-
I now have a BrowserDialog class which lets me emulate a WebDialog under Safari. Although it's usable, there are still a few rough edges. In particular, it takes over the plugin, looking for input files (see http://forums.sketchucation.com/viewtopic.php?f=180&t=33012 for details).
Still, I was able to use it successfully on a couple of very substantial plugins, so I am quite encouraged. At this point, I'm looking for some other plugin developers who would like to try out the code, look it over for problems, etc. I'm particularly interested in finding a tester who runs something other than Mac OS X.
-
Sure, I'll take a look at it. I'm running SU8 on Linux/Wine.
-
Phew!, glad someone responded. It sounds interesting....I just don't know what any of the terms mean that you're using. So I'd count it as being a little over my head
-
@morgan_greywolf said:
Sure, I'll take a look at it. I'm running SU8 on Linux/Wine.
Great. You can get started with the proxy server and the test page; send me a note off-list (rdm@cfcl.com) letting me know what you find out. As soon as I have my example plugin ready for Alpha testing, I'll let you know.
FYI, the plugin no longer sits in a read loop. Instead, I use UI.start_timer to perform periodic scans of the input directory. This seems to work quite nicely, but it does require SU8, because it's using a sub-second interval.
Also, I'm still hoping for a CygWin and/or native Windows tester!
Advertisement