(* Web page for a given mushroom - Russian language *)
maintainSpeciesRu := (
Print["Running maintainSpeciesRu ..."];
filesample = ToFileName[{dirwork, "templates"}, "species-ru.htm"];
checkfile[filesample];
text0 = Import[filesample, "Text"];
Do[
name = data[[1]];
datasql = data[[3]];
getAttributes[name];
idnamedata = iddata[name];
specnumber = Length[idnamedata];
wiki = wikiRu[name];
text = StringReplace[text0, {
"APIKEY" -> apikey,
"NAMERULAT" -> nameru,
"KEYWORDS" -> rukeywords,
"> TOPNAME" -> If[nameru0 === "", "", "> " <> StringReplace[nameru0, " " -> " "] <> ""],
"TITLEHTML" -> nameru1,
"SPECIES" -> name,
"SPECNUMBER" -> ToString[specnumber],
"SPECPLUS" -> StringReplace[name, " " -> "+"],
"SPECLOWERUND" -> nameLUnd,
"SPECBLANC" -> nameUnd,
"SPECLOWBLANC" -> nameLUnd,
"SPECID" -> id,
"HTMLNAME" -> StringReplace[name, " " -> "%20"],
"FIRSTPAR" -> wiki
}];
spanRead[text];
spanNew["topline"] = toplinefix[spanOld["topline"]];
spanNew["upperline"] = classlinefullru;
spanNew["synonyms"] = synlineru;
spanNew["common"] = commlineru;
spanNew["choice"] = If[specnumber < 2, "", spanOld["choice"]];
(*
(* Fixing some dots *)
If[name === "Monilinia fructigena", wiki1 = StringReplace[wiki1, "
" -> ""]];
StringReplace[spanOld["wiki"], {"FIRSTPAR" -> wiki1}]
];
*)
spanNew["wiki"] = If[wiki === "", "", spanOld["wiki"]];
spanNew["wikiref"] = If[wiki === "", "", spanOld["wikiref"]];
epilog = StringReplace[epilogru0, {"program/sub/maintain-SCRIPTNAME" -> "../program/sub/maintain-species-ru",
"asergeev/" -> "../asergeev/",
"\"program-ru.htm" -> "\"../program-ru.htm",
"\"index" -> "\"../index"}];
spanNew["epilog"] = epilog;
picture0 = spanOld["pictures"];
pictures = Table[
{year, roll, pic, capt, xsize, ysize, date, pop} = dat;
alabel = "r" <> roll <> "p" <> pic;
datecapt =
StringCases[capt,
RegularExpression["\\W+(\\w+\\W+\\w+\\W+\\w+)\\W*$"] -> "$1"];
If[datecapt =!= {}, datecapt = datecapt[[1]];
date = DateList[datecapt];
If[Head[date] === List,
date = Take[date, 3];
capt =
StringReplace[capt,
datecapt ->
" dateS[date, "-"] <> ".htm\">" <>
datecapt <> ""],
Print["Error in date: Picture ", {year, roll, pic, capt}]]];
capt = StringReplace[capt, name -> "" <> name <> ""];
(* 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 = "";
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[capt] <> "\">";
(* "\" 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[capt] <> "\">
";
jpg = " alabel <> "\" HREF=\"" <> linkjpg <> "\" TARGET=\"_blank\" TITLE=\"Download the picture\">" <> pictureset <> "";
" " <> jpg <>
" " <> capt1 <> " ", {dat, datasql}] // StringJoin;
spanNew["pictures"] = pictures;
spanNew["locationscripts"] = spanNew["locationmap"] = "";
fileloc = ToFileName[{dir0, "loc"}, nameLUnd <> ".kmz"];
If[FileType[fileloc] === File,
spanNew["locationscripts"] = spanOld["locationscripts"];
spanNew["locationmap"] = spanOld["locationmap"]];
text = text // spanReplace;
dirru = ToFileName[{dir0, "ru"}];
checkdir1[dirru];
file = ToFileName[dirru, nameLUnd <> ".htm"];
Export[file, text, "Text"], {data, listsort}];
);
|