on viewPage (domain, path) { // Changes // 6/20/05; 5:07:46 PM by DW // Headlines with slashes in their text really confuse things, so when we link to one of these change the slashes to &slash; and when we use one of these links, properly decode them. // 6/14/05; 9:35:19 AM by DW // If it's the gnomedex outline, don't process periods. Don't try to be elegant about it, that can come later. // 5/22/05; 11:00:31 AM by DW // If a line has a xmlUrl attribute, display a tiny XML icon linked to the XML version. // 5/22/05; 10:48:34 AM by DW // Accept title or text attributes for display, favor text. local (flprocessperiods = true); //6/14/05; 9:39:37 AM by DW if domain beginswith "gnomedex" { flprocessperiods = false}; on popuri (ctpop) { local (i, s = path, ix, ch); for i = 1 to ctpop { for ix = sizeof (s) downto 1 { ch = s [ix]; s = string.delete (s, ix, 1); if ch == "/" { break}}}; return (s)}; on decode (s) { s = xml.entityDecode (s, true, true); s = xml.rss.decodeString (s); return (s)}; local (adrdata = opmlDirectorySuite.init ()); local (adrmatch, errorstring, trail, opmlurl); opmlDirectorySuite.walk (domain, path, @adrmatch, @trail, adrerrorstring:@errorstring, adropmlurl:@opmlurl); if sizeof (errorstring) > 0 { scripterror (errorstring)}; local (opmlarrowimg = string (adrdata^.prefs.graphics.redarrow)); local (minixmlimg = string (adrdata^.prefs.graphics.minixml)); local (htmltext = "", indentlevel = 0); on add (s) { htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r"}; bundle { //add crumb trail string local (crumbstring, i, adritem, fllast, link, sizetrail = sizeof (trail)); if sizetrail == 0 { crumbstring = "Top"} else { crumbstring = "Top"; for i = 1 to sizetrail { adritem = @trail [i]; fllast = i == sizetrail; if fllast { link = "" + adritem^.s + ""} else { link = "" + adritem^.s + ""}; if sizeof (crumbstring) > 0 { crumbstring = crumbstring + " > " + link} else { crumbstring = crumbstring + link}}}; add (crumbstring)}; bundle { //add subs add ("
"); indentlevel++; if nameof (adrmatch^) contains "channel" { //it's an RSS feed local (adritem); for adritem in adrmatch { if nameof (adritem^) contains "item" { add (""); indentlevel--}; bundle { //flow through template local (s = string (adrdata^.prefs.htmlTemplate)); new (tabletype, @changes); changes.bodytext = htmltext; changes.opmlUrl = opmlurl; changes.now = clock.now () + " Eastern"; changes.counterScript = ""; s = string.multiplereplaceall (s, @changes, false, "<%", "%>"); htmltext = s}; return (htmltext)}; // edit (@scratchpad.trail) // local (adr, adratts, url) // add ("" + xml.getvalue (adritem, "description") + "
")}}} else { local (ct = 0); add (""); indentlevel++; local (adrsub); for adrsub in adrmatch { if nameof (adrsub^) contains "outline" { local (adratts = @adrsub^.["/atts"]); local (ctsubs, fldirectorynode, decodedtext, flopmllink, flrss, linktext, commentstring, subscountstring, link, textatt); bundle { //set ctsubs if defined (adratts^.ctsubs) { ctsubs = adratts^.ctsubs} else { local (adr); ctsubs = 0; // edit (adrsub) for adr in adrsub { if nameof (adr^) contains "outline" { ctsubs++}}; adratts^.ctsubs = ctsubs}}; bundle { //set textatt, 5/22/05; 10:48:07 AM by DW // if there is no text attribute, look for a title attribute, // appears to be common usage for subscription lists // if neither are there, take the first attribute, in alphabetic order, and convert it to a string if defined (adratts^.text) { textatt = adratts^.text} else { if defined (adratts^.title) { textatt = adratts^.title} else { textatt = string (adratts [1])}}}; bundle { //set decodedtext decodedtext = decode (textatt)}; bundle { //set flopmllink flopmllink = false; try { if adratts^.type == "link" { if string.lower (adratts^.url) endswith ".opml" { flopmllink = true}}}}; bundle { //set flrss flrss = false; if defined (adratts^.type) { if adratts^.type == "rss" { flrss = true}}}; bundle { //set fldirectorynode // |A directory node is one that either has subheads or links to something, meaning you can click on it and go somewhere. fldirectorynode = true; if ctsubs == 0 { if defined (adratts^.type) { if (adratts^.type != "link") and (not flrss) { fldirectorynode = false}} else { fldirectorynode = false}}}; if fldirectorynode { bundle { //set subscountstring, text, link if ctsubs > 0 { subscountstring = " (" + ctsubs + ")"} else { if flopmllink { subscountstring = " " + opmlarrowimg + ""} else { if flrss { subscountstring = " " + minixmlimg + ""} else { subscountstring = ""}}}; bundle { //set link, 6/20/05 by DW link = string.urlencode (textatt) + "/"; link = string.replaceall (link, "%2F", "&slash;")}; if defined (adratts^.type) { if adratts^.type == "link" { try { if not (string.lower (adratts^.url) endswith ".opml") { link = adratts^.url}}}}}; bundle { //set linktext, commentstring local (s = searchengine.stripmarkup (decodedtext), i); linktext = s; commentstring = ""; if flprocessperiods { for i = 1 to sizeof (s)-1 { ch = s [i]; if ch == "." { if s [i+1] == " " { linktext = string.mid (s, 1, i); commentstring = "" + string.delete (s, 1, i) + ""; break}}}}}; add ("
"); indentlevel--}; add ("")} else { local (iconstring = ""); bundle { //set iconstring if there's an xmlUrl attribute if defined (adratts^.xmlUrl) { iconstring = " " + minixmlimg + ""}}; add (" " + ++ct + ". " + linktext + "" + commentstring + subscountstring + " ")}}}; add (" " + ++ct + ". " + decodedtext + iconstring + "