Monday, November 08, 2010 at 12:06 AM.


on getFrontWindowSource () { <<4.2.3
	case sys.os () {
		"MacOS" {
			<<Thu, May 1, 1997 at 5:27:25 PM by DW
				<<More general way of working with non-MSIE 3.0.1 browsers
				<<Wed, Apr 9, 1997 at 6:13:56 PM by DW
					<<Now works with Netscape
			try {
				return (appleevent ('MSIE', 'MSIE', 'SORC'))}
			else {
				local (url = webBrowser.getFrontWindowURL ());
				if url beginsWith "file:///" { //handle local web pages
					local (path = string.getFileURL (url));
					return (string (file.readWholeFile (path)))};
				on httpGetSource (url) {
					local (partsList = string.urlSplit (url));
					local (domainName = partsList [2]);
					local (path = partsList [3]);
					local (s);
					<<if not (netEvents.launch ())
						<<return (false)
					<<return (netEvents.examples.httpGet (domainName, path, 80))
					s = tcp.httpClient (server:domainName, path:path);
					<<Strip off the header.
					s = string.mid (s, string.patternMatch ("\r\n\r\n", s) + 4, infinity);
					return (s)};
				return (httpGetSource (url))}}}}

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.