(* Main index page *) maintainIndex := ( Print["Creating main index page ..."]; (* dates *) cdates = shootingdata["datetime", #[[1]], #[[2]]] & /@ picsList; (*Overwrite wrong dates by a date specified in the caption*) cdates1 = DateList[datedata[#[[1]], #[[2]]]] & /@ picsList; Do[cdate = cdates[[nr]]; cdate1 = cdates1[[nr]]; cdatea = Take[cdate, 3]; cdatea1 = Take[cdate1, 3]; If[cdatea =!= cdatea1, Print["Picture ", picsList[[nr]], ": Changing date: ", cdatea, " -> ", cdatea1]; cdates[[nr, 1]] = cdatea1[[1]]; cdates[[nr, 2]] = cdatea1[[2]]; cdates[[nr, 3]] = cdatea1[[3]];], {nr, Length[picsList]}]; picDates = Transpose[{picsList, cdates}]; Do[ {{r, p}, date} = picdate; picDate[r, p] = date, {picdate, picDates}]; mushyears = Union[First /@ cdates]; {tyearmin, tyearmax} = {Min[mushyears], Max[mushyears]}; (* *) {wthmaxm, hthmaxm} = {400, 300}; xsizem1 = 400; (* Max width of pop-up thumbnail *) ysizem1 = 300; (* Max height of pop-up thumbnail *) height = 270; filesample = ToFileName[{dirwork, "templates"}, "index.htm"]; checkfile[filesample]; text = Import[filesample, "Text"]; text = StringReplace[text, {"NPICTURES" -> ToString[nPictures], "MPICTURES" -> ToString[mPictures], "NNAMES" -> ToString[nNames], "NDATES" -> ToString[nDates]}]; spanRead[text]; spanNew["topline"] = toplinefix[spanOld["topline"]]; (* Paginating to several year sets *) tyearsets = Prepend[Table[{y, y}, {y, 2017, tyearmax}], {tyearmin, 2014}]; Print["Year sets for thumbnails: ", tyearsets // TableForm]; (* Main body - giant photomontage - for each year set *) body = Table[ {ymin, ymax} = tyearset; title = label = ToString[ymin]; If[ymax != ymin, title = title <> " - " <> ToString[ymax]; title1 = "Years " <> title, title1 = "Year " <> title]; tmushpics = First /@ Select[picDates, (ymin <= ToExpression[#[[2, 1]]] <= ymax) &]; Print[" --- ", title1, ": Total of ", Length[tmushpics], " pictures of Texas mushrooms."]; tmushpics = ({r, p} = #; {toyear[r], r, p})& /@ tmushpics; set = tmushpics; mset = Length[set]; thsize = 50; columns = 20; columns = Min[columns, mset]; rows = Ceiling[Length[set]/columns]; dirmont = ToFileName[{dir0, "chron"}]; checkdir1[dirmont]; filemont = ToFileName[{dirmont}, "montage" <> label <> ".jpg"]; If[FileType[filemont] =!= File || ifRefreshMont === True, maintainMontage]; nborder = 1; montagewidth = columns (thsize + 2 nborder); montageheight = rows (thsize + 2 nborder); imgmap[tyearset] = { " label <> "\">", nf = 1; nrow = ncol = 1; Table[ xbr = (thsize + 2 nborder) ncol; ybr = (thsize + 2 nborder) nrow; x1 = ToString[xbr - thsize - nborder]; y1 = ToString[ybr - thsize - nborder]; x2 = ToString[xbr - nborder]; y2 = ToString[ybr - nborder]; nf++; ncol++; If[ncol > columns, ncol = ncol - columns; nrow++]; {y, roll, pic} = picture; mushrooms = accNamesPic[roll, pic]; href = If[mushrooms === {}, datea = dateS[picDate[roll, pic], "-"]; "date-en/" <> datea <> ".htm#r" <> roll <> "p" <> pic, (* "asergeev/pictures/archives/compress/" <> y <> "/" <> roll <> "/" <> pic <> ".htm", *) mushroom = mushrooms[[1]]; mushrooma = ToLowerCase[StringReplace[mushroom, " " -> "_"]]; "en/" <> mushrooma <> ".htm#r" <> roll <> "p" <> pic]; psize = picsize[roll, pic]; {pw, ph} = psize; {sc1, sc2} = {wthmaxm, hthmaxm}/{pw, ph}; sc = Min[sc1, sc2]; {pw2, ph2} = Round[sc {pw, ph}]; {xm, ym} = ToString /@ {pw2, ph2}; imgtrail = "ONMOUSEOVER=\"showtrail('asergeev/pictures/archives/compress/" <> y <> "/" <> roll <> "/jpeg/" <> pic <> "m.jpg'," <> xm <> "," <> ym <> ");\" " <> "ONMOUSEOUT=\"hidetrail();\""; " x1 <> "," <> y1 <> "," <> x2 <> "," <> y2 <> "\" href=\"" <> href <> "\" " <> imgtrail <> ">", {picture, tmushpics}], "" } // StringJoin; "

" <> title1 <> "

label <> ".jpg\" ALT=\"Photomontage of pictures of mushrooms in Russia. " <> title1 <> "\" BORDER=\"0\" WIDTH=\"" <> ToString[montagewidth] <> "\" HEIGHT=\"" <> ToString[montageheight] <> "\" USEMAP=\"#montage" <> label <> "\">
", {tyearset, tyearsets}] // StringJoin; spanNew["yearpics"] = body; imagemap = Table[imgmap[tyearset], {tyearset, tyearsets}] // StringJoin; spanNew["imagemap"] = imagemap; epilog = StringReplace[epilog0, {"SCRIPTNAME" -> "index", "href=\"index.htm\"" -> "href=\"#\""}]; spanNew["epilog"] = epilog; text = spanReplace[text]; file = ToFileName[dir0, "index.htm"]; Export[file, text, "Text"]; );