Source Code for user.html.macros.yahooPaths

on yahooPaths (prefix="", suffix="", divider = " | ", useFolderNames=true, adrTopTable=@root, caseConvert=true, usePageTitle=true) {
     «yahooPaths © 1997-99 by Philip Suh <phil@filsa.net>.
          «Terms of Use:
               «Permission granted to use and redistribute this script
               «only if this documentation and copyright statement are
               «included and unmodified.  Use of this script is governed
               «by the full copyright statement, available from the Script Archive.
          «From the filsa.net Frontier Script Archive:
               «Full documentation, updates, and other scripts are available from
               «http://www.filsa.net/frontier/scripts/
          «Docs -- version 6 Tue, Jan 19, 1999 at 3:01:43 PM by PS.
               «Creates yahoo-style directory paths for easy navigation
               «Based on the names of the subfolders.
                    «I break apart innerCase folder names, ie:
                    «"webRelated" becomes "Web Related"
                    «you can turn off this feature by setting the caseConvert parameter to false
               «or based on titles of the default files
                    «turn this on by setting
                    « useFolderNames to false
               «
               «prefix and suffix allow you to insert HTML before and after
               «each path item.  
               «
               «Sat, Jan 10, 1998 at 11:56:42 PM by PS
                    «Support for Frontier 5
               «Tue, Mar 3, 1998 at 7:49:16 AM by PS
                    «Removed dependency on glossRename--now uses glossSub
               «Tue, Apr 7, 1998 at 6:35:31 PM by PS
                    «added adrTopTable parameter
                    «allows you to specify a top level table at which yahooPaths
                    «bails out.  Useful if you want to yahooPath in a deep website, but 
                    «not have the navigation go all the way out to the root of your site
                    «optional, defaults to @root
               «Wed, Apr 22, 1998 at 3:46:49 AM by PS
                    «Major clean up of the code
                         «Heath Tanner's directoryPaths inspired this
                    «now using more efficient html.getpagepref ()
                    «now only works with Frontier 5
                    «Bug fix:
                         «If the object with a title was the last item  (or only) in a table,
                         «the loop would exit without detecting that a title had been found
                         «giving the irritating error message "No object with a #title in " + xxx
                         «My bad!  It's been fixed.
                         «Thanks to Collin Ong for finding this.
               «Tue, Jan 19, 1999 at 2:29:00 PM by PS
                    «Bug fix - pages
                    «caseConvert
               « Sat, Jan 9, 1999 at 6:44:50 PM by PS
                    «change to support guest databases
               «Tue, Jan 19, 1999 at 3:00:52 PM by PS
                    «caseConvert parameter
                         «allows you to turn off innercaseName
                         «feature requested by Chris Janton
                    «usePageTitle parameter
                         «bug fix - reported by Ian D. Beatty
                              «regardless of the useFolderName param,
                              «the last part of the yahooPaths click trail would always
                              «be the current page name
                         «I liked this bug, so I made it optional
                              «set the usePageTitle param to false
                              «if you want the actual page object name
     
     local (adrPageTable);
     try { // Fri, Jan 8, 1999 at 2:39:18 PM by PS
          adrPageTable = html.getPageTableAddress ()}
     else {
          try {
               adrPageTable = html.data.adrPageTable}
          else {
               adrPageTable = @websites.["#data"]}};
     
     local (indexPage = user.html.prefs.defaultfilename);
     local (textToReturn="", nomad, glossRef="", ix);
     
     on add (s) {
          «build the clicktrail backwards
               «going backwards is often the secret to solving thorny scripting problems
          textToReturn = s + textToReturn};
     on convertInnerCaseName (s) {
          if not caseConvert { « Jan 19, 1999 PS
               return (s)};
          local (aName);
          aName = string.upper (s[1]); «capitalize first char
          for i = 2 to sizeOf(s) {
               if (s[i] >= 'A') and (s[i] <= 'Z') { «uppercase
                    aName = aName + " " + string.upper (s[i]);
                    continue};
               if s[i] == '_' {
                    aName = aName + " ";
                    continue};
               aName = aName + s[i]};
          return (aName)};
     
     nomad = adrPageTable^.adrObject;
     
     «handle adrobject
     if nameOf (nomad^) == indexPage {
          «special case: the default file in the folder
               «so we bump up and use the parent folder name
               «Sun, May 10, 1998 at 2:38:38 PM by PS
                    «changed to use the index page's name
                    «nomad is notched up to skip the parent folder instead
                    «hope for a descriptive title here
               «Tue, Jun 2, 1998 at 1:56:44 PM by PS
                    «Change the behaviour here
                    «If useFolderNames is on, we do things as before
                    «else we use the page name
          nomad = parentOf (nomad^);
          if useFolderNames {
               add (prefix +  convertInnerCaseName ( nameOf (nomad^) ) + suffix)}
          else {
               add (prefix + adrPageTable^.title + suffix)}}
     else {
          if defined (adrPageTable^.title) and usePageTitle {
               add (prefix + adrPageTable^.title + suffix)}
          else {
               add (prefix + convertInnerCaseName ( nameOf( nomad^ ) ) + suffix)}};
     
     «main loop
     while nomad != adrPageTable^.adrSiteRootTable {
          if nomad == adrTopTable or nomad == "" { // 1/9/99 PS - fix for guest databases
               break}; «allows user to specify top level that yahooPaths checks for links
          nomad = parentOf (nomad^);
          if defined (nomad^.[indexPage]) { «point to default page
               glossRef = html.getPagePref ("title", @nomad^.[indexPage],  adrPageTable);
               if glossRef == "" {
                    scripterror ("yahooPaths: Can't find a #title for " + nomad + "." + indexPage)}}
          else { «or, if there's no default, the first page with a title
               for ix = 1 to sizeOf (nomad^) {
                    if typeOf (nomad^[ix]) == tabletype || nameOf (nomad^[ix]) beginsWith "#" {
                         continue};
                    try {
                         glossRef = html.getPagePref ("title", @nomad^[ix++], adrPageTable); «5.0.2b10#79
                         «glossRef = html.getOneDirective ("title", string(nomad^[ix++])) «old code
                              «use of html.getOneDirective is deprecated--getPagePref is the way to go here.
                              «Tue, Apr 21, 1998 at 4:15:30 AM by PS}};
               if glossRef == "" {
                    scripterror ("yahooPaths: No object with a #title in " + nomad)}};
          if useFolderNames {
               local (fname = nameOf (nomad^));
               fname = convertInnerCaseName (fname);
               with html.data.standardmacros, user.html.macros, html.data.adrpagetable^.tools^ {
                    add(prefix + glossSub (glossRef, fName) + suffix + divider)}}
          else {
               add (prefix + html.refGlossary (glossRef) + suffix + divider)}};
     
     return (textToReturn)};
bundle { // test code
     html.data.adrpagetable = @websites.["#data"];
     msg(yahooPaths ( "<font size=-1>", "</font>"));
     delete (@html.data.adrpagetable)}

Go back to the main page for this script