I've been doing some HTML scraping with Mechanize recently and I figured I could use a small tool that opens up a small WebView and reads HTML fragments from STDIN. Here's what I came up with: https://gist.github.com/1121174 There are a couple of things wrong with it that I chalk up to noobishness (and the fact that I usually start with an application template in XCode and use Objective-C), that I could use some help on: 1) Despite passing in Closable and Resizeable, the window doesn't seem to do either. Also I can never get focus or scroll. Does the window need to be open in a different thread? Have a window controller? If so, what's the best way to do that? (Most of the tutorials I've seen are either full Applications or minimal scripts with no UI.) 2) Is there anyway to embed/access a web developer console like the one in Safari? Thanks. -- –Andrew O'Brien
1) NSApplication.sharedApplication.activationPolicy = NSApplicationActivationPolicyRegular NSApplication.sharedApplication.activateIgnoringOtherApps(true) That will give your CLI app focus. 2) No idea, the inspector is just html + js, so you should be able to port it. You can also use the webkit scripting bridge to get Ruby <=> JS and create a simple editor in MacRuby. (I have a demo somewhere where I show how to write a HTML 5 game controlled by a bluetooth PS3 controller. It shows how to easily use the webkit bridge. - Matt On Tue, Aug 2, 2011 at 1:58 PM, Andrew O'Brien <obrien.andrew@gmail.com>wrote:
I've been doing some HTML scraping with Mechanize recently and I figured I could use a small tool that opens up a small WebView and reads HTML fragments from STDIN. Here's what I came up with:
https://gist.github.com/1121174
There are a couple of things wrong with it that I chalk up to noobishness (and the fact that I usually start with an application template in XCode and use Objective-C), that I could use some help on:
1) Despite passing in Closable and Resizeable, the window doesn't seem to do either. Also I can never get focus or scroll. Does the window need to be open in a different thread? Have a window controller? If so, what's the best way to do that? (Most of the tutorials I've seen are either full Applications or minimal scripts with no UI.) 2) Is there anyway to embed/access a web developer console like the one in Safari?
Thanks.
-- –Andrew O'Brien
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
ohh that's a neat trick, thanks Eloy! - Matt On Wed, Aug 3, 2011 at 1:39 AM, Eloy Durán <eloy.de.enige@gmail.com> wrote:
2) Is there anyway to embed/access a web developer console like the one in Safari?
You can enable it by doing the following at the start of the app:
NSUserDefaults.registerDefaults(WebKitDeveloperExtras => true)
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Andrew O'Brien
-
Eloy Durán
-
Matt Aimonetti