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

system.verbs.builtins.userland.createDefaultIspSite

on createDefaultIspSite (siteName="createASiteManilaWebsite", password=nil, serverName=nil, displaySiteName=nil, tagline=nil, theme=nil) {
	<<Create the default Manila site if it doesn't already exist.
		<<Return true if it gets created, return false if it already exists and thus doesn't get created.
		<<This is a wrapper for manilaSuite.clone. It's called from userland.finishInstall, when the user has elected to turn on the webserver.
		<<10/26/99; 6:22:28 PM by PBS
	bundle { //set up ISP prefs in config.root
		if not defined (config.manila.hosting) {
			new (tableType, @config.manila.hosting)};
		if not defined (config.manila.hosting.sites) {
			new (tableType, @config.manila.hosting.sites)};
		if not defined (config.manila.hosting.sites.default) {
			new (tableType, @config.manila.hosting.sites.default)};
		config.manila.hosting.sites.default.baseDomain = serverName;
		config.manila.hosting.sites.default.canonicalSiteName = siteName; //"createASiteManilaWebsite"
		if not defined (config.manila.hosting.sites.default.flEditorsOnlyCreateSites) {
			config.manila.hosting.sites.default.flEditorsOnlyCreateSites = false};
		if not defined (config.manila.hosting.sites.default.flSubSites) {
			config.manila.hosting.sites.default.flSubSites = true}};
	
	if not defined (config.manila.prefs.hostingGdbName) {
		config.manila.prefs.hostingGdbName = "manilaWebsites.root"};
	local (gdbName = config.manila.prefs.hostingGdbName);
	local (gdbPath = Frontier.getSubFolder ("www") + gdbName);
	if not (defined ([gdbPath])) { //is it already open?
		if file.exists (gdbPath) {
			fileMenu.open (gdbPath, true)} //it does, open it
		else {
			fileMenu.new (gdbPath);
			window.hide (@[gdbPath])}};
			<<fileMenu.save (gdbPath)
	
	bundle { //add hosting gdb to user.databases
		local (adrTable = @user.databases.[gdbName]);
		if not defined (adrtable^) {
			new (tableType, adrTable)};
		if not defined (adrTable^.f) {
			adrTable^.f = gdbPath};
		if not defined (adrTable^.openOnStartup) {
			adrTable^.openOnStartup = true};
		if not defined (adrTable^.runStartupScript) {
			adrTable^.runStartupScript = false};
		if not defined (adrTable^.supportsIndexing) {
			adrTable^.supportsIndexing = true};
		if not defined (adrTable^.supportsSubscribe) {
			adrTable^.supportsSubscribe = false}};
	
	if file.exists (Frontier.getSubFolder ("www") + siteName + ".root") { //does the file exist?
		return (false)}; //the file exists
	
	local (dgName = siteName + "Discuss");
	local (groupName = siteName + "Members");
	local (sysopName = user.prefs.name);
	local (sysopEmail = user.prefs.mailAddress);
	local (sysopPassword);
	
	if password == nil { //create a new password
		local (i);
		for i = 1 to 12 {
			sysopPassword = sysopPassword + char (random ('A', 'Z'))}}
	else {
		sysopPassword = password};
	
	if serverName == nil { //figure out the server name
		serverName = tcp.dns.getMyDomainName ();
		if not (serverName contains ".") {
			serverName = tcp.myDottedId ()}};
	
	local (siteUrl = "http://" + serverName + "/");
	
	if theme == nil { //default to ISP theme
		theme = "ISP"};
	local (siteInfo);
	siteInfo = manilaSuite.clone (siteName, groupName, dgName, sysopEmail, sysopPassword, sysopName, siteUrl, false, true, true, gdbName, siteName, theme, false); //JES 4/12/02: Pass in siteName instead of "createASiteManilaWebsite" for the canonicalSiteName parameter
	<<siteInfo.adrSite^.["#newsSite"].siteName = "Home"
	<<siteInfo.adrSite^.["#newsSite"].flFirstTimeVisitAfterInstall = true
	delete (@siteInfo.adrSite^.["#navigator"].structure);
	
	bundle { //tag line, siteName, dg access
		local (adrSite = siteInfo.adrSite);
		if displaySiteName == nil {
			displaySiteName = canonicalSiteName};
		if tagline == nil {
			tagline = ""};
		wp.newTextObject (tagline, @adrSite^.["#newsSite"].tagLine);
		adrSite^.["#newsSite"].siteName = displaySiteName;
		try {delete (@adrSite^.discuss.edit.["#members"])};
		adrSite^.discuss.["#members"] = adrSite^.["#prefs"].defaultMembershipGroup};
	
	<<bundle //set up an It Worked! message
		<<local (adrSite = siteInfo.adrSite)
		<<local (adrNewsSite = @adrSite^.["#newsSite"])
		<<local (dgName = adrSite^.["#prefs"].discussionRoot)
		<<local (homePageMsgNum = adrNewsSite^.discussLinks.homePageMsgNum)
		<<local (adrRoot = [system.temp.mainResponder.discussRootFile].[dgName])
		<<
		<<Home page.
		<<local (adrMsgTable = mainResponder.discuss.getMessageTable (homePageMsgNum, adrRoot:adrRoot))
		<<adrMsgTable^.subject = userland.defaultPages.homeTitle
		<<adrMsgTable^.body = string (userland.defaultPages.home)
		<<
		<<FAQ page.
		<<local (faqMsgNum = adrNewsSite^.discussLinks.faqMsgNum)
		<<adrMsgTable = mainResponder.discuss.getMessageTable (faqMsgNum, adrRoot:adrRoot)
		<<adrMsgTable^.subject = userland.defaultPages.faqTitle
		<<adrMsgTable^.body = string (userland.defaultPages.faq)
		<<
		<<Feedback page.
		<<local (emailMsgNum = adrNewsSite^.discussLinks.emailMsgNum)
		<<adrMsgTable = mainResponder.discuss.getMessageTable (emailMsgNum, adrRoot:adrRoot)
		<<adrMsgTable^.subject = userland.defaultPages.feedbackTitle
		<<adrMsgTable^.body = string (userland.defaultPages.feedback)
		<<
		<<Make sure the managing editor gets the cookie in a minute.
		<<adrNewsSite^.flFirstTimeVisitAfterInstall = true
	
	bundle { //set up the domain for this site
		local (domainMinusPort = string.popSuffix (serverName, ':'));
		local (adrDomain = @config.mainResponder.domains.[domainMinusPort]);
		if not defined (adrDomain^) { //don't delete existing domain configurations
			new (tableType, adrDomain);
			new (tableType, @adrDomain^.siteTree);
			new (tableType, @adrDomain^.siteTree.directory);
			local (s = "<siteTree>\r\t<site address=\"" + siteName + "\"/>\r\t</siteTree>");
			wp.newTextObject (s, @adrDomain^.siteTree.directory.outline)}};
	
	if not defined (temp.installer) {
		new (tableType, @temp.installer)};
	temp.installer.urlToOpen = siteInfo.adrSite^.["#ftpSite"].url;
	<<temp.installer.urlToOpen = siteInfo.adrSite^.["#ftpSite"].url + "controlPanel/" //PBS 06/23/00: Open the Control Panel, not the hosting site
	
	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.