Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.oldstuff.includeTextFile
on includeTextFile (fname, flEditButton=true) {
<<Changes
<<4/15/01; 12:20:14 PM by DW
<<If the file exists, include it.
<<Otherwise, look for a #includes folder, relative to the location of the file being rendered. Just pop up levels until you find one that contains the file that's being included.
on includeit (f) {
local (editbutton = "");
if flEditButton {
editbutton = radio.userInterface.editButton (f, "Edit")};
return (string (file.readwholefile (f)) + editbutton)};
if file.exists (fname) {
return (includeit (fname))};
local (pta = html.getpagetableaddress (), pc = file.getpathchar ());
local (foldernomad = file.folderfrompath (pta^.radioResponder.fileBeingRendered));
loop {
local (includefolder = foldernomad + "#includes" + pc);
if file.exists (includefolder) {
local (possiblefileforinclusion = includefolder + fname);
if file.exists (possiblefileforinclusion) {
return (includeit (possiblefileforinclusion))}}};
scriptError ("Can't include \"" + fname + "\" because there is no file with that name in the #includes folder.")}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.