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


on ftpTable (adrTable, flDialog=true, flDisplayInBrowser=false, adrPageTable=nil, template=nil) {
	<<Publish an entire table and its subtables.
		<<When rendering scalable content, call html.ftpTable multiple times,
		<<each time with a different template parameter.
		<<(To use the default template, don't pass a template parameter,
		<<or pass nil.)
	local (f = "", url = "", siteTableAdr);
	local (flDisplay = true, pageTable);
	if adrPageTable == nil {
		new (tableType, @pageTable);
		adrPageTable = @pageTable};
	html.callFileWriterStartup (adrTable, adrPageTable);
	on doTable (adrTable) {
		local (i, ct = sizeOf (adrTable^), adr);
		for i = 1 to ct {
			adr = @adrTable^ [i];
			window.msg (adr);
			if not html.traversalSkip (adr) {
				if typeOf (adr^) == tableType {
					doTable (adr)}
				else {
					local (s);
					table.emptyTable (adrPageTable);
					s = html.buildObject (adr, adrPageTable, template);
					if flDisplayInBrowser {
						<<If this is the default page for this site, save the path.
						local (default = html.getPref ("defaultFileName", adrPageTable));
						if string.lower (nameOf (adr^)) == string.lower (default) {
							if f != "" and url != "" {
								if adr == @adrPageTable^.adrSiteRootTable^.[default] {
									f = adrPageTable^.f;
									url = adrPageTable^.url}}
							else {
								f = adrPageTable^.f;
								url = adrPageTable^.url}}};
					html.ftpText (s, adrPageTable)}}}};
	doTable (adrTable);
	html.callFileWriterShutdown (adrTable, adrPageTable);
	window.msg ("");
	<<Display in browser.
	if flDisplayInBrowser {
		siteTableAdr = html.getSiteTable (adrPageTable);
		if f == "" or url == "" { //didn't find default, get last page rendered
			f = adrPageTable^.f;
			url = adrPageTable^.url};
		if string.lower (html.getPref ("fileWriter")) == "file" {
			webBrowser.openDocument (f)}
		else {
			webBrowser.openUrl (url)};
		if user.webBrowser.bringToFrontOnPreview {
			webBrowser.bringToFront ()}};
	<<Show a dialog.
	if flDialog {
		speaker.beep (); //4.2.1
		dialog.notify ("The \"" + nameOf (adrTable^) + "\" table has been published.")}; //4.2.1
	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.