Show Script
Showing code for: includes/walk.irev
Back
<?rev
-- This needs the files.irev file to be included before this file
function walkDir pFolder, pShowNames, pSortIndexFirst
put empty into tList
set defaultFolder to pFolder
put "http://" & $_SERVER["SERVER_NAME"] into tRoot
put the long files into fList
repeat for each line fLine in fList
if char 1 of fLine <> "." then
put item 1 of fLine into fData
put pFolder & "/" & fData after tList
put ".irev,.html" into tWebPages
if pShowNames = true and char -5 to -1 of fData is among the items of tWebPages then
put comma & pageTitle(pFolder & "/" & fData, true) after tList
end if
put cr after tList
end if
end repeat
if pShowNames = true then
if pSortIndexFirst = true then
-- fool the sort into putting index files first
replace "index.irev," with "index.irev,aaaaaa" in tList
replace "index.html," with "index.html,aaaaaa" in tList
sort lines of tList by item 2 of each
replace "index.irev,aaaaaa" with "index.irev," in tList
replace "index.html,aaaaaa" with "index.html," in tList
else
sort lines of tList by item 2 of each
end if
else
sort lines of tList
end if
put the folders into tFolderList
sort lines of tFolderList
repeat for each line x in tFolderList
if char 1 of x <> "." then
put walkDir(pFolder & "/" & x, pShowNames, pSortIndexFirst) after tList
end if
end repeat
return tList
end walkDir
-- pType can be noimages, web or all
-- pShowNames makes it look up the title or h1 of each web page
-- pSortIndexFirst sets whether the index files are to be moved to the top of the sorted lists
function listAllFiles pType, pShowNames, pSortIndexFirst
-- store the original default folder
put the defaultFolder into tOldDefault
put $_SERVER["DOCUMENT_ROOT"] into tRoot
put walkDir(tRoot, pShowNames, pSortIndexFirst) into tList
if pType = "noimages" then
-- get rid of all image files
put ".png,.gif,.jpg,.jpeg,.tif,.tiff,.ico" into tExcludes
repeat for each item i in tExcludes
filter tList without "*" & i
end repeat
else if pType = "web" then
-- get rid of the includes files
filter tList without "*includes/*"
-- restrict the list to these file extensions only
put ".irev,.html,.php,.htm" into tIncludes
put empty into tNewList
repeat for each item i in tIncludes
put tList into temp
filter temp with "*" & i & "*"
put temp & cr after tNewList
end repeat
put tNewList into tList
end if
filter tList without empty
-- in this sample include, only show other sample files
filter tList with "*/samples/*"
set the defaultFolder to tOldDefault
-- the files are listed as something like:
-- /home/troz/troz.net/onrev/index.irev
-- and need to be shortened to /onrev/index.irev
put $_SERVER["DOCUMENT_ROOT"] into tRoot
replace tRoot with empty in tList
return tList
end listAllFiles