Source Code for user.html.macros.glossPatcher
on glossPatcher (theString) {
«glossPatcher © 1997 by Philip Suh.
«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 1 Thu, Jul 31, 1997 at 3:34:37 PM by PS
«this script is required for user.html.macros.glossTarget
«which is available from Phil's Script Archive
«http://www.filsa.net/frontier/scripts/
«
«searches theString for [[#glossPatch xxx|yyy]]
«and generates relative href's for those references.
«If the string does not contain [[#glossPatch then
«no processing is done and theString is returned as is.
«Based on html.data.standardmacros.glossaryPatcher
«rather than operating on adrPageTable^.renderedtext,
«it works with theString that is passed to it
«
«Notes from html.data.standardmacros.glossaryPatcher
«Sun, Nov 3, 1996: if xxx is empty, just generate the URL, not an href
«This supports the JavaScript popup menu in the DaveNet website
«Author: Dave Winer, dwiner@well.com
«Mon, Jan 20, 1997 at 3:30:04 PM by PH
«Only do the work if the pref is set to true
«Thu, Jul 31, 1997 at 5:19:29 PM by PS
«I took this out of this glossPatcher script. It makes no sense
«to call a script just for gloss patching and have it defeated
« by a preference.
«The code in question:
«if not html.getPref ("useGlossPatcher")
«return
«Fri, Feb 13, 1998 at 11:09:06 PM by PS
«Adding the file extension is no longer needed in version 5
«Thanks to Vincent Knobil <knobil@ava.lelab.fr> for the bug report!
«Fri, Jan 8, 1999 at 4:47:19 PM by PS
«changes to support 5.1.5's html.getadrpagetable
«hopefully this doesn't break 4.2.3 support
local (adrPageTable);
«adrPageTable = @html.data.page «if you're using Frontier 4.2.3, uncomment this!
try { « 4.2.3 users--comment out this line
adrPageTable = html.getPageTableAddress ()}
else { « 4.2.3 users--comment out this line
try {
adrPageTable = html.data.adrpagetable} «and comment out this line!
else {
adrPageTable = @websites.["#data"]}};
while theString contains "[[#glossPatch " {
local (pattern = "[[#glossPatch ");
local (ix, ixstart, ixend);
loop {
ixstart = string.patternmatch (pattern, theString);
if ixstart == 0 {
break};
ix = ixstart + sizeof (pattern);
loop { «find the ]], when loop completes, ix points at second ]
if ix > sizeof (theString) {
ix = sizeof (theString);
break};
if string.nthchar (theString, ix) == ']' {
if string.nthchar (theString, ix - 1) == ']' {
ixend = ix;
break}};
ix++};
local (url = "", nomad = adrPageTable^.adrobject);
loop {
nomad = parentof (nomad^);
if nomad == parentOf (adrPageTable^.ftpsite^) {
break};
url = "../" + url};
local (s, linetext, patch);
s = string.mid (theString, ixstart, ixend - ixstart + 1);
s = string.delete (s, 1, sizeof (pattern));
«url = url + string.nthfield (s, '|', 2) + html.getPref ("fileExtension")
«//5.0 don't need to add the file extension anymore!
url = url + string.nthfield (s, '|', 2);
linetext = string.nthfield (s, '|', 1);
if linetext == "" {
patch = url}
else {
patch = "<a href=\"" + url + "\">" + linetext + "</a>"};
theString = string.delete (theString, ixstart, ixend - ixstart + 1);
theString = string.insert (patch, theString, ixstart)}};
return (theString)};
dialog.notify ( glossPAtcher("[[#glossPatch coreNav|coreNav.html|]]"))
Go back to the main page for this script