(* 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 <> "\">\"Link\"" <> 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 = ""; s = StringCases[texthtm, match]; If[s =!= {}, s = s[[1]]; s = StringReplace[s, {"../../../../../" -> "../asergeev/", "sh('" ~~ Shortest[x___] ~~ "');" -> "", "" -> "", "staticmap?maptype" -> "staticmap?" <> "key=" <> apikey <> "&" <> "maptype", "

"" -> "", "margin-bottom:2px;" -> "margin-bottom:0px;"}]; capt2 = capt2 <> s; geolocat = StringReplace[s, Longest[x__] ~~ "&locat=" -> ""]; geolocat = StringReplace[geolocat, "&delay=" ~~ Longest[x__] -> ""]; geolocat = ToExpression["{" <> geolocat <> "}"]; ]; ]; If[capt2 =!= "", capt1 = capt1 <> "
" <> capt2]; xscale = xsizem1/xsize; yscale = ysizem1/ysize; scale = Min[xscale, yscale]; xm = Round[scale xsize]; ym = Round[scale ysize]; wthmaxt = 800; hthmaxt = 600; {pw, ph} = {xsize, ysize}; {sc1, sc2} = {wthmaxt, hthmaxt}/{xsize, ysize}; sc = Min[sc1, sc2]; {pwr, phr} = Round[sc {xsize, ysize}]; imgtrail = "ONMOUSEOVER=\"showtrail('../asergeev/pictures/archives/compress/" <> year <> "/" <> roll <> "/jpeg/" <> pic <> "m.jpg'," <> ToString[xm] <> "," <> ToString[ym] <> ");" <> "\" ONMOUSEOUT=\"hidetrail();\""; link800 = "../asergeev/pictures/archives/compress/" <> year <> "/" <> roll <> "/jpeg/" <> pic <> "x.jpg"; link1200 = "../asergeev/pictures/archives/" <> year <> "/" <> roll <> "/jpeg/" <> pic <> ".jpg"; link600 = "../asergeev/pictures/archives/compress/" <> year <> "/" <> roll <> "/jpeg/" <> pic <> "l.jpg"; link400 = "../asergeev/pictures/archives/compress/" <> year <> "/" <> roll <> "/jpeg/" <> pic <> "m.jpg"; link240 = "../asergeev/pictures/archives/compress/" <> year <> "/" <> roll <> "/jpeg/" <> pic <> "t.jpg"; img0 = " link800 <> "\" BORDER=\"0\" ALT=\"" <> addsymb[capt0] <> "\">"; (* "\" BORDER=\"0\" HEIGHT=\"" <> ToString[phr] <> "\" WIDTH=\"" <> ToString[pwr] <> "\">
"; *) pictureset = "" <> " link400 <> "\" media=\"(max-width: 400px)\"> link600 <> "\" media=\"(max-width: 600px)\"> link800 <> "\"> link800 <> "\" BORDER=\"0\" ALT=\"" <> addsymb[capt0] <> "\"> "; jpg = " alabel <> "\" HREF=\"" <> linkjpg <> "\" TARGET=\"_blank\" TITLE=\"Download the picture\">" <> pictureset <> ""; "
" <> jpg <> "
" <> capt1 <> "
", {pict, set}] // StringJoin; spanNew["pictures"] = pictures; spanNew["locationscripts"] = spanNew["locationmap"] = ""; fileloc = ToFileName[{dir0, "date-loc"}, dateS[date, "-"] <> ".kmz"]; If[FileType[fileloc] === File, spanNew["locationscripts"] = spanOld["locationscripts"]; spanNew["locationmap"] = spanOld["locationmap"]]; text = text // spanReplace; diren = ToFileName[{dir0, "date-en"}]; checkdir1[diren]; file = ToFileName[diren, dateS[date, "-"] <> ".htm"]; Export[file, text, "Text"], {csubset, csubsets}]; );