(* Web page for a given date *) maintainDate := ( Print["Running maintainDate ..."]; filesample = ToFileName[{dirwork, "templates"}, "date.htm"]; checkfile[filesample]; text0 = Import[filesample, "Text"]; dateset = First /@ csubsets; Do[ {date, set} = csubset; place = placeprint[date]; datefull = DateString[date, {"MonthName", " ", "DayShort", ", ", "Year", " (", "DayName", ")"}]; (* datefull = ToString[date[[3]]] <> " " <> rusmonths[[date[[2]]]] <> " " <> ToString[date[[1]]] <> " \:0433\:043e\:0434\:0430"; *) sd = (" dateS[#, "-"] <> ".htm\">" <> dateS[#, "-"] <> "")&/@dateset; msd = Length[dateset]; n0 = Position[dateset, date][[1, 1]]; dn = 6; sd[[n0]] = "" <> dateS[date, "-"] <> ""; If[n0 - dn > 1, nmin = n0 - dn; sd[[nmin]] = "...", nmin = 1; ]; If[n0 + dn < msd, nmax = n0 + dn; sd[[nmax]] = "...", nmax = msd; ]; sd = Take[sd, {nmin, nmax}]; nearestdates = StringJoin[Riffle[sd, " "]]; text = StringReplace[text0, { "NEARESTDATES" -> nearestdates, "APIKEY" -> apikey, "NAMERULAT" -> datefull, "TOPNAME" -> dateS[date, "-"], "SPECLOWERUND" -> dateS[date, "-"] }]; spanRead[text]; spanNew["prev"] = If[n0 > 1, dateprev = dateset[[n0 - 1]]; dateprev = dateS[dateprev, "-"]; StringReplace[spanOld["prev"], "DATEPREV" -> dateprev], ""]; spanNew["next"] = If[n0 < msd, datenext = dateset[[n0 + 1]]; datenext = dateS[datenext, "-"]; StringReplace[spanOld["next"], "DATENEXT" -> datenext], ""]; spanNew["topline"] = toplinefix[spanOld["topline"]]; spanNew["place"] = If[Head[place] === String && place =!= "", StringReplace[spanOld["place"], "PLACE" -> place], ""]; epilog = StringReplace[epilog0, {"program/sub/maintain-SCRIPTNAME" -> "../program/sub/maintain-date", "asergeev/" -> "../asergeev/", "\"program.htm" -> "\"../program.htm", "\"index" -> "\"../index", "background:url(" -> "background:url(../"}]; (* Weather *) weather = ""; maintainWeatherDate[date]; If[wtemp =!= "" && Head[wtemp] === String, url = StringReplace[wLink, "YEAR-MONTH-DAY" -> dateS[date, "-"]]; weather = "
Weather (" <> " url <> "\">" <> wStation <> "): " <> capitalize[wcond] <> wtemp <> wwind <> wprec <> "
"; ]; spanNew["weather"] = weather; (* *) names = accNamesPic[#[[2]], #[[3]]]&/@ set; spanNew["names"] = If[Flatten[names] === {}, "No identified species.
", picnames = Transpose[{set, names}]; names = Union[Flatten[names]]; names = Table[ {{y, r, p}, nm} = Select[picnames, MemberQ[#[[2]], name]&][[1]]; alabel = "r" <> r <> "p" <> p; " alabel <> "\">" <> name <> "", {name, names}]; names = StringJoin[Riffle[names, ", "]]; "Identified species: " <> names <> "."];
(*Print[date, " -> ", spanNew["names"]];*)
(* *)
spanNew["epilog"] = epilog;
picture0 = spanOld["pictures"];
pictures = Table[
{year, roll, pic} = pict;
capt = picCaption[roll, pic];
(*date = datedata[roll, pic] // DateList;*)
psize = picsize[roll, pic];
{xsize, ysize} = psize;
(*{year, roll, pic, capt, xsize, ysize, date, pop} = dat;*)
alabel = "r" <> roll <> "p" <> pic;
names = accNamesPic[roll, pic];
repls = Table[
namehtm = StringReplace[ToLowerCase[name], " " -> "_"] <> ".htm";
nameonpic = nameOnPic[name, {roll, pic}];
(nameonpic -> " namehtm <> "\">" <> name <> ""), {name, names}];
capt0 = capt;
capt = StringReplace[capt, repls];
(* picture = StringReplace[picture0, {"YEAR" -> year, "ROLL" -> roll, "PIC" -> pic}]; *)
link = "../asergeev/pictures/archives/compress/" <> year <> "/" <> roll <> "/" <> pic <> ".htm";
linkjpg = "../asergeev/pictures/archives/" <> year <> "/" <> roll <> "/jpeg/" <> pic <> ".jpg";
filejpg = ToFileName[{dir00, "pictures", "archives", year, roll, "jpeg"}, pic <> "b.jpg"];
If[FileType[filejpg] === File, linkjpg = "../asergeev/pictures/archives/" <> year <> "/" <> roll <> "/jpeg/" <> pic <> "b.jpg"];
slink = "../asergeev/pictures/archives/compress/" <> year <> "/" <> roll <> "/" <> pic <> ".htm";
capt1 = " link <> "\" TARGET=\"_blank\" TITLE=\"Photo " <> roll <> "-" <> pic <>
"\">" <> capt;
(* Location. May be later: shooting data and extra large size *)
filehtm = ToFileName[{dir00, "pictures", "archives", "compress", year, roll}, pic <> ".htm"];
capt2 = "";
If[FileType[filehtm] === File, texthtm = Import[filehtm, "Text"];
match = "