Clear["@"]; test=True; (* uncomment for testing *) mroll=100; (* max. possible number of rolls *) myear=1999; (* the last year *) dir0="e:\\html\\pictures\\archives"; BeginPackage["flankblank`"] flankblank::usage = "Eliminate flanking blanks or new-lines of a string." Begin["`private`"] flankblank[s_String]:= If[s=="",s, If[s0=StringTake[s,1];s0==" "||s0=="\n",flankblank[StringDrop[s,1]], If[s9=StringTake[s,-1];s9==" "||s9=="\n",flankblank[StringDrop[s,-1]],s]]] End[] EndPackage[] (* icon's src *) dot0="'../../dot0.gif'"; dot1="'../../dot1.gif'"; dot2="'../../dot2.gif'"; right0="'../../right0.gif'"; right1="'../../right1.gif'"; right2="'../../right2.gif'"; left0="'../../left0.gif'"; left1="'../../left1.gif'"; left2="'../../left2.gif'"; dot0a="'../../dot0a.gif'"; dot1a="'../../dot1a.gif'"; right0a="'../../right0a.gif'"; right1a="'../../right1a.gif'"; left0a="'../../left0a.gif'"; left1a="'../../left1a.gif'"; dots="'../../dots.gif'"; blanksrc="'../../../../../blank.gif'"; (* *) If[test,{mroll,myear}={2,1996}]; npic=0; Do[ (* year *) year=ToString[nyear]; Do[ (* roll *) roll=ToString[nroll]; dirslide=ToFileName[{dir0,"compress",year,roll,"jpeg"}]; If[SetDirectory[dirslide]!=StringDrop[dirslide,-1],Goto[1]]; fnames=FileNames["*.jpg"]; mf=Length[fnames]; (* Cycling through images *) Do[fname=fnames[[nf]]; fn=StringDrop[fname,-4]; If[StringLength[fn]>3,Goto[2],npic++]; years[npic]=year;rolls[npic]=roll;numbers[npic]=fn; Label[2],{nf,mf}]; Label[1],{nroll,mroll}],{nyear,1996,myear}]; mpic=npic; Clear[npic]; rolls[0]="START";rolls[mpic+1]="END"; dotpas[npic_]:= If[rolls[npic]!=rolls[npic-1],If[npic==npic0,right2,If[rolls[npic]==roll0,right1,right0]], If[rolls[npic]!=rolls[npic+1],If[npic==npic0,left2,If[rolls[npic]==roll0,left1,left0]], If[npic==npic0,dot2,If[rolls[npic]==roll0,dot1,dot0]] ] ]; dotact[npic_]:= If[rolls[npic]!=rolls[npic-1],If[rolls[npic]==roll0,right1a,right0a], If[rolls[npic]!=rolls[npic+1],If[rolls[npic]==roll0,left1a,left0a], If[rolls[npic]==roll0,dot1a,dot0a] ] ]; dotact1[npic_]:= If[rolls[npic]!=rolls[npic-1],right2, If[rolls[npic]!=rolls[npic+1],left2, dot2 ] ]; dotpas[0]=dotact[0]=dotpas[mpic+1]=dotact[mpic+1]=blanksrc; Do[ year=years[npic];roll=rolls[npic];fn=numbers[npic]; {roll0,npic0}={roll,npic}; (***********) (* Reading the title of the roll and the title of the slide from the file captions.txt *) fn1=StringReplace[fn,"000"->"-1"]; nfn=ToExpression[fn1]; filecapt=ToFileName[{dir0,year,roll},"captions.txt"]; data=ReadList[filecapt,Record,RecordSeparators -> {"#"}]; mrec=Length[data]; rolltitle=gcaption=caption=""; Do[rec=data[[nrec]]; pos=StringPosition[rec,{" ","\n",":"}]; n=pos[[1,1]]; head=StringTake[rec,n-1]; sep=StringTake[rec,{n,n}]; content=StringDrop[rec,n]//flankblank; (*Print[head];Print[sep];Print[content];*) If[head=="ROLL", If[rolltitle!="",Print["WARNING: several titles for the same roll encountered in the caption file "<>capt]]; rolltitle=content;Goto[9]]; If[sep=="\n"||sep==" ", If[head==fn, If[caption!="",Print["WARNING: several captions for the same slide "<>fn<>" encountered in the caption file "<>capt]]; caption=content;Goto[9]]]; If[sep==":", head1=StringReplace[head,{"000"->"-1","-"->"+"}]; range=Flatten[Release[ToExpression["{"<>head1<>"}",InputForm,Hold]/.Plus->Range]]; If[MemberQ[range,nfn], gcaption=gcaption<>"
\n"<>content;Goto[9]]]; Label[9],{nrec,mrec}]; gcaption=flankblank[gcaption]; gcapt=StringReplace[gcaption,{" "->"","""->"","\n"->" "}]; While[StringMatchQ[gcapt,"*<*>*"], n1=StringPosition[gcapt,"<"][[1,1]]; n2=StringPosition[gcapt,">"][[1,1]]; gcapt=If[n1"<>rolltitle,""]; (* For testing Print[" ------"]; Print[rolltitle]; Print[" ------"]; Print[caption]; Print[" ------"]; Print[gcaption]; Print[" ------"]; Print[gcapt]; *) (* End reading from capt *) (***********) mdots=20; (* number of dots on both sides from the central dot *) of=OpenWrite[ToFileName[{dir0,"compress",year,roll},fn<>".htm"],PageWidth->Infinity]; Write[of,""//OutputForm]; Write[of,""//OutputForm]; Write[of,""<>rolltitle<>": Slide #"<>fn<>"-"<>roll<>""//OutputForm]; Write[of,""//OutputForm]; Write[of,"cap<>"\">"//OutputForm]; (* Definition of over and out starts *) over=out=""; Do[ipic=npic+i; rolli=rolls[ipic]; If[rolli==roll&&i!=0, over=over<>"document."<>If[i<0,"l","r"]<>ToString[Abs[i]]<>".src="<>dotact1[ipic]<>"; "; out =out <>"document."<>If[i<0,"l","r"]<>ToString[Abs[i]]<>".src="<>dotpas[ipic] <>"; "; ] ,{i,-mdots,mdots}]; (* Definition of over and out endss *) ldprev=ldnext=" "; If[npic>1, yearpr=years[npic-1];rollpr=rolls[npic-1];fnpr=numbers[npic-1]; ldprev="document.prev.src='../../"<>yearpr<>"/"<>rollpr<>"/jpeg/"<>fnpr<>".jpg'; " ]; If[npicyearne<>"/"<>rollne<>"/jpeg/"<>fnne<>".jpg'; " ]; Write[of,"ldnext<>ldprev<>"\">"//OutputForm]; (* Table begins *) (* T0 *) Write[of,"\n \n "//OutputForm]; (* T1 T2 *) Write[of,"
"//OutputForm]; (* Slide *) bc=Floor[FileByteCount[ToFileName[{dir0,year,roll,"jpeg"},fn<>".jpg"]]/1000]; Write[of,"

year<>"/"<>roll<>"/jpeg/"<>fn<>".jpg\">year<>"/"<>roll<>"/jpeg/"<>fn<>".jpg\" WIDTH=376 HEIGHT=376 BORDER=0 ALT=\"Click to view full-size image of this slide ("<>fname<>").\">
"//OutputForm]; Write[of,"Click to view full-size image ("<>ToString[bc]<>" KB)

 \n
\n \n \n "//OutputForm]; (* /T2 /T1 *) Write[of,"
"//OutputForm]; blank="

"; (* Prev. image *) prev=If[npic==1,blank, If[rollpr==roll,"

yearpr<>"/"<>rollpr<>"/"<>fnpr<>".htm\" onMouseOver=\"document.l1.src="<>dotact[npic-1]<>"\" onMouseOut=\"document.l1.src="<>dotpas[npic-1]<>"\">\"#"<fnpr<>"-"<>rollpr<>" <---\">
Previous

", "

yearpr<>"/"<>rollpr<>"/"<>fnpr<>".htm\" onMouseOver=\"document.l1.src="<>dotact[npic-1]<>"\" onMouseOut=\"document.l1.src="<>dotpas[npic-1]<>"\">\"#"<fnpr<>"-"<>rollpr<>" <--- to the end of the previous roll\">
Previous roll of film

" ]]; Write[of,prev//OutputForm]; (* *) Write[of,"
"//OutputForm]; (* Next image *) next=If[npic==mpic,blank, If[rollne==roll,"

yearne<>"/"<>rollne<>"/"<>fnne<>".htm\" onMouseOver=\"document.r1.src="<>dotact[npic+1]<>"\" onMouseOut=\"document.r1.src="<>dotpas[npic+1]<>"\">\"--- #"<>fnne<>"-"<>rollne<>"\">
Next

", "

yearne<>"/"<>rollne<>"/"<>fnne<>".htm\" onMouseOver=\"document.r1.src="<>dotact[npic+1]<>"\" onMouseOut=\"document.r1.src="<>dotpas[npic+1]<>"\">\"--- #"<>fnne<>"-"<>rollne<>" start the next roll\">
Next roll of film

" ]]; Write[of,next//OutputForm]; (* *) (* T3 *) Write[of,"
"//OutputForm]; (* Ruler of images *) If[npic>mdots+1,Write[of,""//OutputForm], Write[of,""//OutputForm] ]; Do[ If[i==0, Write[of,""//OutputForm], ipic=npic+i; If[ipic<1||ipic>mpic, Write[of,""//OutputForm], Write[of,""//OutputForm] ] ] ,{i,-mdots,mdots}]; If[npic"//OutputForm], Write[of,""//OutputForm] ]; (* Ruler ends *) (* /T3 T3a /T3a *) Write[of,"
\"Currentfn<>"-"<>roll<>"\">If[i<0,"l","r"]<>ToString[Abs[i]]<>"\" WIDTH=7 HEIGHT=7 BORDER=0>years[ipic]<>"/"<>rolls[ipic]<>"/"<>numbers[ipic]<>".htm\" onMouseOver=\"document."<>If[i<0,"l","r"]<>ToString[Abs[i]]<>".src="<>dotact[ipic]<>"\" onMouseOut=\"document."<>If[i<0,"l","r"]<>ToString[Abs[i]]<>".src="<>dotpas[ipic]<>"\">If[i<0,"l","r"]<>ToString[Abs[i]]<>"\" WIDTH=7 HEIGHT=7 BORDER=0 ALT=\"#"<>numbers[ipic]<>"-"<>rolls[ipic]<>"\">
\n year<>"/"<>roll<>"/browser.htm\" onMouseOver=\""<>over<>"\" onMouseOut=\""<>out<>"\">Current roll of film:
"<>rolltitle<>"
\n
"//OutputForm]; (* No-script notice *) Write[of,""//OutputForm]; (* Title *) Write[of,""//OutputForm]; Write[of,"

"<>capt<>"

#"<>fn<>"-"<>roll<>rolltit<>"

"//OutputForm]; Write[of,"
"//OutputForm]; (* Table ends *) Write[of,"
"//OutputForm]; (* References *) Write[of,"

"//OutputForm]; (*Write[of,""//OutputForm];*) Write[of,""//OutputForm]; Write[of,""//OutputForm]; Write[of,""//OutputForm]; Write[of,""//OutputForm]; Write[of,""//OutputForm]; Write[of,""//OutputForm]; Write[of,"
year<>"/"<>roll<>"/browser.htm\">This roll of film:\n
"<>rolltitle<>"
year<>"/list.htm\">Pictures-"<>year<>"Picture ArchivesSelected PicturesRandom Slide ShowDirectory of filesA. Sergeev

"//OutputForm]; Write[of,""//OutputForm]; Print["Roll #"<>roll<>" Slide #"<>fn<>" --- Picture #",npic]; Close[of],{npic,mpic}];