(* Web page for each plant species *)
maintainPlantpages := (
Print["Creating web page for each plant species ..."];
xsizem1 = 800; (* Max width of pop-up thumbnail *)
ysizem1 = 600; (* Max height of pop-up thumbnail *)
height = 680;
font =15;
margin =3;
nodates = {};
Do[
name = plantname[plant];
nts = notes[plant];
family = plantfamily[plant];
name0 = name0a = shortenname[name];
syns = plantsynonyms[plant];
names = plantnames[plant];
cnames = Complement[names, {name0}, syns, SameTest -> ((ToLowerCase[#1] === ToLowerCase[#2]) &)];
If[cnames =!= {},
name0a = If[Length[cnames] < 6,
name0a <> " (" <> StringJoin[Riffle[cnames, ", "]] <> ")",
name0a <> " (" <> StringJoin[Riffle[Take[cnames, 5], ", "]] <> ", ...)"
],
If[syns =!= {},
name0a = If[Length[syns] < 4,
name0a <> " (" <> StringJoin[Riffle[syns, ", "]] <> ")",
name0a <> " (" <> StringJoin[Riffle[Take[syns, 3], ", "]] <> ", ...)"
];
];
];
allnames = Join[{name0}, If[Length[cnames] < 8, cnames, Take[cnames, 7]], If[Length[syns] < 4, syns, Take[syns, 3]]];
wikitext = plantwiki[plant];
If[wikitext === "",
wikitxt = "",
wikitext = StringCases[wikitext, "
" ~~ Shortest[x__] ~~ "
" -> x];
wikitext = StringTrim /@ wikitext;
wikitext = Select[wikitext, !StringMatchQ[#, ""]&];
If[Length[wikitext] == 0,
Print["Internal error: first paragraph of Wiki article not found: ", name, " -> ", wikitext],
wikitxt = "" <> wikitext[[1]] <> "";
];
];
namer = StringReplace[name0, redirects];
name1 = StringReplace[namer, " " -> "%20"];
name1a = StringReplace[name1, " " -> "_"];
planta = StringReplace[plant, " " -> "_"];
plantal = ToLowerCase[planta];
wikiurl = "http://en.wikipedia.org/wiki/" <> name1a;
datasql = plantdatasql[plant];
text = {
"
" <> name0 <> " - Flora of Qatar
name0a <> " in Flora of Qatar, with photos of the plant in its habitat\">
StringJoin[Riffle[allnames, ", "]] <> ", photos, flora, botany, plant life, habitat\">
Home Page > Picture Archives > " <>
" > ToLowerCase[family] <> ".htm\">" <> family <> " > " <> StringReplace[plant, " " -> " "] <> "LOCATIONMAP
" <> name <> "
",
If[syns =!= {}, "Synonyms
" <> StringJoin[Riffle[syns, ", "]] <> "
", ""],
If[cnames =!= {},
cnames = StringJoin[Riffle[cnames, ", "]];
cnames = ToUpperCase[StringTake[cnames, 1]] <> StringDrop[cnames, 1];
"Common names
" <> cnames <> "
", ""],
If[nts =!= {},
nts = StringJoin[Riffle[nts, "
"]];
"My notes
" <> nts <> "
", ""],
wikitxt3 = "";
If[wikitxt =!= "",
wikitxt2 = "";
If[Length[wikitext] > 1,
wikitxt2 = Drop[wikitext, 1];
wikitxt2 = StringJoin[("" <> #)&/@ wikitxt2];
wikitxt2 = "[+]
" <> wikitxt2 <> "
";
];
wikitxt3 = " wikiurl <> "\">" <> name0 <> ", 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";
(* 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}];
captdate = 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" <>
"&key=" <> apikey <>
"&markers=color:red%7C" <> geolocat <>
"&format=gif" <>
"&zoom=10" <>
"&size=400x266" <>
"&scale=1&sensor=false";
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 *)
"Links
Outside links
" <> wikitxt3 <> datatxt,
showOutLinks,
"
How the web page was created
- A list of plants with their common names was written using online sources and books.
- Web pages were written by a program consisting of several scripts.
- Full names, synonyms, and classification of plants were found online from catalogueoflife.org and theplantlist.org
using a script.
- Pictures of plants were selected from a database
using a script.
- This web page was written
using a script.
Acknowledgements
QNHG (Qatar Natural History Group) and associated people,
for a possibility to participate in their field excursions and to learn about local nature.
|