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


local (siteUrl);
op.attributes.getOne ("siteUrl", @siteUrl);

bundle { //bring the window to the front if it's already opened
	local (adrsiteinfo);
	if manila.windowTypes.findSiteInfo (siteUrl, @adrsiteinfo) { //no create info callback
		local (adr, adrobject);
		for adr in {
			adrobject = @adr^.window;
			local (type);
			if window.attributes.getOne ("type", @type, adrobject) {
				if type == "manilaMessage" {
					local (url);
					if window.attributes.getOne ("url", @url, adrobject) {
						local (parts = string.urlSplit (url));
						if not (parts[2] contains ":") {
							url = parts[1] + parts[2] + ":80/" + parts[3]};
						if string.lower (url) == string.lower (siteUrl) {
							local (title, flReadOnly = false);
							if not window.attributes.getOne ("title", @title, adrobject) {
								title = adrinfo^.displaySiteName;
								if title == "" {
									title = adrinfo^.siteName}};
							window.attributes.getOne ("flReadOnly", @flReadOnly, adrobject);
							edit (adrobject, title, flReadOnly);
							return (true)}}}}}}};

local (username, password);
on createInfoCallback (adrinfo) {
	if manila.windowTypes.getUsernameAndPassword (adrinfo, @username, @password) {
		manila.windowTypes.setUsernameAndPassword (adrinfo, username, password)}
	else {
		bundle { //don't leave stale data lying around
			local (adrtempinfo =[nameOf (adrinfo^)]);
			if defined (adrtempinfo^) {delete (adrtempinfo)};
			delete (adrinfo)};
		return (false)}};

local (adrinfo);
if not manila.windowTypes.findSiteInfo (siteUrl, @adrinfo, @createInfoCallback) {
	return (false)};
local (siteinfo = adrinfo^);

manila.windowTypes.getUsernameAndPassword (adrinfo, @username, @password);
siteinfo.username = username;
siteinfo.password = password;

local (msgnum = manila.homepage.getMsgNum (@siteinfo));

local (adrtype); ("manilaMessage", @adrtype);
<<adrtype^.openMessage (siteurl, msgnum, flHomePage:true) //this didn't work
thread.callscript (@adrtype^.openMessage, {siteurl, msgnum, false, true});

return (true)

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.