|
From: creedon <icr...@us...> - 2005-09-08 02:53:24
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/op In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29518 Modified Files: outlineToXml Log Message: commented out appstring and replaced with Frontier.getProgramName, changing UserLand Frontier to Frontier, needed to change for docserver rez verb changes I was documenting Index: outlineToXml =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/op/outlineToXml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** outlineToXml 26 Mar 2005 19:43:18 -0000 1.1.1.1 --- outlineToXml 8 Sep 2005 02:53:16 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.op.outlineToXml ! on outlineToXml (adrOutline, ownerName=user.prefs.name, ownerEmail=user.prefs.mailAddress, adrCloud=nil) { ÇChanges: Ç1/28/03; 4:28:20 PM by JES ÇEncode entities in the window title. Prevents formation of mal-formed XML when the outline window contains less-than or greater-than characters. Ç5/24/02; 3:02:46 PM by JES ÇAdd an XML comment to the top of the file, saying what application generated the OPML. Cleaned up change notes. Ç12/20/01; 8:50:05 AM by DB ÇFixed target setting and set more window attributes before calling the kernel Ç12/19/01; 9:43:48 AM by DMB ÇAdded adrCloud parameter Ç7/19/01; 1:34:43 PM by JES ÇPreserve the window title, by patching the xml returned by the kernelCall. Ç7/18/01; 8:33:08 PM by JES ÇCopy the outline to a temporary outline contained in a local table object, instead of to @[windowTitle]^, to prevent the possibility of stomping on objects in the odb. Ç2/18/01; 4:58:37 PM by PBS ÇPreserve size, expansion state, scroll state, and window title. Ç1/1/01; 12:58:02 PM by DW ÇPreserve the dateCreated attribute of the OPML document. Ç1/1/01; 12:25:24 PM by DW ÇIn the 11/17 change the cure was worse than the disease. Now all outlines have a <title> of "localOutline". Not good. To work around this, I create a local outline with the same name as the original, then pass its address to the kernel. Ç11/17/00; 4:18:33 PM by JES ÇConvert a copy of the outline to opml instead of converting the outline itself, since if the outline is in text mode, the last-typed changes aren't added to the opml. Ç09/17/00; 4:06:33 PM by PBS ÇKernelized. Also added ownerName and ownerEmail optional parameters. Ç9/7/00; 2:53:03 PM by JES ÇSet the target to oldTarget before returning xmltext. Ç8/25/00; 11:13:16 AM by DW ÇVersion 1.0d2. Add <ownerName> and <ownerEmail> to the <head>. Ç07/27/00; 3:24:37 PM by PBS ÇEncode > characters as >, so the generated XML can be compiled later. Ç7/26/00; 6:38:36 PM by DW ÇEncode ampersands, quotes and less-thans in attributes. Ç7/19/00; 6:30:02 PM by DW ÇCreated. if date.versionLessThan (Frontier.version (), "7.0b21") { //script version on encode (s) { s = string.replaceall (s, "&", "&"); s = string.replaceall (s, "\"", """); s = string.replaceall (s, "<", "<"); s = string.replaceall (s, ">", ">"); //PBS 07/27/00: encode > characters, so XML can be compiled later return (s)}; local (scrollstate, expansionstate, windowtop, windowleft, windowheight, windowwidth, windowtitle); bundle { //set state variables based on the original window local (oldtarget = target.set (adroutline)); scrollstate = op.getscrollstate (); expansionstate = op.getexpansionstate (); window.getSize (adroutline, @windowwidth, @windowheight); window.getPosition (adroutline, @windowleft, @windowtop); windowtitle = window.gettitle (adroutline); };Çtarget.set (oldtarget) local (xmltext = "", indentlevel = 0); on add (s) { xmltext = xmltext + string.filledstring ("\t", indentlevel) + s + "\r"}; add ("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); local (localoutline); localoutline = adroutline^; local (oldtarget = target.set (@localoutline)); add ("<outlineDocument version=\"1.0d2\">"); indentlevel++; bundle { //add <head> add ("<head>"); indentlevel++; add ("<title>" + xml.entityEncode (windowtitle, true) + "</title>"); add ("<dateCreated>" + date.netstandardstring (timecreated (adroutline)) + "</dateCreated>"); add ("<dateModified>" + date.netstandardstring (timemodified (adroutline)) + "</dateModified>"); add ("<ownerName>" + ownerName + "</ownerName>"); //PBS 09/17/00: ownerName is now an optional parameter to this verb add ("<ownerEmail>" + ownerEmail + "</ownerEmail>"); //PBS 09/17/00: ownerEmail is now an optional parameter to this verb bundle { //add expansion state local (expansionlist = string (expansionstate), num, s = ""); for num in expansionlist { s = s + num + ","}; s = string.delete (s, sizeof (s), 1); //delete last comma add ("<expansionState>" + s + "</expansionState>")}; add ("<vertScrollState>" + scrollstate + "</vertScrollState>"); bundle { //add <windowXxx> elements add ("<windowTop>" + windowtop + "</windowTop>"); add ("<windowLeft>" + windowleft + "</windowLeft>"); add ("<windowBottom>" + (windowtop + windowheight) + "</windowBottom>"); add ("<windowRight>" + (windowleft + windowwidth) + "</windowRight>")}; add ("</head>"); indentlevel--}; bundle { //add <body> add ("<body>"); indentlevel++; op.fullexpand (); op.firstsummit (); on visitLevel () { local (s); loop { s = "<outline text=\"" + encode (op.getlinetext ()) + "\""; bundle { //add attributes from refcon, if there are any local (data = op.getrefcon ()); if typeof (data) == binarytype { //has attributes local (attstable); unpack (@data, @attstable); for adr in @attstable { s = s + " " + nameof (adr^) + "=\"" + encode (adr^) + "\""}}}; //7/26/00 DW if script.isComment () { s = s + " isComment=\"true\""}; if op.go (right, 1) { add (s + "\>"); indentlevel++; visitLevel (); add ("</outline>"); indentlevel--; op.go (left, 1)} else { add (s + "\/>")}; if not op.go (down, 1) { break}}}; visitLevel (); add ("</body>"); indentlevel--}; add ("</outlineDocument>"); indentlevel--; target.set (oldTarget); // 09/07/00 JES return (xmltext)} else { //kernel version local (localoutline); local (adrtempoutline = @localoutline); adrtempoutline^ = adroutline^; local (oldTarget = target.set (adroutline)); bundle { //PBS 02/18/01, dmb 12/20/01: duplicate window size, pos, title, expansion & scroll state local (windowTitle = window.getTitle (adroutline)); //use title of window, not name of outline object if windowTitle == "" { //if title == "", use name of object windowTitle = nameOf (adroutline^)}; windowTitle = xml.entityEncode (windowTitle, true); //JES 1/28/03: prevent malformed XML local (horiz, vert, hpos, vpos); window.getSize (adroutline, @horiz, @vert); window.getPosition (adroutline, @hpos, @vpos); local (expansionState = op.getExpansionState ()); local (scrollState = op.getScrollState ()); target.set (adrtempoutline); window.setTitle (adrtempoutline, windowTitle); window.setSize (adrtempoutline, horiz, vert); window.setPosition (adrtempoutline, hpos, vpos); op.setExpansionState (expansionState); op.setScrollState (scrollState)}; settimecreated (adrtempoutline, timecreated (adrOutline)); local (xmltext); if date.versionLessThan (Frontier.version (), "7.1b43") { // no adrCloud on kernelCall (adrOutline, ownerName, ownerEmail) { kernel (op.outlineToXml)}; xmltext = kernelCall (adrtempoutline, ownerName, ownerEmail)} else { on kernelCall (adrOutline, ownerName, ownerEmail, adrCloud) { kernel (op.outlineToXml)}; xmltext = kernelCall (adrtempoutline, ownerName, ownerEmail, adrCloud)}; try {target.set (oldTarget)}; Çbundle //patch the <title> element Çlocal (ixstart = string.patternMatch ("<title>", xmltext) + 7) Çlocal (ixend = string.patternMatch ("</title>", xmltext)) Çxmltext = string.delete (xmltext, ixstart, ixend - ixstart) Çxmltext = string.insert (windowTitle, xmltext, ixstart) bundle { //add a comment saying what application generated the OPML ÇExample comment: Ç<!-- OPML generated by Radio UserLand v8.0.5 on Fri, 24 May 2002 20:43:14 GMT --> local (appstring); bundle { //set appstring if system.environment.isRadio { appstring = "Radio UserLand "} else { //Frontier appstring = "UserLand Frontier "}; appstring = appstring + "v" + frontier.version ()}; local (commenttext = "<!-- OPML generated by " + appstring + " on " + date.netStandardString (clock.now ()) + " -->\r\n"); local (ix = string.patternMatch ("<opml ", xmltext)); xmltext = string.insert (commenttext, xmltext, ix)}; return (xmltext)}} \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.op.outlineToXml ! on outlineToXml (adrOutline, ownerName=user.prefs.name, ownerEmail=user.prefs.mailAddress, adrCloud=nil) { ÇChanges Ç9/7/05; 3:12:50 PM by TAC Çcommented out appstring and replaced with Frontier.getProgramName, changing UserLand Frontier to Frontier, needed to change for docserver rez verb changes I was documenting Ç1/28/03; 4:28:20 PM by JES ÇEncode entities in the window title. Prevents formation of mal-formed XML when the outline window contains less-than or greater-than characters. Ç5/24/02; 3:02:46 PM by JES ÇAdd an XML comment to the top of the file, saying what application generated the OPML. Cleaned up change notes. Ç2001 Ç12/20/01; 8:50:05 AM by DB ÇFixed target setting and set more window attributes before calling the kernel Ç12/19/01; 9:43:48 AM by DMB ÇAdded adrCloud parameter Ç7/19/01; 1:34:43 PM by JES ÇPreserve the window title, by patching the xml returned by the kernelCall. Ç7/18/01; 8:33:08 PM by JES ÇCopy the outline to a temporary outline contained in a local table object, instead of to @[windowTitle]^, to prevent the possibility of stomping on objects in the odb. Ç2/18/01; 4:58:37 PM by PBS ÇPreserve size, expansion state, scroll state, and window title. Ç1/1/01; 12:58:02 PM by DW ÇPreserve the dateCreated attribute of the OPML document. Ç1/1/01; 12:25:24 PM by DW ÇIn the 11/17 change the cure was worse than the disease. Now all outlines have a <title> of "localOutline". Not good. To work around this, I create a local outline with the same name as the original, then pass its address to the kernel. Ç2000 Ç11/17/00; 4:18:33 PM by JES ÇConvert a copy of the outline to opml instead of converting the outline itself, since if the outline is in text mode, the last-typed changes aren't added to the opml. Ç09/17/00; 4:06:33 PM by PBS ÇKernelized. Also added ownerName and ownerEmail optional parameters. Ç9/7/00; 2:53:03 PM by JES ÇSet the target to oldTarget before returning xmltext. Ç8/25/00; 11:13:16 AM by DW ÇVersion 1.0d2. Add <ownerName> and <ownerEmail> to the <head>. Ç07/27/00; 3:24:37 PM by PBS ÇEncode > characters as >, so the generated XML can be compiled later. Ç7/26/00; 6:38:36 PM by DW ÇEncode ampersands, quotes and less-thans in attributes. Ç7/19/00; 6:30:02 PM by DW ÇCreated. if date.versionLessThan (Frontier.version (), "7.0b21") { //script version on encode (s) { s = string.replaceall (s, "&", "&"); s = string.replaceall (s, "\"", """); s = string.replaceall (s, "<", "<"); s = string.replaceall (s, ">", ">"); //PBS 07/27/00: encode > characters, so XML can be compiled later return (s)}; local (scrollstate, expansionstate, windowtop, windowleft, windowheight, windowwidth, windowtitle); bundle { //set state variables based on the original window local (oldtarget = target.set (adroutline)); scrollstate = op.getscrollstate (); expansionstate = op.getexpansionstate (); window.getSize (adroutline, @windowwidth, @windowheight); window.getPosition (adroutline, @windowleft, @windowtop); windowtitle = window.gettitle (adroutline); };Çtarget.set (oldtarget) local (xmltext = "", indentlevel = 0); on add (s) { xmltext = xmltext + string.filledstring ("\t", indentlevel) + s + "\r"}; add ("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); local (localoutline); localoutline = adroutline^; local (oldtarget = target.set (@localoutline)); add ("<outlineDocument version=\"1.0d2\">"); indentlevel++; bundle { //add <head> add ("<head>"); indentlevel++; add ("<title>" + xml.entityEncode (windowtitle, true) + "</title>"); add ("<dateCreated>" + date.netstandardstring (timecreated (adroutline)) + "</dateCreated>"); add ("<dateModified>" + date.netstandardstring (timemodified (adroutline)) + "</dateModified>"); add ("<ownerName>" + ownerName + "</ownerName>"); //PBS 09/17/00: ownerName is now an optional parameter to this verb add ("<ownerEmail>" + ownerEmail + "</ownerEmail>"); //PBS 09/17/00: ownerEmail is now an optional parameter to this verb bundle { //add expansion state local (expansionlist = string (expansionstate), num, s = ""); for num in expansionlist { s = s + num + ","}; s = string.delete (s, sizeof (s), 1); //delete last comma add ("<expansionState>" + s + "</expansionState>")}; add ("<vertScrollState>" + scrollstate + "</vertScrollState>"); bundle { //add <windowXxx> elements add ("<windowTop>" + windowtop + "</windowTop>"); add ("<windowLeft>" + windowleft + "</windowLeft>"); add ("<windowBottom>" + (windowtop + windowheight) + "</windowBottom>"); add ("<windowRight>" + (windowleft + windowwidth) + "</windowRight>")}; add ("</head>"); indentlevel--}; bundle { //add <body> add ("<body>"); indentlevel++; op.fullexpand (); op.firstsummit (); on visitLevel () { local (s); loop { s = "<outline text=\"" + encode (op.getlinetext ()) + "\""; bundle { //add attributes from refcon, if there are any local (data = op.getrefcon ()); if typeof (data) == binarytype { //has attributes local (attstable); unpack (@data, @attstable); for adr in @attstable { s = s + " " + nameof (adr^) + "=\"" + encode (adr^) + "\""}}}; //7/26/00 DW if script.isComment () { s = s + " isComment=\"true\""}; if op.go (right, 1) { add (s + "\>"); indentlevel++; visitLevel (); add ("</outline>"); indentlevel--; op.go (left, 1)} else { add (s + "\/>")}; if not op.go (down, 1) { break}}}; visitLevel (); add ("</body>"); indentlevel--}; add ("</outlineDocument>"); indentlevel--; target.set (oldTarget); // 09/07/00 JES return (xmltext)} else { //kernel version local (localoutline); local (adrtempoutline = @localoutline); adrtempoutline^ = adroutline^; local (oldTarget = target.set (adroutline)); bundle { //PBS 02/18/01, dmb 12/20/01: duplicate window size, pos, title, expansion & scroll state local (windowTitle = window.getTitle (adroutline)); //use title of window, not name of outline object if windowTitle == "" { //if title == "", use name of object windowTitle = nameOf (adroutline^)}; windowTitle = xml.entityEncode (windowTitle, true); //JES 1/28/03: prevent malformed XML local (horiz, vert, hpos, vpos); window.getSize (adroutline, @horiz, @vert); window.getPosition (adroutline, @hpos, @vpos); local (expansionState = op.getExpansionState ()); local (scrollState = op.getScrollState ()); target.set (adrtempoutline); window.setTitle (adrtempoutline, windowTitle); window.setSize (adrtempoutline, horiz, vert); window.setPosition (adrtempoutline, hpos, vpos); op.setExpansionState (expansionState); op.setScrollState (scrollState)}; settimecreated (adrtempoutline, timecreated (adrOutline)); local (xmltext); if date.versionLessThan (Frontier.version (), "7.1b43") { // no adrCloud on kernelCall (adrOutline, ownerName, ownerEmail) { kernel (op.outlineToXml)}; xmltext = kernelCall (adrtempoutline, ownerName, ownerEmail)} else { on kernelCall (adrOutline, ownerName, ownerEmail, adrCloud) { kernel (op.outlineToXml)}; xmltext = kernelCall (adrtempoutline, ownerName, ownerEmail, adrCloud)}; try {target.set (oldTarget)}; Çbundle //patch the <title> element Çlocal (ixstart = string.patternMatch ("<title>", xmltext) + 7) Çlocal (ixend = string.patternMatch ("</title>", xmltext)) Çxmltext = string.delete (xmltext, ixstart, ixend - ixstart) Çxmltext = string.insert (windowTitle, xmltext, ixstart) bundle { //add a comment saying what application generated the OPML ÇExample comment: Ç<!-- OPML generated by Radio UserLand v8.0.5 on Fri, 24 May 2002 20:43:14 GMT --> Çbundle // 9/7/05; 3:16:55 PM by TAC - appstring old code Çlocal (appString) Çbundle // old code - set appstring Çif system.environment.isRadio Çappstring = "Radio UserLand " Çelse //Frontier Çappstring = "UserLand Frontier " Çappstring = appstring + "v" + frontier.version () local (commentText = "<!-- OPML generated by " + Frontier.getProgramName () + " on " + date.netStandardString (clock.now ()) + " -->\r\n"); local (ix = string.patternMatch ("<opml ", xmlText)); xmlText = string.insert (commentText, xmlText, ix)}; return (xmlText)}} \ No newline at end of file |