@ca-plant-list/ca-plant-list 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/glossary/pappus.md +3 -0
- package/data/glossary/petiole.md +1 -0
- package/data/glossary/phyllary.md +1 -0
- package/data/glossary/stipule.md +1 -0
- package/data/illustrations/inkscape/asteraceae_floret.svg +157 -0
- package/data/illustrations/optimized/asteraceae_floret.svg +28 -0
- package/data/synonyms.csv +12 -0
- package/data/taxa.csv +149 -146
- package/data/text/Clematis-ligusticifolia.md +1 -0
- package/data/text/Erythranthe-arvensis.md +1 -0
- package/data/text/Erythranthe-grandis.md +1 -0
- package/data/text/Erythranthe-guttata.md +1 -0
- package/data/text/Grindelia-camporum.md +1 -1
- package/data/text/Grindelia-hirsutula.md +1 -1
- package/data/text/Lonicera-interrupta.md +1 -0
- package/data/text/Lonicera-subspicata-var-denudata.md +1 -0
- package/data/text/Taraxacum-officinale.md +1 -1
- package/data/text/Wyethia-angustifolia.md +1 -1
- package/data/text/Wyethia-glabra.md +1 -1
- package/data/text/Wyethia-helenioides.md +1 -1
- package/jekyll/_includes/glossary.html +0 -0
- package/jekyll/_layouts/html.html +3 -0
- package/jekyll/assets/css/main.css +9 -0
- package/jekyll/glossary.md +5 -0
- package/lib/basepagerenderer.js +5 -0
- package/lib/dateutils.js +24 -0
- package/lib/ebook/ebook.js +24 -0
- package/lib/ebook/ebookpage.js +4 -2
- package/lib/ebook/glossarypages.js +101 -0
- package/lib/ebook/images.js +86 -0
- package/lib/ebook/pages/taxonpage.js +2 -3
- package/lib/ebook/pages/tocpage.js +1 -0
- package/lib/ebook/plantbook.js +17 -67
- package/lib/genericpage.js +26 -8
- package/lib/html.js +1 -1
- package/lib/index.d.ts +24 -12
- package/lib/jekyll.js +11 -0
- package/lib/markdown.js +18 -0
- package/lib/pagerenderer.js +2 -3
- package/lib/plants/glossary.js +52 -0
- package/lib/taxon.js +14 -0
- package/lib/web/glossarypages.js +52 -0
- package/lib/{pagetaxon.js → web/pagetaxon.js} +34 -7
- package/package.json +1 -1
- /package/{ebook/i → data/illustrations/optimized}/f-blue.svg +0 -0
- /package/{ebook/i → data/illustrations/optimized}/f-orange.svg +0 -0
- /package/{ebook/i → data/illustrations/optimized}/f-pink.svg +0 -0
- /package/{ebook/i → data/illustrations/optimized}/f-red.svg +0 -0
- /package/{ebook/i → data/illustrations/optimized}/f-white.svg +0 -0
- /package/{ebook/i → data/illustrations/optimized}/f-yellow.svg +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
Found along streams and in wet places.
|
@@ -0,0 +1 @@
|
|
1
|
+
Stems not hairy.
|
@@ -0,0 +1 @@
|
|
1
|
+
Corolla tube extends 10-15 mm beyond calyx.
|
@@ -0,0 +1 @@
|
|
1
|
+
Corolla tube extends 3–5 mm beyond calyx.
|
@@ -1 +1 @@
|
|
1
|
-
Phyllaries flattened only at bases (rounded in cross section distally), phyllary tips often reflexed, or coiled; plants generally not hairy.
|
1
|
+
[Phyllaries](g/phyllary.html) flattened only at bases (rounded in cross section distally), phyllary tips often reflexed, or coiled; plants generally not hairy.
|
@@ -1 +1 @@
|
|
1
|
-
Phyllaries flattened, plants generally hairy.
|
1
|
+
[Phyllaries](g/phyllary.html) flattened, plants generally hairy.
|
@@ -0,0 +1 @@
|
|
1
|
+
Upper leaf pairs fused around stem. No [stipules](g/stipule.html), corolla not hairy.
|
@@ -0,0 +1 @@
|
|
1
|
+
Upper leaf pairs not fused around stem.
|
@@ -1 +1 @@
|
|
1
|
-
Leaves basal. Stem not branched. Outer phyllaries much smaller than inner.
|
1
|
+
Leaves basal. Stem not branched. Outer [phyllaries](g/phyllary.html) much smaller than inner.
|
@@ -1 +1 @@
|
|
1
|
-
Outer phyllaries narrow and roughly the same width as inner.
|
1
|
+
Outer [phyllaries](g/phyllary.html) narrow and roughly the same width as inner.
|
@@ -1 +1 @@
|
|
1
|
-
Outer phyllaries wide, leaf-like, and usually much larger than inner phyllaries. Generally not hairy or with some glandular hairs.
|
1
|
+
Outer [phyllaries](g/phyllary.html) wide, leaf-like, and usually much larger than inner phyllaries. Generally not hairy or with some glandular hairs.
|
@@ -1 +1 @@
|
|
1
|
-
Outer phyllaries wide, leaf-like, and usually much larger than inner phyllaries. Plant densely tomentose.
|
1
|
+
Outer [phyllaries](g/phyllary.html) wide, leaf-like, and usually much larger than inner phyllaries. Plant densely tomentose.
|
File without changes
|
@@ -31,6 +31,9 @@
|
|
31
31
|
<li class="nav-item">
|
32
32
|
<a class="nav-link" href="{{site.baseurl}}/name_search.html">Name Search</a>
|
33
33
|
</li>
|
34
|
+
<li class="nav-item">
|
35
|
+
<a class="nav-link" href="{{site.baseurl}}/glossary.html">Glossary</a>
|
36
|
+
</li>
|
34
37
|
{%include menu_extra.html %}
|
35
38
|
</ul>
|
36
39
|
</div>
|
@@ -20,6 +20,10 @@
|
|
20
20
|
background-color: var(--pl-navbar-bg);
|
21
21
|
}
|
22
22
|
|
23
|
+
p {
|
24
|
+
margin-bottom: .5rem;
|
25
|
+
}
|
26
|
+
|
23
27
|
span.label {
|
24
28
|
font-weight: 600;
|
25
29
|
padding-right: .5rem;
|
@@ -126,6 +130,11 @@ div.section ul.indent {
|
|
126
130
|
padding-left: 1rem;
|
127
131
|
}
|
128
132
|
|
133
|
+
img.flower-color {
|
134
|
+
margin-bottom: .2rem;
|
135
|
+
margin-right: .5rem;
|
136
|
+
}
|
137
|
+
|
129
138
|
/* Forms */
|
130
139
|
input {
|
131
140
|
margin-right: .5em;
|
package/lib/basepagerenderer.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Config } from "./config.js";
|
2
2
|
import { Families } from "./families.js";
|
3
3
|
import { Files } from "./files.js";
|
4
|
+
import { GlossaryPages } from "./web/glossarypages.js";
|
4
5
|
|
5
6
|
class BasePageRenderer {
|
6
7
|
|
@@ -12,9 +13,13 @@ class BasePageRenderer {
|
|
12
13
|
Files.copyDir( Config.getPackageDir() + "/jekyll", outputDir );
|
13
14
|
// Then copy Jekyll files from current dir (which may override default files).
|
14
15
|
Files.copyDir( "jekyll", outputDir );
|
16
|
+
// Copy illustrations.
|
17
|
+
Files.copyDir( Config.getPackageDir() + "/data/illustrations/optimized", outputDir + "/i" );
|
15
18
|
|
16
19
|
Families.renderPages( outputDir, familyCols );
|
17
20
|
|
21
|
+
new GlossaryPages( outputDir ).renderPages();
|
22
|
+
|
18
23
|
this.renderTools( outputDir, Taxa );
|
19
24
|
|
20
25
|
}
|
package/lib/dateutils.js
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
const MONTH_NAMES = [
|
2
|
+
"January",
|
3
|
+
"February",
|
4
|
+
"March",
|
5
|
+
"April",
|
6
|
+
"May",
|
7
|
+
"June",
|
8
|
+
"July",
|
9
|
+
"August",
|
10
|
+
"September",
|
11
|
+
"October",
|
12
|
+
"November",
|
13
|
+
"December",
|
14
|
+
];
|
15
|
+
|
16
|
+
class DateUtils {
|
17
|
+
|
18
|
+
static getMonthName( monthNum ) {
|
19
|
+
return MONTH_NAMES[ monthNum ];
|
20
|
+
}
|
21
|
+
|
22
|
+
}
|
23
|
+
|
24
|
+
export { DateUtils };
|
package/lib/ebook/ebook.js
CHANGED
@@ -3,6 +3,18 @@ import { default as archiver } from "archiver";
|
|
3
3
|
import { XHTML } from "./xhtml.js";
|
4
4
|
import { Config } from "../config.js";
|
5
5
|
|
6
|
+
const MEDIA_TYPES = {
|
7
|
+
SVG: "image/svg+xml",
|
8
|
+
JPG: "image/jpeg",
|
9
|
+
XHTML: "application/xhtml+xml",
|
10
|
+
};
|
11
|
+
|
12
|
+
const EXT_MEDIA_MAP = {
|
13
|
+
"jpeg": MEDIA_TYPES.JPG,
|
14
|
+
"jpg": MEDIA_TYPES.JPG,
|
15
|
+
"svg": MEDIA_TYPES.SVG,
|
16
|
+
};
|
17
|
+
|
6
18
|
class EBook {
|
7
19
|
|
8
20
|
#outputDir;
|
@@ -103,6 +115,18 @@ class EBook {
|
|
103
115
|
return this.#outputDir + "/epub";
|
104
116
|
}
|
105
117
|
|
118
|
+
static getManifestEntry( id, href, mediaType = MEDIA_TYPES.XHTML ) {
|
119
|
+
return "<item id=\"" + id + "\" href=\"" + href + "\" media-type=\"" + mediaType + "\" />";
|
120
|
+
}
|
121
|
+
|
122
|
+
static getMediaTypeForExt( ext ) {
|
123
|
+
return EXT_MEDIA_MAP[ ext ];
|
124
|
+
}
|
125
|
+
|
126
|
+
static getSpineEntry( id ) {
|
127
|
+
return "<itemref idref=\"" + id + "\"/>";
|
128
|
+
}
|
129
|
+
|
106
130
|
#getMetaDir() {
|
107
131
|
return this.#outputDir + "/META-INF";
|
108
132
|
}
|
package/lib/ebook/ebookpage.js
CHANGED
@@ -4,10 +4,12 @@ class EBookPage {
|
|
4
4
|
|
5
5
|
#fileName;
|
6
6
|
#title;
|
7
|
+
#rootPrefix;
|
7
8
|
|
8
|
-
constructor( fileName, title ) {
|
9
|
+
constructor( fileName, title, rootPrefix = "" ) {
|
9
10
|
this.#fileName = fileName;
|
10
11
|
this.#title = title;
|
12
|
+
this.#rootPrefix = rootPrefix;
|
11
13
|
}
|
12
14
|
|
13
15
|
create() {
|
@@ -37,7 +39,7 @@ class EBookPage {
|
|
37
39
|
let html = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
38
40
|
html += "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">";
|
39
41
|
html += "<head><title>" + title + "</title>";
|
40
|
-
html += "<link href=\"
|
42
|
+
html += "<link href=\"" + this.#rootPrefix + "css/main.css\" rel=\"stylesheet\" />";
|
41
43
|
html += "</head>" + this.#renderBodyStart();
|
42
44
|
return html;
|
43
45
|
}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
import * as fs from "node:fs";
|
2
|
+
|
3
|
+
import { EBookPage } from "./ebookpage.js";
|
4
|
+
import { XHTML } from "./xhtml.js";
|
5
|
+
|
6
|
+
import { HTML } from "../html.js";
|
7
|
+
import { Markdown } from "../markdown.js";
|
8
|
+
import { EBook } from "./ebook.js";
|
9
|
+
|
10
|
+
import { Glossary } from "../plants/glossary.js";
|
11
|
+
|
12
|
+
class GlossaryPages {
|
13
|
+
|
14
|
+
#glossary;
|
15
|
+
|
16
|
+
constructor() {
|
17
|
+
this.#glossary = new Glossary();
|
18
|
+
}
|
19
|
+
|
20
|
+
createPages( contentDir ) {
|
21
|
+
|
22
|
+
const termList = [];
|
23
|
+
|
24
|
+
// Create target directory.
|
25
|
+
const dirTarget = contentDir + "/g";
|
26
|
+
fs.mkdirSync( dirTarget, { recursive: true } );
|
27
|
+
|
28
|
+
for ( const entry of this.#glossary.getEntries() ) {
|
29
|
+
|
30
|
+
new PageGlossaryEntry( contentDir, entry ).create();
|
31
|
+
|
32
|
+
// Add term to index page list.
|
33
|
+
termList.push( HTML.getLink( "g/" + entry.getHTMLFileName(), entry.getTermName() ) );
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
// Write glossary index page.
|
38
|
+
new PageGlossary( contentDir, termList ).create();
|
39
|
+
}
|
40
|
+
|
41
|
+
getManifestEntries() {
|
42
|
+
|
43
|
+
const glossaryEntries = this.#glossary.getEntries();
|
44
|
+
const manifestEntries = [];
|
45
|
+
|
46
|
+
manifestEntries.push( EBook.getManifestEntry( "g", "glossary.html" ) );
|
47
|
+
for ( let index = 0; index < glossaryEntries.length; index++ ) {
|
48
|
+
const entry = glossaryEntries[ index ];
|
49
|
+
manifestEntries.push( EBook.getManifestEntry( "g" + index, "g/" + entry.getHTMLFileName() ) );
|
50
|
+
}
|
51
|
+
|
52
|
+
return manifestEntries.join( "" );
|
53
|
+
}
|
54
|
+
|
55
|
+
getSpineEntries() {
|
56
|
+
|
57
|
+
const glossaryEntries = this.#glossary.getEntries();
|
58
|
+
const spineEntries = [];
|
59
|
+
|
60
|
+
spineEntries.push( EBook.getSpineEntry( "g", "glossary.html" ) );
|
61
|
+
for ( let index = 0; index < glossaryEntries.length; index++ ) {
|
62
|
+
spineEntries.push( EBook.getSpineEntry( "g" + index ) );
|
63
|
+
}
|
64
|
+
|
65
|
+
return spineEntries.join( "" );
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
class PageGlossary extends EBookPage {
|
72
|
+
|
73
|
+
#entries;
|
74
|
+
|
75
|
+
constructor( outputDir, entries ) {
|
76
|
+
super( outputDir + "/glossary.html", "Glossary" );
|
77
|
+
this.#entries = entries;
|
78
|
+
}
|
79
|
+
|
80
|
+
renderPageBody() {
|
81
|
+
const html = XHTML.textElement( "h1", this.getTitle() );
|
82
|
+
return html + XHTML.wrap( "ol", XHTML.arrayToLI( this.#entries ) );
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
class PageGlossaryEntry extends EBookPage {
|
87
|
+
|
88
|
+
#entry;
|
89
|
+
|
90
|
+
constructor( outputDir, entry ) {
|
91
|
+
super( outputDir + "/g/" + entry.getHTMLFileName(), entry.getTermName(), "../" );
|
92
|
+
this.#entry = entry;
|
93
|
+
}
|
94
|
+
|
95
|
+
renderPageBody() {
|
96
|
+
const html = XHTML.textElement( "h1", this.getTitle() );
|
97
|
+
return html + Markdown.strToHTML( this.#entry.getMarkdown() );
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
export { GlossaryPages };
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import * as fs from "node:fs";
|
2
|
+
import path from "node:path";
|
3
|
+
|
4
|
+
import sharp from "sharp";
|
5
|
+
|
6
|
+
import { Config, CSV, Files, Taxa } from "@ca-plant-list/ca-plant-list";
|
7
|
+
|
8
|
+
import { Image } from "./image.js";
|
9
|
+
import { EBook } from "./ebook.js";
|
10
|
+
|
11
|
+
class Images {
|
12
|
+
|
13
|
+
#contentDir;
|
14
|
+
#images = {};
|
15
|
+
|
16
|
+
constructor( contentDir ) {
|
17
|
+
this.#contentDir = contentDir;
|
18
|
+
}
|
19
|
+
|
20
|
+
async createImages() {
|
21
|
+
|
22
|
+
const photoDirSrc = "external_data/photos";
|
23
|
+
const imagePrefix = "i";
|
24
|
+
const photoDirTarget = this.#contentDir + "/" + imagePrefix;
|
25
|
+
fs.mkdirSync( photoDirSrc, { recursive: true } );
|
26
|
+
fs.mkdirSync( photoDirTarget, { recursive: true } );
|
27
|
+
|
28
|
+
const rows = CSV.parseFile( Config.getPackageDir() + "/data", "photos.csv" );
|
29
|
+
for ( const row of rows ) {
|
30
|
+
|
31
|
+
const name = row[ "taxon_name" ];
|
32
|
+
const taxon = Taxa.getTaxon( name );
|
33
|
+
if ( !taxon ) {
|
34
|
+
continue;
|
35
|
+
}
|
36
|
+
|
37
|
+
let imageList = this.#images[ name ];
|
38
|
+
if ( !imageList ) {
|
39
|
+
imageList = [];
|
40
|
+
this.#images[ name ] = imageList;
|
41
|
+
}
|
42
|
+
|
43
|
+
const src = new URL( row[ "source" ] );
|
44
|
+
const parts = path.parse( src.pathname ).dir.split( "/" );
|
45
|
+
const prefix = src.host.includes( "calflora" ) ? "cf-" : "inat-";
|
46
|
+
const filename = prefix + parts.slice( -1 )[ 0 ] + ".jpg";
|
47
|
+
const srcFileName = photoDirSrc + "/" + filename;
|
48
|
+
const targetFileName = photoDirTarget + "/" + filename;
|
49
|
+
|
50
|
+
if ( !fs.existsSync( srcFileName ) ) {
|
51
|
+
// File is not there; retrieve it.
|
52
|
+
console.log( "retrieving " + srcFileName );
|
53
|
+
await Files.fetch( src, srcFileName );
|
54
|
+
}
|
55
|
+
|
56
|
+
await new sharp( srcFileName ).resize( { width: 400 } ).jpeg( { quality: 40 } ).toFile( targetFileName );
|
57
|
+
|
58
|
+
imageList.push( new Image( imagePrefix + "/" + filename, row[ "credit" ] ) );
|
59
|
+
|
60
|
+
}
|
61
|
+
|
62
|
+
this.#getIllustrations( this.#contentDir );
|
63
|
+
|
64
|
+
}
|
65
|
+
|
66
|
+
#getIllustrations() {
|
67
|
+
Files.copyDir( Config.getPackageDir() + "/data/illustrations/optimized", this.#contentDir + "/i" );
|
68
|
+
}
|
69
|
+
|
70
|
+
getManifestEntries() {
|
71
|
+
|
72
|
+
const entries = [];
|
73
|
+
const images = Files.getDirEntries( this.#contentDir + "/i" ).sort();
|
74
|
+
|
75
|
+
for ( let index = 0; index < images.length; index++ ) {
|
76
|
+
const fileName = images[ index ];
|
77
|
+
const ext = fileName.split( "." )[ 1 ];
|
78
|
+
entries.push( EBook.getManifestEntry( "i" + index, "i/" + fileName, EBook.getMediaTypeForExt( ext ) ) );
|
79
|
+
}
|
80
|
+
|
81
|
+
return entries.join( "" );
|
82
|
+
}
|
83
|
+
|
84
|
+
}
|
85
|
+
|
86
|
+
export { Images };
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import sizeOf from "image-size";
|
2
|
-
import markdownIt from "markdown-it";
|
3
2
|
import { Config, Files } from "@ca-plant-list/ca-plant-list";
|
4
3
|
import { EBookPage } from "../ebookpage.js";
|
5
4
|
import { XHTML } from "../xhtml.js";
|
5
|
+
import { Markdown } from "../../markdown.js";
|
6
6
|
|
7
7
|
class TaxonPage extends EBookPage {
|
8
8
|
|
@@ -39,8 +39,7 @@ class TaxonPage extends EBookPage {
|
|
39
39
|
return "";
|
40
40
|
}
|
41
41
|
const text = Files.read( fileName );
|
42
|
-
|
43
|
-
return md.render( text );
|
42
|
+
return Markdown.strToHTML( text );
|
44
43
|
}
|
45
44
|
|
46
45
|
const name = this.#taxon.getName();
|
@@ -17,6 +17,7 @@ class TOCPage extends EBookPage {
|
|
17
17
|
mainLinks.push( this.#getFlowerColorLinks() );
|
18
18
|
mainLinks.push( XHTML.getLink( "./list_families.html", "All Families" ) );
|
19
19
|
mainLinks.push( XHTML.getLink( "./list_species.html", "All Species" ) );
|
20
|
+
mainLinks.push( XHTML.getLink( "./glossary.html", "Glossary" ) );
|
20
21
|
html += XHTML.wrap( "ol", XHTML.arrayToLI( mainLinks ) );
|
21
22
|
|
22
23
|
html += "</nav>";
|
package/lib/ebook/plantbook.js
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
import
|
2
|
-
import path from "node:path";
|
3
|
-
import sharp from "sharp";
|
4
|
-
import { CSV, Families, Files, Taxa } from "@ca-plant-list/ca-plant-list";
|
1
|
+
import { Families, Taxa } from "@ca-plant-list/ca-plant-list";
|
5
2
|
import { EBook } from "./ebook.js";
|
6
|
-
import {
|
3
|
+
import { GlossaryPages } from "./glossarypages.js";
|
4
|
+
import { Images } from "./images.js";
|
7
5
|
import { PageListFamilies } from "./pages/page_list_families.js";
|
8
6
|
import { PageListFlowerColor } from "./pages/page_list_flower_color.js";
|
9
7
|
import { PageListSpecies } from "./pages/page_list_species.js";
|
@@ -14,7 +12,8 @@ import { FLOWER_COLOR_NAMES } from "../taxa.js";
|
|
14
12
|
|
15
13
|
class PlantBook extends EBook {
|
16
14
|
|
17
|
-
#
|
15
|
+
#glossary;
|
16
|
+
#images;
|
18
17
|
|
19
18
|
constructor() {
|
20
19
|
|
@@ -25,13 +24,13 @@ class PlantBook extends EBook {
|
|
25
24
|
Config.getConfigValue( "ebook", "title" )
|
26
25
|
);
|
27
26
|
|
27
|
+
this.#glossary = new GlossaryPages();
|
28
|
+
this.#images = new Images( this.getContentDir() );
|
29
|
+
|
28
30
|
}
|
29
31
|
|
30
32
|
async createPages() {
|
31
33
|
|
32
|
-
console.log( "checking images" );
|
33
|
-
await this.#importImages();
|
34
|
-
|
35
34
|
const contentDir = this.getContentDir();
|
36
35
|
|
37
36
|
console.log( "creating taxon pages" );
|
@@ -56,63 +55,16 @@ class PlantBook extends EBook {
|
|
56
55
|
}
|
57
56
|
new PageListSpecies( contentDir, taxa, "list_species.html", "All Species" ).create();
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
async #importImages() {
|
63
|
-
|
64
|
-
const photoDirSrc = "external_data/photos";
|
65
|
-
const imagePrefix = "i";
|
66
|
-
const photoDirTarget = this.getContentDir() + "/" + imagePrefix;
|
67
|
-
fs.mkdirSync( photoDirSrc, { recursive: true } );
|
68
|
-
fs.mkdirSync( photoDirTarget, { recursive: true } );
|
69
|
-
|
70
|
-
const rows = CSV.parseFile( Config.getPackageDir() + "/data", "photos.csv" );
|
71
|
-
for ( const row of rows ) {
|
72
|
-
|
73
|
-
const name = row[ "taxon_name" ];
|
74
|
-
const taxon = Taxa.getTaxon( name );
|
75
|
-
if ( !taxon ) {
|
76
|
-
continue;
|
77
|
-
}
|
78
|
-
|
79
|
-
let imageList = this.#images[ name ];
|
80
|
-
if ( !imageList ) {
|
81
|
-
imageList = [];
|
82
|
-
this.#images[ name ] = imageList;
|
83
|
-
}
|
84
|
-
|
85
|
-
const src = new URL( row[ "source" ] );
|
86
|
-
const parts = path.parse( src.pathname ).dir.split( "/" );
|
87
|
-
const prefix = src.host.includes( "calflora" ) ? "cf-" : "inat-";
|
88
|
-
const filename = prefix + parts.slice( -1 )[ 0 ] + ".jpg";
|
89
|
-
const srcFileName = photoDirSrc + "/" + filename;
|
90
|
-
const targetFileName = photoDirTarget + "/" + filename;
|
91
|
-
|
92
|
-
if ( !fs.existsSync( srcFileName ) ) {
|
93
|
-
// File is not there; retrieve it.
|
94
|
-
console.log( "retrieving " + srcFileName );
|
95
|
-
await Files.fetch( src, srcFileName );
|
96
|
-
}
|
97
|
-
|
98
|
-
await new sharp( srcFileName ).resize( { width: 400 } ).jpeg( { quality: 40 } ).toFile( targetFileName );
|
58
|
+
await this.#images.createImages( contentDir );
|
59
|
+
this.#glossary.createPages( contentDir );
|
99
60
|
|
100
|
-
|
101
|
-
|
102
|
-
}
|
61
|
+
new TOCPage( contentDir ).create();
|
103
62
|
}
|
104
63
|
|
105
64
|
renderManifestEntries() {
|
106
65
|
|
107
66
|
let xml = "";
|
108
67
|
|
109
|
-
xml += "<item id=\"f0\" href=\"i/f-blue.svg\" media-type=\"image/svg+xml\" />";
|
110
|
-
xml += "<item id=\"f1\" href=\"i/f-orange.svg\" media-type=\"image/svg+xml\" />";
|
111
|
-
xml += "<item id=\"f2\" href=\"i/f-pink.svg\" media-type=\"image/svg+xml\" />";
|
112
|
-
xml += "<item id=\"f3\" href=\"i/f-red.svg\" media-type=\"image/svg+xml\" />";
|
113
|
-
xml += "<item id=\"f4\" href=\"i/f-white.svg\" media-type=\"image/svg+xml\" />";
|
114
|
-
xml += "<item id=\"f5\" href=\"i/f-yellow.svg\" media-type=\"image/svg+xml\" />";
|
115
|
-
|
116
68
|
// Add lists.
|
117
69
|
xml += "<item id=\"lspecies\" href=\"list_species.html\" media-type=\"application/xhtml+xml\" />";
|
118
70
|
xml += "<item id=\"lfamilies\" href=\"list_families.html\" media-type=\"application/xhtml+xml\" />";
|
@@ -137,14 +89,9 @@ class PlantBook extends EBook {
|
|
137
89
|
xml += "<item id=\"t" + index + "\" href=\"" + taxon.getFileName() + "\" media-type=\"application/xhtml+xml\" />";
|
138
90
|
}
|
139
91
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
for ( const image of imageList ) {
|
144
|
-
xml += "<item id=\"i" + index + "\" href=\"" + image.getSrc() + "\" media-type=\"image/jpeg\" />";
|
145
|
-
index++;
|
146
|
-
}
|
147
|
-
}
|
92
|
+
xml += this.#glossary.getManifestEntries();
|
93
|
+
xml += this.#images.getManifestEntries();
|
94
|
+
|
148
95
|
return xml;
|
149
96
|
}
|
150
97
|
|
@@ -172,6 +119,9 @@ class PlantBook extends EBook {
|
|
172
119
|
for ( let index = 0; index < Taxa.getTaxa().length; index++ ) {
|
173
120
|
xml += "<itemref idref=\"t" + index + "\"/>";
|
174
121
|
}
|
122
|
+
|
123
|
+
xml += this.#glossary.getSpineEntries();
|
124
|
+
|
175
125
|
return xml;
|
176
126
|
}
|
177
127
|
}
|
package/lib/genericpage.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import { Files, HTML, Jekyll } from "@ca-plant-list/ca-plant-list";
|
1
|
+
import { Config, Files, HTML, Jekyll } from "@ca-plant-list/ca-plant-list";
|
2
|
+
import { Markdown } from "./markdown.js";
|
2
3
|
|
3
4
|
class GenericPage {
|
4
5
|
|
@@ -19,21 +20,38 @@ class GenericPage {
|
|
19
20
|
}
|
20
21
|
|
21
22
|
getDefaultIntro() {
|
22
|
-
let html = this
|
23
|
-
|
24
|
-
if ( Jekyll.hasInclude( this.#outputDir, introPath ) ) {
|
25
|
-
html += HTML.wrap( "div", Jekyll.include( introPath ), { class: "section" } );
|
26
|
-
}
|
27
|
-
return html;
|
23
|
+
let html = this.getFrontMatter();
|
24
|
+
return html + this.getMarkdown();
|
28
25
|
}
|
29
26
|
|
30
|
-
|
27
|
+
getFrontMatter() {
|
31
28
|
return "---\n"
|
32
29
|
+ "title: \"" + this.#title + "\"\n"
|
33
30
|
+ ( this.#js ? ( "js: " + this.#js + "\n" ) : "" )
|
34
31
|
+ "---\n";
|
35
32
|
}
|
36
33
|
|
34
|
+
getMarkdown() {
|
35
|
+
// Include site-specific markdown.
|
36
|
+
let html = this.#getMarkdown( "intros" );
|
37
|
+
|
38
|
+
// Include package markdown.
|
39
|
+
const mdPath = Config.getPackageDir() + "/data/text/" + this.#baseFileName + ".md";
|
40
|
+
if ( Files.exists( mdPath ) ) {
|
41
|
+
html += HTML.wrap( "div", Markdown.fileToHTML( mdPath ), { class: "section" } );
|
42
|
+
}
|
43
|
+
|
44
|
+
return html;
|
45
|
+
}
|
46
|
+
|
47
|
+
#getMarkdown( path ) {
|
48
|
+
const textPath = path + "/" + this.#baseFileName + ".md";
|
49
|
+
if ( !Jekyll.hasInclude( this.#outputDir, textPath ) ) {
|
50
|
+
return "";
|
51
|
+
}
|
52
|
+
return HTML.wrap( "div", Jekyll.include( textPath ), { class: "section" } );
|
53
|
+
}
|
54
|
+
|
37
55
|
getOutputDir() {
|
38
56
|
return this.#outputDir;
|
39
57
|
}
|
package/lib/html.js
CHANGED