(* Main index file *)
maintainIndex := (
{wthmaxm, hthmaxm} = {400, 300};
Print["Creating main index file ..."];
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"];
spanRead[text];
spanNew["topline"] = toplinefix[spanOld["topline"]];
mushyears = Union[ryears];
(* Paginating to several year sets *)
(*ryearsets = Prepend[Table[{y, y}, {y, 2016, ryearmax}], {2003, 2015}];*)
ryearsets = Join[{{2003, 2015}, {2016, 2016}, {2017, 2017}, {2018, 2018}, {2019, 2021}}, Table[{y, y}, {y, 2022, ryearmax}] ];
Print["Year sets for thumbnails: ", ryearsets // TableForm];
(* Main body - giant photomontage - for each year set *)
body = Table[
{ymin, ymax} = ryearset;
title = label = ToString[ymin];
If[ymax != ymin, title = title <> " - " <> ToString[ymax];
title1 = "Years " <> title, title1 = "Year " <> title];
rmushpics =
Select[rmushpictures, (ymin <= ToExpression[#[[1]]] <= ymax) &];
Print[" --- ", title1, ": Total of ", Length[rmushpics],
" pictures of Russian mushrooms."];
set = rmushpics;
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[ryearset] = {
""
} // StringJoin;
"
" <> title1 <> "

label <> ".jpg\" ALT=\"Photomontage of pictures of mushrooms in Russia. " <> title1 <> "\" BORDER=\"0\" WIDTH=\"" <> ToString[montagewidth] <>
"\" HEIGHT=\"" <> ToString[montageheight] <> "\" USEMAP=\"#montage" <> label <> "\">
", {ryearset, ryearsets}] // StringJoin;
spanNew["yearpics"] = body;
imagemap = Table[imgmap[ryearset], {ryearset, ryearsets}] // 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"];
(* ----------- The same for Russian language *)
filesample = ToFileName[{dirwork, "templates"}, "index-ru.htm"];
checkfile[filesample];
text = Import[filesample, "Text"];
spanRead[text];
spanNew["topline"] = toplinefix[spanOld["topline"]];
(* Main body - giant photomontage - for each year set *)
body = Table[
{ymin, ymax} = ryearset;
title = label = ToString[ymin];
If[ymax != ymin, title = title <> " - " <> ToString[ymax];
title1 = "Годы " <> title, title1 = "Год " <> title];
rmushpics =
Select[rmushpictures, (ymin <= ToExpression[#[[1]]] <= ymax) &];
Print[" --- ", title1, ": Total of ", Length[rmushpics],
" pictures of Russian mushrooms."];
set = rmushpics;
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"];
(* Already done for English version! If[FileType[filemont] =!= File || ifRefreshMont === True, maintainMontage];*)
nborder = 1;
montagewidth = columns (thsize + 2 nborder);
montageheight = rows (thsize + 2 nborder);
imgmap[ryearset] = {
""
} // StringJoin;
"" <> title1 <> "

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