* utility to edit the Thumbnailer HTML so that if an original image exists, the normal 600x600 image links to it and says so
* Sept 27, 1999

SET DEFAULT TO t:\webhost\pod
thisdir = GETDIR("Please point to the directory where the normal web pages and images are...")
IF EMPTY(thisdir)
	WAIT WINDOW "You didn't specify a directory where the web files start..."
	RETURN
ENDIF

testfiles = ADIR(htmlfiles, thisdir + "\*.HTML","A",1)


IF testfiles < 1
	WAIT WINDOW "Didn't find any .html files in the directory " + thisdir
ELSE
	FOR i = 1 TO testfiles
		imagename = STRTRAN(ALLTRIM(htmlfiles[i,1]), ".html", "")
		IF FILE(thisdir + "\originals\" + imagename + ".jpg")
			DO htmledit WITH imagename
		ENDIF
	ENDFOR
ENDIF
RETURN


PROCEDURE htmledit
PARAMETERS in_name
WAIT WINDOW "Now changing file " + (thisdir) + in_name + ".html" NOWAIT
thispage = FILETOSTR(thisdir + "\" + in_name + ".html")
thispage = STRTRAN(thispage, "<P>" + in_name + ".jpg", [<BR>Click here for the larger original file, <A HREF="./originals/] + in_name + [.jpg" target="blank">] + in_name + [</A><P>])
*thispage = STRTRAN(thispage, "</a>" + CHR(13) + CHR(10) + "<P>" + UPPER(in_name) + ".jpg", "</a>" + CHR(13) + CHR(10) + UPPER(in_name) + ".jpg" + [<BR>Click here for the larger original file, <A HREF="./originals/] + in_name + [.jpg">] + in_name + [</A><P>])
ERASE (thisdir + "\" + in_name + ".html")
STRTOFILE(thispage, thisdir + "\" + in_name + ".html")
RETURN





PROCEDURE htmledit_old
PARAMETERS in_name
WAIT WINDOW "Now changing file " + (thisdir) + in_name + ".html" NOWAIT
CREATE CURSOR htmltemp (line1 C(200))
APPEND FROM (thisdir + "\" + in_name + ".html") TYPE SDF
* BROWSE
LOCATE FOR UPPER(line1) = "<P>" + UPPER(in_name) + ".JPG"
IF NOT "Click here for the larger original" $ line1
	REPLACE line1 WITH [<BR>Click here for the larger original file, <A HREF="./originals/] + in_name + [.jpg" target="blank">] + in_name + [</A><BR>]
	ERASE (thisdir + "\" + in_name + ".html")
	SET CONSOLE OFF
	SET ALTERNATE TO (thisdir + "\" + in_name + ".html")
	SET ALTERNATE ON
	SCAN
		?? ALLTRIM(line1)
		?
	ENDSCAN
	SET ALTERNATE OFF
	SET ALTERNATE TO
	SET CONSOLE ON
ENDIF
RETURN



PROCEDURE htmledit_ll
* oops -- this writes over the existing text
PARAMETERS in_name
thisfile = (thisdir + "\" + in_name + ".html")
testopen=FOPEN(thisfile,2)
IF testopen >=1
	WAIT WINDOW "Now changing file " + (thisfile) NOWAIT
	DO WHILE NOT FEOF(testopen)
		line1 = FGETS(testopen)
		IF lower(line1) = LOWER("<br>" + in_name + ".JPG")
			WAIT WINDOW "About to change " + ALLTRIM(line1) + CHR(13) + " to " + SUBSTR(line1,1,4) + [Click here for the larger original file, <A HREF="] + LOWER(STRTRAN(thisdir, "D:\WEBHOST", "/") + "originals/" + in_name + ".jpg") + [">] + ALLTRIM(SUBSTR(line1,5)) + [</A>]
			testwrite = FPUTS(testopen, SUBSTR(line1,1,4) + [Click here for the larger original file, <A HREF="] + LOWER(STRTRAN(thisdir, "D:\WEBHOST\", "/") + "originals/" + in_name + ".jpg") + [">] + ALLTRIM(SUBSTR(line1,5)) + [</A><] + CHR(13))
			IF testwrite < 1 
				WAIT WINDOW "Didn't rewrite the HTML file..."
			ENDIF
			EXIT
		ENDIF
	ENDDO
ELSE
	WAIT WINDOW "Couldn't open " + thisfile
ENDIF
=FCLOSE(testopen)
RETURN


