Monday, November 08, 2010 at 12:05 AM.

on images (adrTheme) {
		<<1/24/02; 5:10:50 PM by JES
			<<Add images referenced by imageRef macros, used in the day- and item-level permalinks, and the source and enclosure image prefs.
		<<12/31/01; 7:26:34 PM by JES
			<<Set  pagetable.processMacrosInHtmlTags to true, so we pick up images referenced by URL inside the tags.
		<<12/30/01; 5:50:38 PM by JES
			<<Simulate rendering of the templates stored in adrTheme, in order to get a table of all the image files, and then load the image files into the Theme table at adrTheme.
			<<Call this script after calling radio.theme.loadTextFiles.
	local (adrImages = @adrTheme^.images);
	new (tableType, adrImages);
	local (pc = file.getPathChar (), imageFileList = {});
	on getImagePathsFromTemplate (adrTemplate) {
		local (s = string (adrTemplate^));
		local (pagetable); new (tableType, @pageTable);
		bundle { //process macros in the template to get the image file paths
			pagetable.macroStartCharacters = "<%";
			pagetable.macroEndCharacters = "%>";
			pagetable.processMacrosInHtmlTags = true;
			pagetable.adrObject =;
			new (tableType, @pagetable.radioResponder);
			pagetable.radioResponder.flImagePatching = true;
			pagetable.radioResponder.flSameMachine = true;
			local (oldPta);
			try {
				oldPta = html.getPageTableAddress ()};
			html.setPageTableAddress (@pageTable);
			s = html.processMacros (s, true, @pagetable);
			html.deletePageTableAddress ();
			if oldPta != nil {
				html.setPageTableAddress (oldPta)}};
		local (systemFolderRelPath = + pc);
		if defined (pagetable.radioResponder.imageFiles) {
			local (adrfile);
			for adrfile in @pagetable.radioResponder.imageFiles {
				local (relpath = nameOf (adrfile^));
				if not (relpath beginsWith systemFolderRelPath) {
					if not (imageFileList contains relpath) {
						imageFileList = imageFileList + relpath}}}};
		return (imageFileList)};
	local (adrTemplate, adrTemplates = @adrTheme^.textFiles);
	for adrTemplate in adrTemplates {
		getImagePathsFromTemplate (adrTemplate)};
	bundle { //get images referenced in weblogData.prefs
		local (adrblog = radio.weblog.init ());
		getImagePathsFromTemplate (@adrblog^.prefs.archiveLinkImgTag);
		getImagePathsFromTemplate (@adrblog^.prefs.itemPermaLinkImgTag);
		getImagePathsFromTemplate (@adrblog^.prefs.enclosureImgTag);
		getImagePathsFromTemplate (@adrblog^.prefs.sourceImgTag)};
	local (relpath);
	for relpath in imageFileList {
		local (f = + relPath);
		local (slashDelimitedPath = string.replaceAll (relPath, pc, "/"));
		local (adrimage = @adrImages^.[slashDelimitedPath]);
		new (tableType, adrimage);
		adrimage^.bits = file.readWholeFile (f);
		adrimage^.timeCreated = file.created (f);
		adrimage^.timeModified = file.modified (f)};
	return (true)};

bundle { //test code
	local (adrTheme = @scratchpad.testTheme);
	images (adrTheme);
	edit (adrTheme)}

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.