Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.theme.apply.textFiles
on textFiles (adrTheme, folder=user.radio.prefs.wwwFolder) {
<<Changes
<<2/23/02; 7:58:33 PM by JES
<<Don't save #prefs files stored in the Theme. This fixes a problem with applying Themes to category sub-folders, where the #categoryName directive would be overwritten when the #prefs file is saved. A corresponding change is in radio.theme.create.textFiles, where #prefs files are not saved with the Theme.
<<1/1/02; 10:37:42 PM by JES
<<Delete #homeTemplate.* and #subTemplate.* before applying the Theme's text files, since the Theme might not contain those files.
<<12/30/01; 7:29:59 PM by JES
<<Apply the templates and #prefs files stored in the Theme table at adrTheme, to the specified folder.
local (adrFiles = @adrTheme^.textFiles);
local (adrFile);
bundle { //delete #homeTemplate and #subTemplate -- a Theme might not contain them
on deleteFileIgnoringExtension (fname) {
local (fileToDelete);
if radio.file.locateFileIgnoringExtension (folder + fname, @fileToDelete) {
file.delete (fileToDelete)}};
deleteFileIgnoringExtension ("#homeTemplate.txt");
deleteFileIgnoringExtension ("#subTemplate.txt")};
for adrFile in adrFiles {
local (fname = nameOf (adrFile^));
if string.lower (fname) beginsWith "#prefs." {
continue};
local (f = folder + fname);
if file.exists (f) { //skip files which already exist, and haven't changed
if file.modified (f) == timeModified (adrFile) {
if file.created (f) == timeCreated (adrFile) {
continue}}};
local (fileToReplace);
if radio.file.locateFileIgnoringExtension (f, @fileToReplace) {
file.delete (fileToReplace)};
file.writeTextFile (f, string (adrFile^));
file.setCreated (f, timeCreated (adrfile));
file.setModified (f, timeModified (adrfile))};
return (true)};
bundle { //test code
local (adrTheme = @scratchpad.testTheme);
textFiles (adrTheme, user.radio.prefs.wwwFolder + "categories:jake'sTestChannel:")}
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.