|
From: creecode <icr...@us...> - 2006-03-07 05:39:35
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/data/windowTypes/outlinerFile In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6904 Modified Files: saveAsHtml Log Message: replace calls to verbs at extensions.latinToMac with string.(latin/mac)To(Latin/Mac) verbs Index: saveAsHtml =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/data/windowTypes/outlinerFile/saveAsHtml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** saveAsHtml 26 Mar 2005 19:42:52 -0000 1.1.1.1 --- saveAsHtml 7 Mar 2006 05:39:32 -0000 1.2 *************** *** 1,3 **** ! FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.data.windowTypes.outlinerFile.saveAsHtml ! on saveAsHtml (adrOutline, adrFilepath=nil, flPreview=false) { //Render an outline as HTML and save it to disk. ÇChanges Ç4/27/02; 9:51:38 AM by DW ÇThe flPreview flag is nutty. It's always false based on the way it's called from the kernel. Setting it true doesn't get the document to open in the browser which is what previewing should do. Further, if it's false, it opens the document in an outline window. Oy. So I changed it, so that unconditionally, the HTML rendering is displayed in the browser after you save it. Don't try turning it on, please. It's not a well-designed feature. Ç4/27/02; 9:30:14 AM by DW ÇThere were two references to "adr" in this script, and apparently, at one time, the address of the outline was called adr, but not any more. These two changes made Save As HTML command in the File menu work on a relatively virgin Radio 8 installation. Ç1/30/02; 2:07:42 AM by JES ÇRemoved reference to pike.getPreferencesFolder. Ç1/29/02; 10:39:41 PM by JES ÇRemoved references to pike.isLocalOutline and pike.titleToHtmlFileName. Ç12/10/01; 12:33:40 AM by JES ÇCommented out the block where a default file path was set. Not only did it reference the deprecated pike.getPreferencesFolder, but it wasn't needed in the first place. Now all we set is the default filename. Ç12/15/00; 6:20:38 PM by PBS ÇCall user.pike.renderOutline to create the HTML document. This script may be changed by the user to over-ride the standard behavior. Ç12/20/00; 2:02:56 AM by JES ÇIf on a Mac, convert Mac characters to latin before writing the file to disk. Ç12/26/00; 2:43:55 PM by PBS ÇWorks with non-file-based outlines -- gets title from window title. If local, file based outline, get it from file info table. Ç12/13/00; 5:41:50 PM by PBS ÇCreated. Render an outline as HTML and save it to disk. Çadr is the address of the window to save ÇadrFilepath is the address from which to get the file path. If adrFilepath^ == nil, it will be set to the generated file path. ÇIf flPreview is true, the file is saved in [Radio Folder]/Preferences/View in Browser/[outlineName].html. ÇIf flPreview is false, the HTML file is opened in Radio. local (f); if adrFilepath != nil { f = adrFilepath^}; if f == nil { //construct a file path if not specified f = Frontier.tools.windowTypes.getDefaultFilename (adrOutline, user.html.prefs.fileExtension); local (appFolder = file.folderFromPath (Frontier.getProgramPath ())); local (viewInBrowserFolder = appFolder + "View in Browser" + file.getPathChar ()); f = viewInBrowserFolder + f; file.sureFilePath (f)}; if not flPreview { //ask the user for a path if not file.putFileDialog ("Save as HTML:", @f) { return (true)}}; //consume the command local (htmlText); bundle { //render the HTML on runUserRenderer (adrRenderer) { if defined (adrRenderer^) { local (adrScript = adrRenderer); try { while (typeOf (adrScript^) == addressType) { adrScript = adrScript^}}; htmlText = adrScript^ (adrOutline); return (true)}; return (false)}; local (htmlSetByUserRenderer = false); if runUserRenderer (@user.tools.renderOutline) { htmlSetByUserRenderer = true} else { //legacy support for user.pike.renderOutline if system.environment.isRadio { if defined (user.pike) { if runUserRenderer (@user.pike.renderOutline) { htmlSetByUserRenderer = true}}}}; if not htmlSetByUserRenderer { //do default rendering on renderOutline (adrOutline) { //from pike.renderOutline ÇRender an outline. Return the text of the rendering. ÇIf the outline contains rules, use pikeRenderer. Otherwise do a default unordered list rendering. Ç12/13/00; 5:03:46 PM by PBS ÇChanges: Ç12/26/00; 2:44:31 PM by PBS ÇWorks with non-file-based outlines -- gets title from window title. If local, file based outline, get it from file info table. Ç12/26/00; 5:11:21 PM by PBS ÇAdd HTML 4.01 Transitional doctype declaration. local (s); local (adrParentTable = parentOf (adrOutline^)); local (title = window.getTitle (adrOutline)); //PBS 12/26/00: get window title window.attributes.getOne ("title", @title, adrOutline); //4/27/02 by DW, change adr to adrOutline if string.lower (title) endsWith ".opml" { title = string.popSuffix (title)}; local (localOutline = adrOutline^); //make a copy of the outline adrOutline = @localOutline; if string (adrOutline) contains "<rules>" { //rules? local (pt); new (tableType, @pt); html.setPageTableAddress (@pt); local (oldTarget = target.set (@localOutline)); s = pikeRenderer.theRenderer (adrOutline); try {target.set (oldTarget)}; s = string.replaceAll (s, "\r\r", "<p>\r"); html.deletePageTableAddress ()} else { //no rules; use unordered list rendering s = html.getOutlineHtml (adrOutline, "\r<ul>", "\r</ul>", "\r<li>", "</li>")}; bundle { //add HTML header and footer ÇHeader. local (headerText = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r"); //PBS 12/26/00: add DOCTYPE declaration headerText = headerText + "<html>\r\t<head><title>" + title + "</title></head>\r"; headerText = headerText + "\t<body bgcolor=\"white\">\r"; ÇHTML title. headerText = headerText + "<h2>" + title + "</h2>\r"; s = headerText + s; ÇFooter. local (footerText = "\r\t\t</body>\r\t</html>"); s = s + footerText}; bundle { //if this is a PC, add line feeds if system.environment.isWindows { s = string.replaceAll (s, "\r", "\r\n")}}; return (s)}; htmlText = renderOutline (adrOutline)}}; //4/27/02 by DW, change adr to adrOutline if system.environment.isMac { //12/20/00 JES: if on a Mac, convert Mac characters to latin htmlText = latinToMac.macToLatin (htmlText)}; file.writeWholeFile (f, htmlText, 'TEXT', user.html.prefs.textFileCreator, clock.now ()); if adrFilepath != nil { //tell the caller where the file is -- used for View in Browser adrFilepath^ = f}; bundle { //4/27/02 by DW, see comment at head of script Çif not flPreview Çreturn (Frontier.tools.windowTypes.commands.open (f)) webbrowser.opendocument (f)}; return (true)} \ No newline at end of file --- 1,133 ---- ! FrontierVcsFile:2:scpt:system.verbs.builtins.Frontier.tools.data.windowTypes.outlinerFile.saveAsHtml ! on saveAsHtml (adrOutline, adrFilepath=nil, flPreview=false) { //Render an outline as HTML and save it to disk. ! «Changes ! «2/28/06; 1:03:16 PM by TAC ! «replace latinToMac.macToLatin with string.macToLatin ! «2002 ! «4/27/02; 9:51:38 AM by DW ! «The flPreview flag is nutty. It's always false based on the way it's called from the kernel. Setting it true doesn't get the document to open in the browser which is what previewing should do. Further, if it's false, it opens the document in an outline window. Oy. So I changed it, so that unconditionally, the HTML rendering is displayed in the browser after you save it. Don't try turning it on, please. It's not a well-designed feature. ! «4/27/02; 9:30:14 AM by DW ! «There were two references to "adr" in this script, and apparently, at one time, the address of the outline was called adr, but not any more. These two changes made Save As HTML command in the File menu work on a relatively virgin Radio 8 installation. ! «1/30/02; 2:07:42 AM by JES ! «Removed reference to pike.getPreferencesFolder. ! «1/29/02; 10:39:41 PM by JES ! «Removed references to pike.isLocalOutline and pike.titleToHtmlFileName. ! «12/10/01; 12:33:40 AM by JES ! «Commented out the block where a default file path was set. Not only did it reference the deprecated pike.getPreferencesFolder, but it wasn't needed in the first place. Now all we set is the default filename. ! «2000 ! «12/26/00; 2:43:55 PM by PBS ! «Works with non-file-based outlines -- gets title from window title. If local, file based outline, get it from file info table. ! «12/20/00; 2:02:56 AM by JES ! «If on a Mac, convert Mac characters to latin before writing the file to disk. ! «12/15/00; 6:20:38 PM by PBS ! «Call user.pike.renderOutline to create the HTML document. This script may be changed by the user to over-ride the standard behavior. ! «12/13/00; 5:41:50 PM by PBS ! «Created. Render an outline as HTML and save it to disk. ! «adr is the address of the window to save ! «adrFilepath is the address from which to get the file path. If adrFilepath^ == nil, it will be set to the generated file path. ! «If flPreview is true, the file is saved in [Radio Folder]/Preferences/View in Browser/[outlineName].html. ! «If flPreview is false, the HTML file is opened in Radio. ! ! local (f); ! if adrFilepath != nil { ! f = adrFilepath^}; ! ! if f == nil { //construct a file path if not specified ! f = Frontier.tools.windowTypes.getDefaultFilename (adrOutline, user.html.prefs.fileExtension); ! local (appFolder = file.folderFromPath (Frontier.getProgramPath ())); ! local (viewInBrowserFolder = appFolder + "View in Browser" + file.getPathChar ()); ! f = viewInBrowserFolder + f; ! file.sureFilePath (f)}; ! ! if not flPreview { //ask the user for a path ! if not file.putFileDialog ("Save as HTML:", @f) { ! return (true)}}; //consume the command ! ! local (htmlText); ! bundle { //render the HTML ! on runUserRenderer (adrRenderer) { ! if defined (adrRenderer^) { ! local (adrScript = adrRenderer); ! try { ! while (typeOf (adrScript^) == addressType) { ! adrScript = adrScript^}}; ! htmlText = adrScript^ (adrOutline); ! return (true)}; ! return (false)}; ! local (htmlSetByUserRenderer = false); ! if runUserRenderer (@user.tools.renderOutline) { ! htmlSetByUserRenderer = true} ! else { //legacy support for user.pike.renderOutline ! if system.environment.isRadio { ! if defined (user.pike) { ! if runUserRenderer (@user.pike.renderOutline) { ! htmlSetByUserRenderer = true}}}}; ! if not htmlSetByUserRenderer { //do default rendering ! on renderOutline (adrOutline) { //from pike.renderOutline ! «Render an outline. Return the text of the rendering. ! «If the outline contains rules, use pikeRenderer. Otherwise do a default unordered list rendering. ! «12/13/00; 5:03:46 PM by PBS ! «Changes: ! «12/26/00; 2:44:31 PM by PBS ! «Works with non-file-based outlines -- gets title from window title. If local, file based outline, get it from file info table. ! «12/26/00; 5:11:21 PM by PBS ! «Add HTML 4.01 Transitional doctype declaration. ! ! local (s); ! local (adrParentTable = parentOf (adrOutline^)); ! local (title = window.getTitle (adrOutline)); //PBS 12/26/00: get window title ! window.attributes.getOne ("title", @title, adrOutline); //4/27/02 by DW, change adr to adrOutline ! if string.lower (title) endsWith ".opml" { ! title = string.popSuffix (title)}; ! ! local (localOutline = adrOutline^); //make a copy of the outline ! adrOutline = @localOutline; ! ! if string (adrOutline) contains "<rules>" { //rules? ! local (pt); ! new (tableType, @pt); ! html.setPageTableAddress (@pt); ! local (oldTarget = target.set (@localOutline)); ! s = pikeRenderer.theRenderer (adrOutline); ! try {target.set (oldTarget)}; ! s = string.replaceAll (s, "\r\r", "<p>\r"); ! html.deletePageTableAddress ()} ! else { //no rules; use unordered list rendering ! s = html.getOutlineHtml (adrOutline, "\r<ul>", "\r</ul>", "\r<li>", "</li>")}; ! ! bundle { //add HTML header and footer ! «Header. ! local (headerText = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r"); //PBS 12/26/00: add DOCTYPE declaration ! headerText = headerText + "<html>\r\t<head><title>" + title + "</title></head>\r"; ! headerText = headerText + "\t<body bgcolor=\"white\">\r"; ! ! «HTML title. ! headerText = headerText + "<h2>" + title + "</h2>\r"; ! ! s = headerText + s; ! ! «Footer. ! local (footerText = "\r\t\t</body>\r\t</html>"); ! ! s = s + footerText}; ! ! bundle { //if this is a PC, add line feeds ! if system.environment.isWindows { ! s = string.replaceAll (s, "\r", "\r\n")}}; ! ! return (s)}; ! htmlText = renderOutline (adrOutline)}}; //4/27/02 by DW, change adr to adrOutline ! ! if system.environment.isMac { //12/20/00 JES: if on a Mac, convert Mac characters to latin ! htmlText = string.macToLatin (htmlText)}; ! file.writeWholeFile (f, htmlText, 'TEXT', user.html.prefs.textFileCreator, clock.now ()); ! ! if adrFilepath != nil { //tell the caller where the file is -- used for View in Browser ! adrFilepath^ = f}; ! ! bundle { //4/27/02 by DW, see comment at head of script ! «if not flPreview ! «return (Frontier.tools.windowTypes.commands.open (f)) ! webbrowser.opendocument (f)}; ! return (true)} \ No newline at end of file |