on walk (domain, path, adradrmatch, adrtrail, adrerrorstring=nil, adropmlurl=nil) { // Changes // 6/20/05; 5:12:57 PM by DW // Convert &slash; in the trail to /. // 5/22/05; 10:53:45 AM by DW // Accept either text (preferred) or title attributes as the key for an outline node. // 3/18/05; 6:27:54 PM by DW // Add "domain" parameter. // 3/18/05; 11:36:49 AM by DW // Add optional parameter, the address of a place to put the url of the OPML file that contains the last node in the walk. This is the URL you should link to the XML icon. // 3/15/05; 10:57:47 AM by DW // Created. on error (s) { if adrerrorstring != nil { adrerrorstring^ = "Can't display the directory because " + s + "."}}; on loadopml (opmlurl, adrnomad) { local (adrtable = @system.temp.opmlDirectory.opmls.[opmlurl]); if not defined (adrtable^) { new (tabletype, adrtable); adrtable^.ctreads = 0; adrtable^.whenLastRead = date (0)}; local (adrstruct = @adrtable^.xstruct); if not defined (adrstruct^) { local (opmltext = tcp.httpreadurl (opmlurl)); xml.compile (opmltext, adrstruct); adrtable^.ctreads++; adrtable^.whenLastRead = clock.now ()}; local (nomad = xml.getaddress (adrstruct, "opml")); nomad = xml.getaddress (nomad, "body"); adrnomad^ = nomad; if adropmlurl != nil { adropmlurl^ = opmlurl}; return (true)}; on loadrss (rssurl, adrnomad) { local (adrtable = @system.temp.opmlDirectory.opmls.[rssurl]); if not defined (adrtable^) { new (tabletype, adrtable); adrtable^.ctreads = 0; adrtable^.whenLastRead = date (0)}; local (adrstruct = @adrtable^.xstruct); if not defined (adrstruct^) { local (rsstext = tcp.httpreadurl (rssurl)); xml.compile (rsstext, adrstruct); adrtable^.ctreads++; adrtable^.whenLastRead = clock.now ()}; local (nomad = xml.getaddress (adrstruct, "rss")); nomad = xml.getaddress (nomad, "channel"); adrnomad^ = nomad; if adropmlurl != nil { adropmlurl^ = rssurl}}; on popelement () { //get the first element in the path, and delete it local (ix = string.patternmatch ("/", path), element); if ix == 0 { element = path; path = ""} else { element = string.mid (path, 1, ix-1); path = string.delete (path, 1, ix)}; return (element)}; on trailpush (s) { //s is the string displayed in the cookie crumb trail local (ix = sizeof (adrtrail^) + 1); local (adrnew = @adrtrail^.[string.padwithzeros (ix, 5)]); new (tabletype, adrnew); adrnew^.s = s; return (adrnew)}; adradrmatch^ = nil; new (tabletype, adrtrail); adrerrorstring^ = ""; local (adrdata = opmlDirectorySuite.init ()); // local (directoryname = popelement ()) local (adrdirectory = @adrdata^.directories.[domain]); if not defined (adrdirectory^) { error ("there is no top-level directory named \"" + domain + "\""); return (false)}; local (nextstep, lowernextstep, nomad, adrtrailstep, adrsub, flfoundsub); loadopml (adrdirectory^.opmlurl, @nomad); loop { nextstep = popelement (); nextstep = string.replaceall (nextstep, "&slash;", "/"); //6/20/05 by DW lowernextstep = string.lower (nextstep); bundle { //dive into links local (adratts = @nomad^.["/atts"]); if defined (adratts^) { if defined (adratts^.type) { if adratts^.type == "link" { if defined (adratts^.url) { loadopml (adratts^.url, @nomad)}}; if adratts^.type == "rss" { if defined (adratts^.xmlurl) { loadrss (adratts^.xmlurl, @nomad)}}}}}; if nextstep == "" { break}; flfoundsub = false; adrtrailstep = trailpush (nextstep); for adrsub in nomad { if typeof (adrsub^) == tabletype { adratts = @adrsub^.["/atts"]; if defined (adratts^) { // if defined (adratts^.text) // if string.lower (adratts^.text) == lowernextstep // nomad = adrsub // flfoundsub = true // break // local (s, flhavestring = false); bundle { //set s, flhavestring, 5/22/05; 10:55:05 AM by DW if defined (adratts^.text) { flhavestring = true; s = string.lower (adratts^.text)} else { if defined (adratts^.title) { flhavestring = true; s = string.lower (adratts^.title)}}}; if flhavestring { if s == lowernextstep { nomad = adrsub; flfoundsub = true; break}}}}}; if not flfoundsub { error ("there is no sub-head named \"" + nextstep + "\""); return (false)}; adrtrailstep^.nomad = nomad}; adradrmatch^ = nomad; return (true)}; bundle { //test code local (adrmatch, es, adrtrail = @scratchpad.trail); local (path = "About%20this%20site/RSS%20in%20directories/Scripting%20News%20RSS%20feed/"); path = string.urldecode (path); // path = scratchpad.odwparams.path walk ("test.opml.org", path, @adrmatch, adrtrail, adrerrorstring:@es); // edit (@scratchpad.trail) edit (adrmatch); if es != "" { dialog.alert (es)}}