(* Web page for each mushroom species *)
maintainMpages := (
Print["Creating web page for each mushroom species ..."];
xsizem1 = 800; (* Max width of pop-up thumbnail *)
ysizem1 = 600; (* Max height of pop-up thumbnail *)
height = 680;
font =15;
margin =3;
Do[
name0 = data[[1]];
datasql = data[[3]];
id = selectid[name0];
kingdom = idcomponents["kingdom", id];
phylum = idcomponents["phylum", id];
class = idcomponents["class", id];
order = idcomponents["order", id];
family = idcomponents["family", id];
name = idcomponents["name", id];
namehtml = idcomponents["name_html", id];
syns = idcomponents["synonyms", id];
rnames = translatename[name, "ru"];
nameru = "";
If[rnames =!= {}, nameru = rnames[[1]]];
nPrint[name, " -> ", rnames];
line = kingdom <> " > " <> phylum <> " > " <> class <> " > " <> order <> " > " <> family<> " > " <> namehtml;
name0a = name;
If[rnames =!= {},
name0a = If[Length[rnames] < 6,
name0a <> " (" <> StringJoin[Riffle[rnames, ", "]] <> ")",
name0a <> " (" <> StringJoin[Riffle[Take[rnames, 5], ", "]] <> ", ...)"
],
If[syns =!= {},
name0a = If[Length[syns] < 4,
name0a <> " (" <> StringJoin[Riffle[syns, ", "]] <> ")",
name0a <> " (" <> StringJoin[Riffle[Take[syns, 3], ", "]] <> ", ...)"
];
];
];
allnames = Join[{name0}, If[Length[rnames] < 8, rnames, Take[rnames, 7]], If[Length[syns] < 4, syns, Take[syns, 3]]];
name0a=name;
namew = StringReplace[name, " " -> "%20"];
namea = StringReplace[name, " " -> "_"];
wikitext = wikitext1ru[name];
wikiurl = "http://ru.wikipedia.org/wiki/" <> namea;
If[wikitext === {},
wikitxt = "",
wikitext = wikitextru[name];
If[wikitext === {},
wikitxt = "",
wikitxt = "" <> wikitext[[1]] <> "";
];
];
text = {
"
" <> name0 <> If[nameru === "", "", "(" <> nameru <> ")"] <> " - griby Len Obl
name0a <> " in mushrooms of Leningrad Region\">
StringJoin[Riffle[allnames, ", "]] <> ", photos, fungi, mycology, mushrooms\">
" <> line <> "
",
srnames = StringJoin[Riffle[rnames, ", "]];
If[rnames === {}, "" <> name <> "
", "" <> rnames[[1]] <> "
"],
If[syns =!= {}, "Синоним" <> If[Length[syns] > 1, "ы", ""] <> "
" <> StringJoin[Riffle[syns, ", "]] <> "
", ""],
(*
wikitxt3 = "";
If[wikitxt =!= "",
wikitxt2 = "";
If[Length[wikitext] > 1,
wikitxt2 = wikitext[[2]];
wikitxt2 = "[+]
" <> wikitxt2 <> "
";
];
wikitxt3 = " wikiurl <> "\">" <> name <> ", Wikipedia article";
"" <> wikitxt <> wikitxt2 <> "
",
""],
*)
(*
pts = {};
SetDirectory[ToFileName[{dir00, "temp", "qatar_plants-2014", "webpages"}]];
availdates = FileNames[];
availdates = Select[availdates, (FileType[#] === Directory)&];
ResetDirectory[];
*)
Table[
{year, roll, pic, capt, xsize, ysize, date, pop} = dat;
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";
(* ! *) captdate = capt;
(* Link to all pictures including duplicates it the same day *)
datematch = "(\\w+\\s+\\w+[,]?\\s+\\w+)$";
datest = StringCases[capt, RegularExpression[datematch]];
If[datest === {},
Print["Error: datematch not found: ", {year, roll, pic, capt}];
Goto[endcaptdate];
];
datest = datest[[1]];
datecapt = DateList[datest];
If[Head[datecapt] =!= List,
Print["Error: Head[datecapt] =!= List: ", {year, roll, pic, capt}];
captdate = capt;
Goto[endcaptdate];
];
{date1, date2, date3} = ToString /@ Take[datecapt, 3];
If[StringLength[date2] == 1, date2 = "0" <> date2];
If[StringLength[date3] == 1, date3 = "0" <> date3];
datecapt = date1 <> "-" <> date2 <> "-" <> date3;
(*
If[!MemberQ[availdates, datecapt],
(* Print["Warning: !MemberQ[availdates, datecapt]: ", {year, roll, pic, datecapt}]; *)
nodates = Append[nodates, datecapt];
captdate = capt;
Goto[endcaptdate];
];
datest1 = " datecapt <> "/index-160x120.htm\" TARGET=\"_blank\" " <>
"TITLE=\"All pictures (including duplicates) taken on " <> datest <> "\">" <> datest <> "";
captdate = StringReplace[capt, datest ~~ EndOfString -> datest1];
Label[endcaptdate];
*)
capt1 = " link <> "\" TARGET=\"_blank\" TITLE=\"Photo " <> roll <> "-" <> pic <>
"\">
" <>
captdate;
(*
(* GPS data *)
plname = placename[roll, pic];
If[Head[plname] === List, {plname, plname1} = plname];
russia = "\:0420\:043e\:0441\:0441\:0438\:044f";
If[Head[plname] === String,
inrussia = StringMatchQ[plname, RegularExpression["^" <> russia <> ".*"]];
If[!inrussia,
plname = StringReplace[plname, RegularExpression["^" <> russia <> "[, ]*"] -> ""];
plname = "" <> plname <> "
";
];
];
plname2 = "";
If[Head[plname] === String,
plname2 = plname;
];
geolocat = shootingdata["gps position", roll, pic];
If[Head[geolocat] === List && shootingdata["gps delay", roll, pic] < 60,
pts = Append[pts, geolocat];
geolocat = StringTrim /@ (ToString /@ (NumberForm[#, {9, 6}, ExponentFunction -> (Null &)] & /@ geolocat));
geolocat = StringJoin[Riffle[geolocat, ","]];
(*
linkg = "http://maps.googleapis.com/maps/api/staticmap?maptype=roadmap" <>
"&markers=color:red%7C" <> geolocat <>
"&format=gif" <>
"&zoom=10" <>
"&size=400x266" <>
"&scale=1&sensor=false";
*)
{lat, long} = StringSplit[geolocat, ","];
geolocatr = long <> "," <> lat;
overlay = "geojson(%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B" <> long <> "%2C" <> lat <> "%5D%7D)";
zoomlev = 11;
linkg = "https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/static/" <> overlay <> "/" <> geolocatr <> "," <> ToString[zoomlev] <>",0/600x400?access_token=" <> mapboxkey;
linkmap = "../asergeev/php/searchph/location.php?roll=" <> roll <> "&pic=" <> pic <> "&locat=" <> geolocat <> "&delay=" <> ToString[Round[shootingdata["gps delay", roll, pic]]];
location = "";
capt1 = capt1 <> "
" <> location;
];
*)
(* 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___] ~~ "');" -> "",
" | " -> "",
"margin-bottom:2px;" -> "margin-bottom:0px;"}];
capt2 = capt2 <> s;
geolocat = StringReplace[s, Longest[x__] ~~ "&locat=" -> ""];
geolocat = StringReplace[geolocat, "&delay=" ~~ Longest[x__] -> ""];
geolocat = ToExpression["{" <> geolocat <> "}"];
pts = Append[pts, 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 = "" <>
(*
" link1200 <> "\" media=\"(min-width: 1200px)\">
link240 <> "\" media=\"(max-width: 240px)\">" <>
*)
" link400 <> "\" media=\"(max-width: 400px)\">
link600 <> "\" media=\"(max-width: 600px)\">
link800 <> "\">
link800 <> "\" BORDER=\"0\" ALT=\"" <> addsymb[capt] <> "\">
";
jpg = " linkjpg <> "\" TARGET=\"_blank\" TITLE=\"Download the picture\">" <> pictureset <> "";
"" <> jpg <>
" " <> capt1 <> " ", {dat, datasql}],
datatxt = plantdatali[plant];
(* Footer *)
"
|