|
From: creedon <icr...@us...> - 2005-06-13 22:23:55
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/windowTypes/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9387 Modified Files: quit save Log Message: comment test code bundle Index: quit =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/windowTypes/commands/quit,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** quit 26 Mar 2005 19:42:55 -0000 1.1.1.1 --- quit 13 Jun 2005 22:23:44 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.quit ! on quit () { bundle { //set quitting flag if not defined (temp.Frontier) { new (tableType, @temp.Frontier)}; temp.Frontier.closingDown = true}; on closeWindow (adr) { if defined (adr^) { //don't check the About window or the Find & Replace dialog if table.getRootAddress (adr) == adr { //hide the window window.hide (adr); return (true)}}; return (Frontier.tools.windowTypes.commands.close (adr))}; //this also calls callbacks if not window.visit (@closeWindow) { return (false)}; local (rootPath = window.getFile (@root)); on closeDatabase (f) { fileMenu.save (f); if f != rootPath { if not system.callbacks.closeWindow (@[f]) { return (false)}; fileMenu.close (f)}; return (true)}; if not table.visitOpenDatabases (@closeDatabase, true) { return (false)}; filemenu.save (); filemenu.quit (); return (true); Çbundle //old code ÇQuit Radio UserLand. ÇChanges: ÇThu, Oct 26, 2000 at 7:05:05 PM by PBS ÇAlways save each database, no matter what callbacks return. ÇDon't use Frontier.getFilePath, since it may return a gdb. Construct the path to the current system root. ÇVisit open databases in reverse order -- since we're removing items from the list. ÇSet a quitting flag in the temp table so other threads know the app is shutting down. Ç12/29/00; 4:06:10 AM by JES ÇBug fix: delete outlines in sub-tables of user.pike.sites before deleting user.pike.sites, to prevent an 'outline' undefined error on saving Radio.root, when quitting with open, un-saved Manila messages/templates. Ç01/05/01; 9:28:22 PM by JES ÇChanged handling of the closeWindow callback so that top-level guest database windows would be handled correctly. Çbundle //set quitting flag Çif not defined (temp.Frontier) Çnew (tableType, @temp.Frontier) Çtemp.Frontier.closingDown = true Çon closeChildWindow (adr) Çif defined (adr^) Çif table.getRootAddress (adr) != adr Çif system.callbacks.closeWindow (adr) Çtry Çif adr == table.getRootAddress (adr) // hide the window instead of closing it Çwindow.hide (adr) Çelse Çreturn (window.close (adr)) Çreturn (true) // continue through the rest of the windows Çelse Çif adr == table.getRootAddress (adr) //01/05/01 JES: don't stop if the window is the top level of a guest database. Çreturn (true) Çreturn (false) Çreturn (true) Çif not window.visit (@closeChildWindow) Çreturn (false) Çif defined (user.pike.sites) //clean up our temporary storage area; 12/29/00 JES: do this before closing databases Çbundle //12/29/00 JES: delete outlines in newStories, savedStories and advancedItems sub-tables of all of the site tables -- prevents an error window at shutdown. Çlocal (adrSite) Çon deleteOutlinesFromSubtables (adrTable) Çif defined (adrTable^) Çlocal (adrSubTable) Çfor adrSubTable in adrTable Çif defined (adrSubTable^.outline) Çdelete (@adrSubTable^.outline) Çfor adrSite in @user.pike.sites Çlocal (adrStory) ÇdeleteOutlinesFromSubtables (@adrSite^.advancedItems) ÇdeleteOutlinesFromSubtables (@adrSite^.newStories) ÇdeleteOutlinesFromSubtables (@adrSite^.savedStories) Çtable.emptyTable (@user.pike.sites) //12/29/00 JES: this will eventually go away, in favor of deleting the story tables. Çlocal (rootPath = window.getFile (@root)) //PBS 10/26/00: get path to system root Çon closeDatabase (f) ÇfileMenu.save (f) Çif f != rootPath Çif not system.callbacks.closeWindow (@[f]) //01/05/01 JES: commented out -- the callbacks have already been called. Çreturn (false) ÇfileMenu.close (f) Çreturn (true) Çif not table.visitOpenDatabases (@closeDatabase, true) //PBS 10/26/00: visit in reverse order Çreturn (false) Çfilemenu.save () Çfilemenu.quit () Çreturn (true)}; bundle { // debugging quit ()} \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.quit ! on quit () { bundle { //set quitting flag if not defined (temp.Frontier) { new (tableType, @temp.Frontier)}; temp.Frontier.closingDown = true}; on closeWindow (adr) { if defined (adr^) { //don't check the About window or the Find & Replace dialog if table.getRootAddress (adr) == adr { //hide the window window.hide (adr); return (true)}}; return (Frontier.tools.windowTypes.commands.close (adr))}; //this also calls callbacks if not window.visit (@closeWindow) { return (false)}; local (rootPath = window.getFile (@root)); on closeDatabase (f) { fileMenu.save (f); if f != rootPath { if not system.callbacks.closeWindow (@[f]) { return (false)}; fileMenu.close (f)}; return (true)}; if not table.visitOpenDatabases (@closeDatabase, true) { return (false)}; filemenu.save (); filemenu.quit (); return (true); Çbundle //old code ÇQuit Radio UserLand. ÇChanges: ÇThu, Oct 26, 2000 at 7:05:05 PM by PBS ÇAlways save each database, no matter what callbacks return. ÇDon't use Frontier.getFilePath, since it may return a gdb. Construct the path to the current system root. ÇVisit open databases in reverse order -- since we're removing items from the list. ÇSet a quitting flag in the temp table so other threads know the app is shutting down. Ç12/29/00; 4:06:10 AM by JES ÇBug fix: delete outlines in sub-tables of user.pike.sites before deleting user.pike.sites, to prevent an 'outline' undefined error on saving Radio.root, when quitting with open, un-saved Manila messages/templates. Ç01/05/01; 9:28:22 PM by JES ÇChanged handling of the closeWindow callback so that top-level guest database windows would be handled correctly. Çbundle //set quitting flag Çif not defined (temp.Frontier) Çnew (tableType, @temp.Frontier) Çtemp.Frontier.closingDown = true Çon closeChildWindow (adr) Çif defined (adr^) Çif table.getRootAddress (adr) != adr Çif system.callbacks.closeWindow (adr) Çtry Çif adr == table.getRootAddress (adr) // hide the window instead of closing it Çwindow.hide (adr) Çelse Çreturn (window.close (adr)) Çreturn (true) // continue through the rest of the windows Çelse Çif adr == table.getRootAddress (adr) //01/05/01 JES: don't stop if the window is the top level of a guest database. Çreturn (true) Çreturn (false) Çreturn (true) Çif not window.visit (@closeChildWindow) Çreturn (false) Çif defined (user.pike.sites) //clean up our temporary storage area; 12/29/00 JES: do this before closing databases Çbundle //12/29/00 JES: delete outlines in newStories, savedStories and advancedItems sub-tables of all of the site tables -- prevents an error window at shutdown. Çlocal (adrSite) Çon deleteOutlinesFromSubtables (adrTable) Çif defined (adrTable^) Çlocal (adrSubTable) Çfor adrSubTable in adrTable Çif defined (adrSubTable^.outline) Çdelete (@adrSubTable^.outline) Çfor adrSite in @user.pike.sites Çlocal (adrStory) ÇdeleteOutlinesFromSubtables (@adrSite^.advancedItems) ÇdeleteOutlinesFromSubtables (@adrSite^.newStories) ÇdeleteOutlinesFromSubtables (@adrSite^.savedStories) Çtable.emptyTable (@user.pike.sites) //12/29/00 JES: this will eventually go away, in favor of deleting the story tables. Çlocal (rootPath = window.getFile (@root)) //PBS 10/26/00: get path to system root Çon closeDatabase (f) ÇfileMenu.save (f) Çif f != rootPath Çif not system.callbacks.closeWindow (@[f]) //01/05/01 JES: commented out -- the callbacks have already been called. Çreturn (false) ÇfileMenu.close (f) Çreturn (true) Çif not table.visitOpenDatabases (@closeDatabase, true) //PBS 10/26/00: visit in reverse order Çreturn (false) Çfilemenu.save () Çfilemenu.quit () Çreturn (true)}; Çbundle // debugging Çquit () \ No newline at end of file Index: save =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/windowTypes/commands/save,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** save 26 Mar 2005 19:42:55 -0000 1.1.1.1 --- save 13 Jun 2005 22:23:44 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.save ! on save (adrItem=nil, flClosing=false) { ÇHandle the Save command. ÇChanges: Ç02/05/00; 5:29:12 PM by PBS ÇBuild the table of information about this window, so we can preserve size, position, scroll state, and expansion state. Ç03/23/00; 12:15:17 PM by PBS ÇUse the About Window for feedback when saving. Ç03/24/00; 11:14:47 AM by PBS ÇDon't update the last saved date after a failed save. Display a friendly error message explaining that there was a communication error -- display the title of the object and the name of the server. Ç03/24/00; 6:41:08 PM by PBS ÇConvert cascadingStyleSheet to css -- because manila.css is the name of the handler. This fixes saving CSS items back to the server. ÇFri, Jul 7, 2000 at 11:00:09 PM by AR ÇCall any scripts in user.pike.commandCallbacks.save ÇIf one of the scripts returns true, we're done Ç07/23/00; 7:59:16 PM by PBS ÇIf it's a local outline document, save it to disk at the right location. Ç08/16/00; 10:38:06 PM by JES ÇAlways bring the last frontmost window to the front after saving. ÇMonday, August 21, 2000 at 5:48:56 AM by DW ÇProvide feedback when saving local files. Ç08/22/00; 9:59:29 PM by PBS ÇWhen saving a message, don't promote it to a story if storyInfo.flAddToStoriesList exists and is false. This preserves backwards compatibility, but it also provides a way for people to create and reply to dg messages without making them stories. Ç08/23/00; 3:14:32 AM by PBS ÇSupport custom serialization routines for advanced items. This allows the plain XML display to be over-ridden. ÇSat, Aug 26, 2000 at 6:13:44 PM by JES ÇSave weblog pages by rendering with the website framework, according to their #ftpSite table settings. Ç09/15/00; 1:55:51 PM by PBS ÇIf the outline is raw XML, don't try to save it as an outlineDocument. Ç09/16/00; 5:22:22 PM by PBS Ç.opml is the default extension when saving new files. Ç09/16/00; 3:16:02 PM by PBS ÇSave file system objects -- classic text files -- okay. Ç09/21/00; 5:35:57 PM by PBS ÇWhen saving an OPML file, save with Radio UserLand's file creator code and OPML file type. Ç09/22/00; 5:00:21 PM by PBS ÇBefore saving to a Manila server, check the offline status. Ç10/03/00; 6:41:58 PM by PBS ÇCallbacks can be addresses. Ç10/07/00; 1:37:06 PM by PBS ÇIf there's an error saving, report the actual error to the user. Ç11/03/00; 1:13:17 AM by JES ÇHandle saving the message as opml if the server is compatible. Ç11/20/00; 3:39:43 PM by JES ÇCall the user callbacks when saving local outlines or rendering wsf pages. Ç11/20/00; 10:19:36 PM by JES ÇAllow callbacks to consume the save action for weblog pages and local outlines. Ç11/21/00; 1:22:36 AM by PBS ÇUse generic template save routine when the template doesn't have a dedicated handler. Ç11/29/00; 10:34:08 PM by JES ÇDereference callback addresses in a try block in case a tool's odb is not opened Ç12/20/00; 1:19:14 AM by JES ÇBug fix: View in Browser works for new stories and new messages. Ç12/21/00; 11:07:10 AM by PBS ÇBring the window being saved back to front only if the About window is frontmost. Fixes bug reported on Scripting News: http://scriptingnews.userland.com/backissues/2000/12/21 Ç12/26/00; 3:04:22 PM by PBS ÇWhen doing a save as plain text, allow the user to decide the extension, don't force an .xml or whatever extension. If no extension is provided, then use .txt. Ç12/31/00; 12:33:46 AM by JES ÇOn Macs, convert opml text to latin text before saving local outlines to disk. Ç01/24/01; 1:46:18 PM by JES ÇIf an opml file contained any xml headers like xml-stylesheet declarations, include them when saving the file. Ç02/08/01; 4:05:36 PM by JES ÇBug fix: If the About Window is frontmost, save Radio.root. Ç02/21/01; 2:16:27 AM by JES ÇSave the file using the recorded line-ending format. Preserve Mac type/creator codes. Ç3/16/01; 10:30:51 PM by PBS ÇIf the About window is already open, don't call window.about (), as that messes up window cascade order. if adrItem == nil { //default to frontmost window adrItem = window.frontmost ()}; on saveDatabase () { msg ("Saving database..."); if typeOf (adrItem) == addressType { fileMenu.saveMyRoot (adritem)} else { fileMenu.save ()}; msg ("")}; //clear the feedback message if not defined (adrItem^) { //save Radio.root adrItem = @root; saveDatabase (); return (true)}; on runCallbacks (adrCallback) { //call callbacks if defined (adrCallback^) { local (flConsumed = false); local (adrScript); for adrScript in adrCallback { try { //11/30/00 JES while typeOf (adrScript^) == addressType { //follow addresses adrScript = adrScript^}; flConsumed = adrScript^ (adrItem, flClosing)}; if flConsumed { return (true)}}}; return (false)}; if runCallbacks (@user.tools.commandCallbacks.save) { return (true)}; if system.environment.isRadio { if defined (user.pike.commandCallbacks) { if runCallbacks (@user.pike.commandCallbacks.save) { return (true)}}}; bundle { //look for a windowType that handles this command local (type, adrType); if window.attributes.getOne ("type", @type, adrItem) { if Frontier.tools.windowTypes.findWindowType (type, @adrType, adrItem) { if defined (adrType^.save) { if adrType^.save (adrItem, flClosing) { window.attributes.setOne ("lastSaved", timeModified (adrItem), adrItem); saveDatabase (); return (true)} else { return (false)}}}}}; saveDatabase (); return (true); Çbundle //old code Çif adrItem == nil //get the current selection Çtry {adrItem = table.getCursorAddress ()} Çlocal (frontWindow = window.frontMost ()) Çlocal (aboutWindowName = "About Radio UserLand") Ç Çon saveDatabase () // 8/26/00 JES: factored saving code Çmsg ("Saving database...") Çif typeOf (adrItem) == addressType ÇfileMenu.saveMyRoot (adritem) Çelse ÇfileMenu.save () Ç Çif window.frontMost () == aboutWindowName //PBS 12/21/00: bring editing window back to front only if the About window is frontmost Çtry {edit (frontWindow)} //JES 08/16/00 Ç Çmsg ("") //clear the feedback message Ç Çlocal (flConsumed = false) Çif adrItem != nil //11/20/00 JES: call the user callbacks Çif defined (user.pike.commandCallbacks.save) Çlocal (adrcallback) Çfor adrcallback in @user.pike.commandCallbacks.save Çtry //11/30/00 JES Çwhile typeOf (adrcallback^) == addressType //follow addresses Çadrcallback = adrcallback^ ÇflConsumed = adrcallback^ (adrItem, flClosing) Çif flConsumed Çbreak Ç Çif not defined (adrItem^) //save Radio.root ÇadrItem = @root ÇsaveDatabase () Çreturn (true) Ç Çif not flConsumed //JES 08/26/00: handle rendering website framework pages Çif defined (suites.playlist.weblog.utilities.windowIsWebPage) and suites.playlist.weblog.utilities.windowIsWebPage (adrItem) Çhtml.buildOnePage (adrItem) Ç ÇsaveDatabase () Ç Çif not flConsumed //PBS 07/23/00: handle local outline documents Çif pike.isLocalOutline (adrItem) //handle local outlines only in this block Çlocal (adrTable = parentOf (adrItem^)) Çlocal (f) Çon saveFile () Çmsg ("Saving \"" + f + "\".") //Monday, August 21, 2000 at 5:47:45 AM by DW ÇadrTable^.title = file.fileFromPath (f) Çwindow.setTitle (adrItem, adrTable^.title) Çlocal (xmlText) Çif defined (adrTable^.flOutlineDocument) //PBS 09/15/00: it may be raw XML Çif not (adrTable^.flOutlineDocument) ÇxmlText = string (adrItem^) //raw XML is just string of the outline Çbundle //add linefeeds if this is Windows Çif system.environment.isWindows ÇxmlText = string.replaceAll (xmlText, "\r", "\r\n") Çif defined (adrTable^.fileCreator) //02/21/2001 JES: save with recorded type/creator Çfile.writeWholeFile (f, xmlText, adrTable^.fileType, adrTable^.fileCreator) Çelse Çfile.writeWholeFile (f, xmlText, 'TEXT', 'Radu') Çif xmlText == nil //if it's an outlineDocument, xmlText is not yet set ÇxmlText = op.outlineToXml (adrItem) //convert to outlineDocument Çif defined (adrTable^.lineEnding) //02/21/2001 JES: save the file with the recorded line-endings ÇxmlText = string.replaceAll (xmlText, "\r", adrTable^.lineEnding) Çbundle //01/23/01 JES: support style sheet declarations Çif defined (adrTable^.xmlHeaders) Çlocal (ix = string.patternMatch ("?>", xmlText) + 3) ÇxmlText = string.insert (adrTable^.xmlHeaders, xmlText, ix) Çif system.environment.isMac //12/31/00 JES: convert Mac text to latin ÇxmlText = latinToMac.macToLatin (xmlText) Çif defined (adrTable^.fileCreator) //02/21/2001 JES: save with recorded type/creator Çfile.writeWholeFile (f, xmlText, adrTable^.fileType, adrTable^.fileCreator) Çelse Çfile.writeWholeFile (f, xmlText, 'OPML', 'Radu') //PBS 09/21/00: save with Mac codes ÇadrTable^.f = f ÇadrTable^.lastSaved = clock.now () Çmsg ("") Çreturn (true) Çif defined (adrTable^.f) Çf = adrTable^.f ÇsaveFile () Çelse Çif not (file.putFileDialog ("Save as:", @f)) Çreturn (false) Çlocal (defaultExtension = ".opml") Çlocal (flOutlineDocument = false) Çif defined (adrTable^.flOutlineDocument) //PBS 12/26/00: check extension only with OPML documents Çif adrTable^.flOutlineDocument ÇflOutlineDocument = true Ç Çif flOutlineDocument //ensure .opml extension Çif not (string.lower (f) endsWith defaultExtension) Çf = f + defaultExtension Çelse //PBS 12/26/00: if no extension, use .txt extension Çlocal (fname = file.fileFromPath (f)) Çif not (fname contains ".") Çf = f + ".txt" Ç ÇsaveFile () Ç Çreturn (true) Ç Çbundle //PBS 09/18/00: handle saving the home page of the server Çlocal (adrHomePage = @system.temp.playlist.serverHomePage) Çif defined (adrHomePage^) Çif adrItem == adrHomePage Çlocal (s = string (adrHomePage^)) //get the text Çlocal (f = user.playlist.prefs.wwwFolder + "index.html") Çfile.writeWholeFile (f, s, 'TEXT', user.html.prefs.textFileCreator, clock.now ()) Çreturn (true) Ç Çlocal (flAboutWindowOpen = window.isOpen (aboutWindowName)) Ç Çon savingError (displayTitle) ÇHandle errors in saving the document. Display a message and clean up. ÇfileMenu.save () Çmsg ("") ÇPBS 04/03/00: save the actual tryError Çif not defined (temp.pike) Çnew (tableType, @temp.pike) Çwp.newTextObject (tryError, @temp.pike.lastSaveError) Çif not flAboutWindowOpen //close the About Window if it wasn't open before doing a save Çwindow.close (aboutWindowName) Çlocal (hostName = pike.getServerHostName (adrItem)) ÇscriptError ("Can't save " + displayTitle + " because of an error communicating with the server, " + hostName + ".") ÇscriptError ("Can't save " + displayTitle + " because " + tryError + ".") Ç Çif adrItem!= nil Çbundle //PBS 03/23/00: display feedback message Çif not flAboutWindowOpen //PBS 03/16/01: this call messes up window cascade order if the About window was already open Çwindow.about () Ç Çif not flConsumed Çlocal (windowType = pike.getWindowType (adrItem)) Çif windowType != "" Ç Çif not (playlist.tcpOkay ()) //PBS 09/22/00: check offline status Çreturn (false) Ç Çlocal (adrTable = parentOf (adrItem^)) Ç Çlocal (bodyType = "text/x-outline-tabbed") Ç Çlocal (windowInfoTable = pike.buildWindowInfoTable (adrItem)) //PBS 02/05/00: get the window info table Ç Çlocal (flServerAcceptsOpml = false) Çif defined (adrTable^.siteInfo.flAcceptsOpml) //11/03/00 JES ÇflServerAcceptsOpml = adrTable^.siteInfo.flAcceptsOpml Çcase windowType Ç"advancedItems" Çlocal (itemTypeName = nameOf (adrTable^)) Çmsg ("Saving " + itemTypeName + "...") Çlocal (handlerName = pike.advancedItemToHandlerName (itemTypeName)) Çtry Çlocal (s = string (adrItem^)) Çif defined (adrTable^.itemInfo.adrSerializeRoutine) //PBS 08/23/00: call serialization routine if there is one Çif defined (adrTable^.itemInfo.adrSerializeRoutine^) Çs = adrTable^.itemInfo.adrSerializeRoutine^ (adrTable) Çif defined (manila.[handlerName].set) Çmanila.[handlerName].set (@adrTable^.siteinfo, s, windowInfoTable) Çelse //PBS 11/20/00: use generic save routine Çmanila.advancedPref.set (@adrTable^.siteInfo, itemTypeName, s, windowInfoTable) Çelse ÇsavingError ("the " + itemTypeName) ÇadrTable^.lastSaved = clock.now () Ç"savedStories" Çif flServerAcceptsOpml ÇbodyType = "text/x-opml" Çlocal (subject = adrTable^.storyinfo.subject) Çmsg ("Saving \"" + subject + "\"...") Çlocal (adrStory = @adrTable^.storyinfo) Çtry Çif flServerAcceptsOpml //11/03/00 JES Çlocal (opmlText = op.outlineToXml (adrItem, ownerEmail:adrTable^.siteInfo.username)) Çmanila.message.set (@adrTable^.siteinfo, adrStory^.msgnum, adrStory^.subject, opmlText, bodyType, windowInfoTable) //PBS 02/05/00: added windowInfoTable parameter Çelse Çmanila.message.set (@adrTable^.siteinfo, adrStory^.msgnum, adrStory^.subject, string (adrItem^), bodyType, windowInfoTable) //PBS 02/05/00: added windowInfoTable parameter Çelse Çtemp.errorText = tryError ÇsavingError ("\"" + subject + "\"") ÇadrTable^.lastSaved = clock.now () Ç"newStories" Çif flServerAcceptsOpml ÇbodyType = "text/x-opml" Çlocal (subject = adrTable^.storyinfo.subject) Çmsg ("Saving \"" + subject + "\"...") Ç Çlocal (resulttable) Çtry Çlocal (inResponseTo = 0) Çif defined (adrTable^.storyInfo.inResponseTo) ÇinResponseTo = adrTable^.storyInfo.inResponseTo Çif flServerAcceptsOpml //11/03/00 JES Çlocal (opmlText = op.outlineToXml (adrItem, ownerEmail:adrTable^.siteInfo.username)) Çresulttable = manila.message.create (@adrTable^.siteinfo, subject, opmlText, bodyType, inResponseTo, windowInfoTable) Çelse Çresulttable = manila.message.create (@adrTable^.siteinfo, subject, string (adrItem^), bodyType, inResponseTo, windowInfoTable) Çelse Çtemp.errorText = tryError ÇsavingError ("\"" + subject + "\"") Ç Çif not flClosing //copy to savedStories Çlocal (adrStoryTable = pike.getStoryTableAddress (@adrTable^.siteinfo, resulttable.msgnum)) ÇadrStoryTable^.siteinfo = adrTable^.siteinfo ÇadrStoryTable^.storyinfo = resulttable Ç Çtable.move (adrItem, adrStoryTable) Çpike.setWindowTitle (adrStoryTable) Ç ÇadrTable^.storyinfo.url = adrStoryTable^.storyinfo.url //12/20/00 JES: make view in browser work for new stories Ç ÇadrStoryTable^.lastSaved = clock.now () Ç Çlocal (flAddToStoriesList = true) //PBS 08/22/00: if flAddToStoriesList exists and is false, don't add to stories. This way we can have messages that aren't stories. Çif defined (adrTable^.storyInfo.flAddToStoriesList) Çif not (adrTable^.storyInfo.flAddToStoriesList) ÇflAddToStoriesList = false Çif flAddToStoriesList Çmanila.message.addToStoriesList (@adrTable^.siteinfo, resulttable.msgnum) Ç Çif window.isOpen (adrItem) Çedit (adrItem) //PBS 03/24/00: bring it back to the front, in case the About Window came to the front Ç ÇsaveDatabase () Çbundle // factored code Çmsg ("Saving database...") Çif typeOf (adrItem) == addressType ÇfileMenu.saveMyRoot (adritem) Çelse ÇfileMenu.save () Ç Çtry {edit (frontWindow)} //JES 08/16/00 Ç Çmsg ("") //clear the feedback message Çif not flAboutWindowOpen //close the About Window if it wasn't open before doing a save Çwindow.close (aboutWindowName) Ç Çreturn (true)}; bundle { // debugging save (window.frontMost ())} \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.save ! on save (adrItem=nil, flClosing=false) { ÇHandle the Save command. ÇChanges: Ç02/05/00; 5:29:12 PM by PBS ÇBuild the table of information about this window, so we can preserve size, position, scroll state, and expansion state. Ç03/23/00; 12:15:17 PM by PBS ÇUse the About Window for feedback when saving. Ç03/24/00; 11:14:47 AM by PBS ÇDon't update the last saved date after a failed save. Display a friendly error message explaining that there was a communication error -- display the title of the object and the name of the server. Ç03/24/00; 6:41:08 PM by PBS ÇConvert cascadingStyleSheet to css -- because manila.css is the name of the handler. This fixes saving CSS items back to the server. ÇFri, Jul 7, 2000 at 11:00:09 PM by AR ÇCall any scripts in user.pike.commandCallbacks.save ÇIf one of the scripts returns true, we're done Ç07/23/00; 7:59:16 PM by PBS ÇIf it's a local outline document, save it to disk at the right location. Ç08/16/00; 10:38:06 PM by JES ÇAlways bring the last frontmost window to the front after saving. ÇMonday, August 21, 2000 at 5:48:56 AM by DW ÇProvide feedback when saving local files. Ç08/22/00; 9:59:29 PM by PBS ÇWhen saving a message, don't promote it to a story if storyInfo.flAddToStoriesList exists and is false. This preserves backwards compatibility, but it also provides a way for people to create and reply to dg messages without making them stories. Ç08/23/00; 3:14:32 AM by PBS ÇSupport custom serialization routines for advanced items. This allows the plain XML display to be over-ridden. ÇSat, Aug 26, 2000 at 6:13:44 PM by JES ÇSave weblog pages by rendering with the website framework, according to their #ftpSite table settings. Ç09/15/00; 1:55:51 PM by PBS ÇIf the outline is raw XML, don't try to save it as an outlineDocument. Ç09/16/00; 5:22:22 PM by PBS Ç.opml is the default extension when saving new files. Ç09/16/00; 3:16:02 PM by PBS ÇSave file system objects -- classic text files -- okay. Ç09/21/00; 5:35:57 PM by PBS ÇWhen saving an OPML file, save with Radio UserLand's file creator code and OPML file type. Ç09/22/00; 5:00:21 PM by PBS ÇBefore saving to a Manila server, check the offline status. Ç10/03/00; 6:41:58 PM by PBS ÇCallbacks can be addresses. Ç10/07/00; 1:37:06 PM by PBS ÇIf there's an error saving, report the actual error to the user. Ç11/03/00; 1:13:17 AM by JES ÇHandle saving the message as opml if the server is compatible. Ç11/20/00; 3:39:43 PM by JES ÇCall the user callbacks when saving local outlines or rendering wsf pages. Ç11/20/00; 10:19:36 PM by JES ÇAllow callbacks to consume the save action for weblog pages and local outlines. Ç11/21/00; 1:22:36 AM by PBS ÇUse generic template save routine when the template doesn't have a dedicated handler. Ç11/29/00; 10:34:08 PM by JES ÇDereference callback addresses in a try block in case a tool's odb is not opened Ç12/20/00; 1:19:14 AM by JES ÇBug fix: View in Browser works for new stories and new messages. Ç12/21/00; 11:07:10 AM by PBS ÇBring the window being saved back to front only if the About window is frontmost. Fixes bug reported on Scripting News: http://scriptingnews.userland.com/backissues/2000/12/21 Ç12/26/00; 3:04:22 PM by PBS ÇWhen doing a save as plain text, allow the user to decide the extension, don't force an .xml or whatever extension. If no extension is provided, then use .txt. Ç12/31/00; 12:33:46 AM by JES ÇOn Macs, convert opml text to latin text before saving local outlines to disk. Ç01/24/01; 1:46:18 PM by JES ÇIf an opml file contained any xml headers like xml-stylesheet declarations, include them when saving the file. Ç02/08/01; 4:05:36 PM by JES ÇBug fix: If the About Window is frontmost, save Radio.root. Ç02/21/01; 2:16:27 AM by JES ÇSave the file using the recorded line-ending format. Preserve Mac type/creator codes. Ç3/16/01; 10:30:51 PM by PBS ÇIf the About window is already open, don't call window.about (), as that messes up window cascade order. if adrItem == nil { //default to frontmost window adrItem = window.frontmost ()}; on saveDatabase () { msg ("Saving database..."); if typeOf (adrItem) == addressType { fileMenu.saveMyRoot (adritem)} else { fileMenu.save ()}; msg ("")}; //clear the feedback message if not defined (adrItem^) { //save Radio.root adrItem = @root; saveDatabase (); return (true)}; on runCallbacks (adrCallback) { //call callbacks if defined (adrCallback^) { local (flConsumed = false); local (adrScript); for adrScript in adrCallback { try { //11/30/00 JES while typeOf (adrScript^) == addressType { //follow addresses adrScript = adrScript^}; flConsumed = adrScript^ (adrItem, flClosing)}; if flConsumed { return (true)}}}; return (false)}; if runCallbacks (@user.tools.commandCallbacks.save) { return (true)}; if system.environment.isRadio { if defined (user.pike.commandCallbacks) { if runCallbacks (@user.pike.commandCallbacks.save) { return (true)}}}; bundle { //look for a windowType that handles this command local (type, adrType); if window.attributes.getOne ("type", @type, adrItem) { if Frontier.tools.windowTypes.findWindowType (type, @adrType, adrItem) { if defined (adrType^.save) { if adrType^.save (adrItem, flClosing) { window.attributes.setOne ("lastSaved", timeModified (adrItem), adrItem); saveDatabase (); return (true)} else { return (false)}}}}}; saveDatabase (); return (true); Çbundle //old code Çif adrItem == nil //get the current selection Çtry {adrItem = table.getCursorAddress ()} Çlocal (frontWindow = window.frontMost ()) Çlocal (aboutWindowName = "About Radio UserLand") Ç Çon saveDatabase () // 8/26/00 JES: factored saving code Çmsg ("Saving database...") Çif typeOf (adrItem) == addressType ÇfileMenu.saveMyRoot (adritem) Çelse ÇfileMenu.save () Ç Çif window.frontMost () == aboutWindowName //PBS 12/21/00: bring editing window back to front only if the About window is frontmost Çtry {edit (frontWindow)} //JES 08/16/00 Ç Çmsg ("") //clear the feedback message Ç Çlocal (flConsumed = false) Çif adrItem != nil //11/20/00 JES: call the user callbacks Çif defined (user.pike.commandCallbacks.save) Çlocal (adrcallback) Çfor adrcallback in @user.pike.commandCallbacks.save Çtry //11/30/00 JES Çwhile typeOf (adrcallback^) == addressType //follow addresses Çadrcallback = adrcallback^ ÇflConsumed = adrcallback^ (adrItem, flClosing) Çif flConsumed Çbreak Ç Çif not defined (adrItem^) //save Radio.root ÇadrItem = @root ÇsaveDatabase () Çreturn (true) Ç Çif not flConsumed //JES 08/26/00: handle rendering website framework pages Çif defined (suites.playlist.weblog.utilities.windowIsWebPage) and suites.playlist.weblog.utilities.windowIsWebPage (adrItem) Çhtml.buildOnePage (adrItem) Ç ÇsaveDatabase () Ç Çif not flConsumed //PBS 07/23/00: handle local outline documents Çif pike.isLocalOutline (adrItem) //handle local outlines only in this block Çlocal (adrTable = parentOf (adrItem^)) Çlocal (f) Çon saveFile () Çmsg ("Saving \"" + f + "\".") //Monday, August 21, 2000 at 5:47:45 AM by DW ÇadrTable^.title = file.fileFromPath (f) Çwindow.setTitle (adrItem, adrTable^.title) Çlocal (xmlText) Çif defined (adrTable^.flOutlineDocument) //PBS 09/15/00: it may be raw XML Çif not (adrTable^.flOutlineDocument) ÇxmlText = string (adrItem^) //raw XML is just string of the outline Çbundle //add linefeeds if this is Windows Çif system.environment.isWindows ÇxmlText = string.replaceAll (xmlText, "\r", "\r\n") Çif defined (adrTable^.fileCreator) //02/21/2001 JES: save with recorded type/creator Çfile.writeWholeFile (f, xmlText, adrTable^.fileType, adrTable^.fileCreator) Çelse Çfile.writeWholeFile (f, xmlText, 'TEXT', 'Radu') Çif xmlText == nil //if it's an outlineDocument, xmlText is not yet set ÇxmlText = op.outlineToXml (adrItem) //convert to outlineDocument Çif defined (adrTable^.lineEnding) //02/21/2001 JES: save the file with the recorded line-endings ÇxmlText = string.replaceAll (xmlText, "\r", adrTable^.lineEnding) Çbundle //01/23/01 JES: support style sheet declarations Çif defined (adrTable^.xmlHeaders) Çlocal (ix = string.patternMatch ("?>", xmlText) + 3) ÇxmlText = string.insert (adrTable^.xmlHeaders, xmlText, ix) Çif system.environment.isMac //12/31/00 JES: convert Mac text to latin ÇxmlText = latinToMac.macToLatin (xmlText) Çif defined (adrTable^.fileCreator) //02/21/2001 JES: save with recorded type/creator Çfile.writeWholeFile (f, xmlText, adrTable^.fileType, adrTable^.fileCreator) Çelse Çfile.writeWholeFile (f, xmlText, 'OPML', 'Radu') //PBS 09/21/00: save with Mac codes ÇadrTable^.f = f ÇadrTable^.lastSaved = clock.now () Çmsg ("") Çreturn (true) Çif defined (adrTable^.f) Çf = adrTable^.f ÇsaveFile () Çelse Çif not (file.putFileDialog ("Save as:", @f)) Çreturn (false) Çlocal (defaultExtension = ".opml") Çlocal (flOutlineDocument = false) Çif defined (adrTable^.flOutlineDocument) //PBS 12/26/00: check extension only with OPML documents Çif adrTable^.flOutlineDocument ÇflOutlineDocument = true Ç Çif flOutlineDocument //ensure .opml extension Çif not (string.lower (f) endsWith defaultExtension) Çf = f + defaultExtension Çelse //PBS 12/26/00: if no extension, use .txt extension Çlocal (fname = file.fileFromPath (f)) Çif not (fname contains ".") Çf = f + ".txt" Ç ÇsaveFile () Ç Çreturn (true) Ç Çbundle //PBS 09/18/00: handle saving the home page of the server Çlocal (adrHomePage = @system.temp.playlist.serverHomePage) Çif defined (adrHomePage^) Çif adrItem == adrHomePage Çlocal (s = string (adrHomePage^)) //get the text Çlocal (f = user.playlist.prefs.wwwFolder + "index.html") Çfile.writeWholeFile (f, s, 'TEXT', user.html.prefs.textFileCreator, clock.now ()) Çreturn (true) Ç Çlocal (flAboutWindowOpen = window.isOpen (aboutWindowName)) Ç Çon savingError (displayTitle) ÇHandle errors in saving the document. Display a message and clean up. ÇfileMenu.save () Çmsg ("") ÇPBS 04/03/00: save the actual tryError Çif not defined (temp.pike) Çnew (tableType, @temp.pike) Çwp.newTextObject (tryError, @temp.pike.lastSaveError) Çif not flAboutWindowOpen //close the About Window if it wasn't open before doing a save Çwindow.close (aboutWindowName) Çlocal (hostName = pike.getServerHostName (adrItem)) ÇscriptError ("Can't save " + displayTitle + " because of an error communicating with the server, " + hostName + ".") ÇscriptError ("Can't save " + displayTitle + " because " + tryError + ".") Ç Çif adrItem!= nil Çbundle //PBS 03/23/00: display feedback message Çif not flAboutWindowOpen //PBS 03/16/01: this call messes up window cascade order if the About window was already open Çwindow.about () Ç Çif not flConsumed Çlocal (windowType = pike.getWindowType (adrItem)) Çif windowType != "" Ç Çif not (playlist.tcpOkay ()) //PBS 09/22/00: check offline status Çreturn (false) Ç Çlocal (adrTable = parentOf (adrItem^)) Ç Çlocal (bodyType = "text/x-outline-tabbed") Ç Çlocal (windowInfoTable = pike.buildWindowInfoTable (adrItem)) //PBS 02/05/00: get the window info table Ç Çlocal (flServerAcceptsOpml = false) Çif defined (adrTable^.siteInfo.flAcceptsOpml) //11/03/00 JES ÇflServerAcceptsOpml = adrTable^.siteInfo.flAcceptsOpml Çcase windowType Ç"advancedItems" Çlocal (itemTypeName = nameOf (adrTable^)) Çmsg ("Saving " + itemTypeName + "...") Çlocal (handlerName = pike.advancedItemToHandlerName (itemTypeName)) Çtry Çlocal (s = string (adrItem^)) Çif defined (adrTable^.itemInfo.adrSerializeRoutine) //PBS 08/23/00: call serialization routine if there is one Çif defined (adrTable^.itemInfo.adrSerializeRoutine^) Çs = adrTable^.itemInfo.adrSerializeRoutine^ (adrTable) Çif defined (manila.[handlerName].set) Çmanila.[handlerName].set (@adrTable^.siteinfo, s, windowInfoTable) Çelse //PBS 11/20/00: use generic save routine Çmanila.advancedPref.set (@adrTable^.siteInfo, itemTypeName, s, windowInfoTable) Çelse ÇsavingError ("the " + itemTypeName) ÇadrTable^.lastSaved = clock.now () Ç"savedStories" Çif flServerAcceptsOpml ÇbodyType = "text/x-opml" Çlocal (subject = adrTable^.storyinfo.subject) Çmsg ("Saving \"" + subject + "\"...") Çlocal (adrStory = @adrTable^.storyinfo) Çtry Çif flServerAcceptsOpml //11/03/00 JES Çlocal (opmlText = op.outlineToXml (adrItem, ownerEmail:adrTable^.siteInfo.username)) Çmanila.message.set (@adrTable^.siteinfo, adrStory^.msgnum, adrStory^.subject, opmlText, bodyType, windowInfoTable) //PBS 02/05/00: added windowInfoTable parameter Çelse Çmanila.message.set (@adrTable^.siteinfo, adrStory^.msgnum, adrStory^.subject, string (adrItem^), bodyType, windowInfoTable) //PBS 02/05/00: added windowInfoTable parameter Çelse Çtemp.errorText = tryError ÇsavingError ("\"" + subject + "\"") ÇadrTable^.lastSaved = clock.now () Ç"newStories" Çif flServerAcceptsOpml ÇbodyType = "text/x-opml" Çlocal (subject = adrTable^.storyinfo.subject) Çmsg ("Saving \"" + subject + "\"...") Ç Çlocal (resulttable) Çtry Çlocal (inResponseTo = 0) Çif defined (adrTable^.storyInfo.inResponseTo) ÇinResponseTo = adrTable^.storyInfo.inResponseTo Çif flServerAcceptsOpml //11/03/00 JES Çlocal (opmlText = op.outlineToXml (adrItem, ownerEmail:adrTable^.siteInfo.username)) Çresulttable = manila.message.create (@adrTable^.siteinfo, subject, opmlText, bodyType, inResponseTo, windowInfoTable) Çelse Çresulttable = manila.message.create (@adrTable^.siteinfo, subject, string (adrItem^), bodyType, inResponseTo, windowInfoTable) Çelse Çtemp.errorText = tryError ÇsavingError ("\"" + subject + "\"") Ç Çif not flClosing //copy to savedStories Çlocal (adrStoryTable = pike.getStoryTableAddress (@adrTable^.siteinfo, resulttable.msgnum)) ÇadrStoryTable^.siteinfo = adrTable^.siteinfo ÇadrStoryTable^.storyinfo = resulttable Ç Çtable.move (adrItem, adrStoryTable) Çpike.setWindowTitle (adrStoryTable) Ç ÇadrTable^.storyinfo.url = adrStoryTable^.storyinfo.url //12/20/00 JES: make view in browser work for new stories Ç ÇadrStoryTable^.lastSaved = clock.now () Ç Çlocal (flAddToStoriesList = true) //PBS 08/22/00: if flAddToStoriesList exists and is false, don't add to stories. This way we can have messages that aren't stories. Çif defined (adrTable^.storyInfo.flAddToStoriesList) Çif not (adrTable^.storyInfo.flAddToStoriesList) ÇflAddToStoriesList = false Çif flAddToStoriesList Çmanila.message.addToStoriesList (@adrTable^.siteinfo, resulttable.msgnum) Ç Çif window.isOpen (adrItem) Çedit (adrItem) //PBS 03/24/00: bring it back to the front, in case the About Window came to the front Ç ÇsaveDatabase () Çbundle // factored code Çmsg ("Saving database...") Çif typeOf (adrItem) == addressType ÇfileMenu.saveMyRoot (adritem) Çelse ÇfileMenu.save () Ç Çtry {edit (frontWindow)} //JES 08/16/00 Ç Çmsg ("") //clear the feedback message Çif not flAboutWindowOpen //close the About Window if it wasn't open before doing a save Çwindow.close (aboutWindowName) Ç Çreturn (true)}; Çbundle // debugging Çsave (window.frontMost ()) \ No newline at end of file |