Monday, November 08, 2010 at 12:01 AM.
system.verbs.apps.Manila.windowTypes.types.manilaTemplate.openTemplate
on openTemplate (siteurl, type, flHidden=false, adradrwindow=nil) { <<Open a template or other advanced item in a Manila site. bundle { //if the window is already opened, bring it to the front local (t); new (tableType, @t); local (adrtype = parentOf (this^)); t.type = nameOf (adrtype^); t.manilaType = type; manila.windowTypes.findSiteInfo (siteUrl, @t.adrSiteInfo); local (adrwindow); if Frontier.tools.windowTypes.findWindowWithMatchingAtts (@t, @adrwindow) { local (title, flReadOnly = false); window.attributes.getOne ("title", @title, adrwindow); window.attributes.getOne ("flReadOnly", @flReadOnly, adrwindow); if not flHidden { edit (adrwindow, 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 = @system.temp.manila.data.sites.[nameOf (adrinfo^)]); if defined (adrtempinfo^) {delete (adrtempinfo)}; delete (adrinfo)}; return (false)}}; local (adrinfo); if not manila.windowTypes.findSiteInfo (siteUrl, @adrinfo, @createInfoCallback) { return (false)}; bundle { //get the site name and displaySiteName if we need them if adrinfo^.siteName == "" { adrinfo^.siteName = manila.getSiteName (nameOf (adrinfo^))}; if adrinfo^.displaySiteName == "" { adrinfo^.displaySiteName = adrinfo^.siteName}}; local (siteinfo = adrinfo^); manila.windowTypes.getUsernameAndPassword (adrinfo, @username, @password); siteinfo.username = username; siteinfo.password = password; local (template = manila.advancedPref.get (@siteinfo, type)); on typeToTitle (s) { if s == "css" { s = "cascadingStyleSheet"}; local (ct = sizeOf (s)); for i = ct downto 2 { if s[i] == string.upper (s[i]) { s = string.insert (" ", s, i)}}; s[1] = string.upper (s[1]); return (adrinfo^.displaySiteName + ": " + s)}; local (title = typeToTitle (type)); local (adr = Frontier.tools.windowTypes.newWindow ("manilaTemplate", true, title)); window.attributes.setOne ("adrSiteInfo", adrinfo, adr); case string.lower (type) { //custom deserialization "sitestructure" { local (adrtype = parentOf (this^)); adrtype^.scripts.siteStructure.xmlToOutline (template.body, adr)}} else { //default behavior -- open the returned body in the outline window op.newOutlineObject (template.body, adr)}; if defined (template.windowInfo) { //restore window state if sizeOf (template.windowInfo) != 0 { manila.windowTypes.restoreWindowState (adr, @template.windowInfo)}}; bundle { //set attributes local (t); new (tableType, @t); t.manilaType = type; t.lastSaved = timeModified (adr); window.attributes.addGroup (@t, adr)}; manila.advancedPref.checkOut (@siteinfo, type); if not flHidden { edit (adr, title)}; if adradrwindow != nil { adradrwindow^ = adr}; return (true)}; bundle { //debugging openTemplate ("http://jake.editthispage.com/", "SiteStructure")}
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.