Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.weblog.file.isArchivePage
on isArchivePage (f, adrblog = radio.weblog.init ()) {
<<Changes
<<1/5/02; 4:34:05 PM by JES
<<Created.
<<Given the path to a file on disk, return true if the file is the source file for a weblog or category archive page, or false if not.
<<Parameters
<<f -- the path to the file on disk
<<adrBlog -- the address of the weblog table -- defaults to the address returned by radio.weblog.init.
on isNumeric (s) {
<<return true if all chars in s are numeric
local (ch, ct = sizeOf (s));
for i = 1 to ct {
ch = s[i];
if not string.isNumeric (ch) {
return (false)}};
return (true)};
local (pc = file.getPathChar ());
local (fname = file.fileFromPath (f));
local (nameWithoutExtension = string.popSuffix (fname));
if isNumeric (nameWithoutExtension) {
local (day = number (nameWithoutExtension));
if day > 0 and day < 32 {
local (monthFolder = file.folderFromPath (f));
local (monthName = string.popSuffix (file.fileFromPath (monthFolder), pc));
if isNumeric (monthName) {
local (month = number (monthName));
if month > 0 and month < 13 {
local (yearFolder = file.folderFromPath (monthFolder));
local (yearName = string.popSuffix (file.fileFromPath (yearFolder), pc));
if isNumeric (yearName) {
local (year = number (yearName));
if year > 1903 { //1-1-1904 is the earliest date Frontier knows about
return (true)}}}}}};
return (false)}
<<bundle //test code
<<local (f, pc = file.getPathChar ())
<<bundle //returns true
<<f = user.radio.prefs.wwwFolder + "2002" + pc + "01" + pc + "04.txt"
<<dialog.notify (isArchivePage (f))
<<bundle //returns false
<<f = user.radio.prefs.wwwFolder + "index.txt"
<<dialog.notify (isArchivePage (f))
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.