Monday, April 04, 2011 at 1:06 AM.

rssCloudWebsite.pleaseNotify

on pleaseNotify () {
	<<Changes
		<<10/2/09; 3:10:18 PM by DW
			<<Pass flDiffDomain to rssCloudSuite.pleaseNotify.
		<<9/13/09; 8:58:10 AM by DW
			<<Add support for optional domain parameter.
		<<8/11/09; 10:01:52 AM by DW
			<<If the request body is empty, try to get the params from the searchargs.
		<<8/11/09; 9:55:11 AM by DW
			<<Only respond to POST requests.
		<<8/11/09; 9:34:23 AM by DW
			<<Check the parameters to make sure they're all there, and if not, provide a more intelligent error message.
		<<7/20/09; 1:57:31 PM by DW
			<<Created. A page to receive notify requests via http-post. This is the REST interface.
			<<Params we expect: notifyProcedure, port, path, protocol, url1, url2, ... urlN. 
			<<They identify the routine we're to call back when the urls change. 
	local (pta = html.getpagetableaddress (), returnstring = "");
	<<scratchpad.pleaseNotifyParams = pta^
	on setreturnstring (fl, msgstring) {
		<<bundle //old code, before factoring 7/23/09 by DW
			<<local (xmltext = "", indentlevel = 0)
			<<on add (s)
				<<xmltext = xmltext + string.filledstring ("\t", indentlevel) + s + "\r"
			<<on encode (s)
				<<if system.environment.isMac
					<<return (xml.entityEncode (latinToMac.macToLatin (s), true))
				<<else
					<<return (xml.entityEncode (s, true))
			<<add ("<?xml version=\"1.0\"?>")
			<<add ("<notifyResult success=\"" + fl + "\" msg=\"" + encode (msgstring) + "\" />")
			<<returnstring = xmltext
		returnstring = rssCloudSuite.restReturnSuccess (fl, msgstring, "notifyResult")};
	try {
		if pta^.method == "POST" {
			local (args, adr, i, client, flDiffDomain);
			new (tabletype, @args);
			
			local (paramstring = pta^.requestbody);
			if sizeof (paramstring) == 0 {
				paramstring = pta^.searchargs};
			webserver.parseargs (paramstring, @args);
			
			local (urllist = {});
			for adr in @args {
				if string.lower (nameof (adr^)) beginswith "url" {
					urllist = urllist + string.urldecode (adr^)}};
			
			bundle { //check params, 8/11/09 by DW
				local (s = "");
				if not defined (args.notifyProcedure) {
					s = s + "notifyProcedure, "};
				if not defined (args.port) {
					s = s + "port, "};
				if not defined (args.path) {
					s = s + "path, "};
				if not defined (args.protocol) {
					s = s + "protocol, "};
				if sizeof (s) > 0 {
					s = string.delete (s, sizeof (s) - 1, 2);
					scripterror ("The following parameters were missing from the request body: " + s + ".")}};
			bundle { //set client, 9/13/09 by DW
				if defined (args.domain) {
					client = args.domain;
					<<scratchpad.domainNotifyParams = pta^
					flDiffDomain = true}
				else {
					client = pta^.client;
					flDiffDomain = false}};
			
			rssCloudSuite.pleaseNotify (args.notifyProcedure, args.port, args.path, args.protocol, urllist, client, flDiffDomain);
			setreturnstring (true, "Thanks for the registration. It worked. When the feed updates we'll notify you. Don't forget to re-register after 24 hours, your subscription will expire in 25. Keep on truckin!")}
		else {
			scriptError ("Request must be POST.")}}
	else {
		setreturnstring (false, tryerror)};
	rssCloudSuite.setupXmlReturn ();
	return (returnstring)};
bundle { //test code
	html.setpagetableaddress (@scratchpad.domainNotifyParams);
	pleaseNotify ()}



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.