@ca-plant-list/ca-plant-list 0.4.24 → 0.4.27
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/taxa.csv +7 -6
- package/data/text/Erodium-botrys.footer.md +3 -0
- package/data/text/Erodium-botrys.md +1 -0
- package/data/text/Erodium-brachycarpum.footer.md +3 -0
- package/data/text/Erodium-brachycarpum.md +1 -0
- package/data/text/Erodium-cicutarium.md +1 -0
- package/data/text/Erodium-moschatum.footer.md +3 -0
- package/data/text/Erodium-moschatum.md +1 -0
- package/generators/eleventy/layouts/h1.njk +6 -0
- package/generators/eleventy/layouts/html.njk +55 -0
- package/lib/basepagerenderer.js +36 -18
- package/lib/config.js +5 -3
- package/lib/ebook/ebookpage.js +1 -4
- package/lib/ebook/ebooksitegenerator.js +4 -12
- package/lib/ebook/glossarypages.js +1 -3
- package/lib/ebook/plantbook.js +1 -1
- package/lib/files.js +1 -0
- package/lib/htmltaxon.js +8 -19
- package/lib/index.d.ts +32 -9
- package/lib/index.js +4 -2
- package/lib/jekyll.js +40 -59
- package/lib/markdown.js +3 -5
- package/lib/sitegenerator.js +68 -12
- package/lib/taxonomy/taxa.js +4 -4
- package/lib/types.js +4 -0
- package/lib/utils/eleventyGenerator.js +82 -0
- package/lib/utils/htmlFragments.js +19 -0
- package/lib/web/glossarypages.js +6 -10
- package/lib/web/pageFamily.js +14 -14
- package/lib/web/pageGeneric.js +78 -0
- package/lib/web/{pagetaxon.js → pageTaxon.js} +4 -4
- package/lib/web/pageTaxonList.js +53 -0
- package/lib/{pagerenderer.js → web/renderAllPages.js} +38 -80
- package/package.json +12 -10
- package/scripts/build-site.js +20 -52
- package/static/assets/js/nameSearchData.js +2 -0
- package/static/assets/js/name_search.js +203 -0
- package/static/assets/js/ui.js +11 -0
- package/static/assets/js/utils.js +56 -0
- package/static/name_search.html +15 -0
- package/jekyll/_includes/glossary.html +0 -0
- package/jekyll/assets/js/name_search.js +0 -165
- package/jekyll/assets/js/ui.js +0 -10
- package/jekyll/assets/js/utils.js +0 -26
- package/jekyll/name_search.html +0 -17
- package/lib/genericpage.js +0 -88
- /package/{jekyll → generators}/_includes/analytics.html +0 -0
- /package/{jekyll → generators}/_includes/menu_extra.html +0 -0
- /package/{jekyll → generators/jekyll}/_config.yml +0 -0
- /package/{jekyll → generators/jekyll}/_layouts/default.html +0 -0
- /package/{jekyll → generators/jekyll}/_layouts/html.html +0 -0
- /package/{jekyll → static}/assets/css/main.css +0 -0
- /package/{jekyll → static}/index.md +0 -0
package/data/taxa.csv
CHANGED
@@ -503,6 +503,7 @@ Cryptantha clevelandii var. florosa,,N,57120,11565,1045003,203153,,Coastal Crypt
|
|
503
503
|
Cryptantha corollata,,N,21213,2452,58853,203157,,Coast Range Cryptantha
|
504
504
|
Cryptantha flaccida,,N,21228,2460,56989,203167,,Flaccid Cryptantha
|
505
505
|
Cryptantha hooveri,,N,21240,2468,57701,245944,,Hoover's Cryptantha,,,,,525,1A,,,SH,GH
|
506
|
+
Cryptantha hispidula,Napa cryptantha,N,21237,2465,57703,203175,,Napa Cryptantha,annual,white,3,5
|
506
507
|
Cryptantha intermedia var. intermedia,,N,71933,11568,80627,203183
|
507
508
|
Cryptantha juniperensis,rigid cryptantha,N,103476,14557,769572,203205
|
508
509
|
Cryptantha micromeres,,N,21263,2476,770232,203194,,Minute-flowered Cryptantha
|
@@ -720,11 +721,11 @@ Eriophyllum confertiflorum var. confertiflorum,golden-yarrow,N,69866,3423,53397,
|
|
720
721
|
Eriophyllum jepsonii,Jepson's woolly-sunflower,N,2816,3426,77048,203742,true,Jepson's Woolly Sunflower,,,,,776,4.3,,,S3,G3
|
721
722
|
Eriophyllum lanatum var. achilleoides,,N,7369,10587,80880,260847,true,Common Woollysunflower
|
722
723
|
Eriophyllum staechadifolium,seaside woolly-sunflower,N,2825,3444,60963,203755,true,Seaside Woolly Sunflower
|
723
|
-
Erodium botrys,long-beaked filaree,X,25037,3446,57090,17986
|
724
|
-
Erodium brachycarpum,,X,25038,3447,58171,17987
|
725
|
-
Erodium cicutarium,red-stemmed filaree,X,25041,3448,47687,17989
|
724
|
+
Erodium botrys,long-beaked filaree,X,25037,3446,57090,17986,,,annual,pink,3,7
|
725
|
+
Erodium brachycarpum,,X,25038,3447,58171,17987,,,annual,pink,3,7
|
726
|
+
Erodium cicutarium,red-stemmed filaree,X,25041,3448,47687,17989,,,annual,pink,3,9
|
726
727
|
Erodium malacoides,,X,76818,3451,77056,17994
|
727
|
-
Erodium moschatum,white-stem filaree,X,25048,3452,57092,17995
|
728
|
+
Erodium moschatum,white-stem filaree,X,25048,3452,57092,17995,,,"annual,biennial",pink,2,9
|
728
729
|
Eryngium aristulatum var. aristulatum,coyote-thistle,N,58845,3458,64189,211707,,California Eryngo
|
729
730
|
Eryngium aristulatum var. hooveri,,N,58846,3459,57904,203761,,Hoover's Button-celery,,,,,783,1B.1,,,S1,G5T1
|
730
731
|
Eryngium aristulatum,Jepson's button celery,N,25070,3457,57901,203759,,Jepson's Button Celery
|
@@ -1599,7 +1600,7 @@ Salix exigua var. hindsiana,Hind's willow,N,81242,11063,64195,51553,true,Sandbar
|
|
1599
1600
|
Salix gooddingii,Goodding's black willow,N,42825,7272,60240,31274,true,Goodding's Black Willow
|
1600
1601
|
Salix laevigata,red willow,N,42850,7276,58319,31302,true,Red Willow
|
1601
1602
|
Salix lasiandra var. lasiandra,Pacific willow,N,76043,11065,81358,51640,true,Yellow Willow
|
1602
|
-
Salix lasiolepis,arroyo willow,N,42855,7277,53452,31307,true,Arroyo Willow
|
1603
|
+
Salix lasiolepis,arroyo willow,N,42855,7277,53452,31307,true,Arroyo Willow,perennial,,1,6
|
1603
1604
|
Salix melanopsis,dusky willow,N,42881,7284,78947,31332,true,Dusky Willow
|
1604
1605
|
Salix scouleriana,Scouler's willow,N,42973,7289,71076,31425,true,Scouler's Willow
|
1605
1606
|
Salix sitchensis,Sitka willow,N,42994,7291,61100,31435,true,Sitka Willow
|
@@ -1676,7 +1677,7 @@ Silene lemmonii,Lemmon's catchfly,N,44533,7603,60523,119295,true,Lemmon's Catchf
|
|
1676
1677
|
Silene sargentii,Sargent's catchfly,N,44566,7614,62697,119340,true,Sargent's Catchfly,perennial,white,7,8
|
1677
1678
|
Silene verecunda,,N,44589,7617,60581,119364,true,San Francisco Campion
|
1678
1679
|
Silybum marianum,milk-thistle,X,4918,7622,52586,205950,true
|
1679
|
-
Sinapis arvensis,charlock,X,44609,7625,1562069,32232,true
|
1680
|
+
Sinapis arvensis,charlock,X,44609,7625,1562069,32232,true,,annual,yellow,3,10
|
1680
1681
|
Sisymbrium irio,London rocket,X,44651,7628,58085,32256,true
|
1681
1682
|
Sisymbrium officinale,hedge mustard,X,44653,7630,53266,32267,true
|
1682
1683
|
Sisymbrium orientale,,X,44654,7631,58086,32268,true
|
@@ -0,0 +1 @@
|
|
1
|
+
Petals with purple streaks.
|
@@ -0,0 +1 @@
|
|
1
|
+
Petals with purple streaks.
|
@@ -0,0 +1 @@
|
|
1
|
+
Petals not streaked. Leaf compound, fern-like. Bristles on sepals.
|
@@ -0,0 +1 @@
|
|
1
|
+
Petals not streaked, except near base. Leaves compound but not fern-like. No bristles on sepals.
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
|
4
|
+
<head>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
8
|
+
<title>{{title}}</title>
|
9
|
+
<link href="/assets/css/main.css" rel="stylesheet">
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
|
14
|
+
<nav class="navbar navbar-expand-md">
|
15
|
+
<div class="container-xxl px-5">
|
16
|
+
<button id="hamburger" class="navbar-toggler" type="button" data-bs-toggle="collapse"
|
17
|
+
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
|
18
|
+
aria-label="Toggle navigation">
|
19
|
+
<span class="navbar-toggler-icon"></span>
|
20
|
+
</button>
|
21
|
+
<a class="navbar-brand" href="/index.html">{{siteName}}</a>
|
22
|
+
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
23
|
+
<ul class="navbar-nav me-auto mb-lg-0">
|
24
|
+
<li class="nav-item">
|
25
|
+
<a class="nav-link" href="/index_lists.html">Plant Lists</a>
|
26
|
+
</li>
|
27
|
+
<li class="nav-item">
|
28
|
+
<a class="nav-link" href="/rare_plants.html">Rare Plants</a>
|
29
|
+
</li>
|
30
|
+
<li class="nav-item">
|
31
|
+
<a class="nav-link" href="/name_search.html">Name Search</a>
|
32
|
+
</li>
|
33
|
+
<li class="nav-item">
|
34
|
+
<a class="nav-link" href="/glossary.html">Glossary</a>
|
35
|
+
</li>
|
36
|
+
{%include "menu_extra.html" %}
|
37
|
+
</ul>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
</nav>
|
41
|
+
|
42
|
+
<div class="container-xxl px-5">
|
43
|
+
{{content|safe}}
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
|
47
|
+
|
48
|
+
{%if js%}<script src="/assets/js/{{js}}" type="module"></script>{%endif%}
|
49
|
+
|
50
|
+
<script src="/assets/js/ui.js" type="module"></script>
|
51
|
+
|
52
|
+
{%include "analytics.html"%}
|
53
|
+
</body>
|
54
|
+
|
55
|
+
</html>
|
package/lib/basepagerenderer.js
CHANGED
@@ -1,33 +1,49 @@
|
|
1
|
-
import
|
1
|
+
import path from "node:path";
|
2
2
|
import { Files } from "./files.js";
|
3
|
-
import { Jekyll } from "./jekyll.js";
|
4
3
|
import { GlossaryPages } from "./web/glossarypages.js";
|
5
4
|
import { PageFamilyList } from "./web/pageFamily.js";
|
5
|
+
import { Jekyll } from "./jekyll.js";
|
6
|
+
import { EleventyGenerator } from "./utils/eleventyGenerator.js";
|
6
7
|
|
7
|
-
class BasePageRenderer {
|
8
|
+
export class BasePageRenderer {
|
8
9
|
/**
|
10
|
+
* @param {import("./types.js").Config} config
|
9
11
|
* @param {string} outputDir
|
12
|
+
* @param {import("./index.js").SiteGeneratorOptions} options
|
13
|
+
* @param {"11ty"|"jekyll"} [type="11ty"]
|
14
|
+
* @returns {import("./types.js").SiteGenerator}
|
15
|
+
*/
|
16
|
+
static newSiteGenerator(config, outputDir, options = {}, type = "11ty") {
|
17
|
+
switch (type) {
|
18
|
+
case "jekyll":
|
19
|
+
return new Jekyll(config, outputDir);
|
20
|
+
}
|
21
|
+
return new EleventyGenerator(config, outputDir, options);
|
22
|
+
}
|
23
|
+
|
24
|
+
/**
|
25
|
+
* @param {import("./types.js").SiteGenerator} siteGenerator
|
10
26
|
* @param {import("./types.js").Taxa} taxa
|
11
27
|
* @param {import("./types.js").TaxaColDef[]} [familyCols]
|
12
28
|
*/
|
13
|
-
static renderBasePages(
|
14
|
-
const
|
29
|
+
static renderBasePages(siteGenerator, taxa, familyCols) {
|
30
|
+
const outputDir = siteGenerator.getBaseDir();
|
31
|
+
|
32
|
+
// Copy static files
|
33
|
+
siteGenerator.copyStaticFiles();
|
15
34
|
|
16
35
|
// Copy static files
|
17
|
-
|
18
|
-
Files.copyDir(Config.getPackageDir() + "/jekyll", outputDir);
|
19
|
-
// Then copy Jekyll files from current dir (which may override default files).
|
20
|
-
Files.copyDir("jekyll", outputDir);
|
36
|
+
siteGenerator.copyGeneratorFiles();
|
21
37
|
|
22
38
|
// Copy illustrations.
|
23
39
|
siteGenerator.copyIllustrations(taxa.getFlowerColors());
|
24
40
|
|
25
41
|
const fl = new PageFamilyList(
|
26
|
-
|
42
|
+
siteGenerator,
|
27
43
|
taxa.getFamilies().getFamilies(),
|
28
44
|
);
|
29
45
|
fl.render(familyCols);
|
30
|
-
fl.renderPages(
|
46
|
+
fl.renderPages(siteGenerator, familyCols);
|
31
47
|
|
32
48
|
new GlossaryPages(siteGenerator).renderPages();
|
33
49
|
|
@@ -41,24 +57,26 @@ class BasePageRenderer {
|
|
41
57
|
static renderTools(outputDir, taxa) {
|
42
58
|
const names = [];
|
43
59
|
for (const taxon of taxa.getTaxonList()) {
|
44
|
-
|
45
|
-
row
|
60
|
+
/** @type {(import("./types.js").NameSearchData)} */
|
61
|
+
const row = { t: taxon.getName() };
|
46
62
|
const cn = taxon.getCommonNames().join(", ");
|
47
63
|
if (cn) {
|
48
|
-
row.
|
64
|
+
row.c = cn;
|
49
65
|
}
|
50
66
|
const synonyms = [];
|
51
67
|
for (const syn of taxon.getSynonyms()) {
|
52
68
|
synonyms.push(syn);
|
53
69
|
}
|
54
70
|
if (synonyms.length > 0) {
|
55
|
-
row
|
71
|
+
row.s = synonyms;
|
56
72
|
}
|
57
73
|
names.push(row);
|
58
74
|
}
|
59
75
|
|
60
|
-
Files.write(
|
76
|
+
Files.write(
|
77
|
+
path.join(outputDir, "./assets/js/nameSearchData.js"),
|
78
|
+
`export const NAMES = ${JSON.stringify(names)};`,
|
79
|
+
true,
|
80
|
+
);
|
61
81
|
}
|
62
82
|
}
|
63
|
-
|
64
|
-
export { BasePageRenderer };
|
package/lib/config.js
CHANGED
@@ -8,7 +8,7 @@ const COUNTY_NAMES = {
|
|
8
8
|
CCA: "Contra Costa",
|
9
9
|
};
|
10
10
|
|
11
|
-
class Config {
|
11
|
+
export class Config {
|
12
12
|
static #packageDir = path.dirname(
|
13
13
|
path.dirname(url.fileURLToPath(import.meta.url)),
|
14
14
|
);
|
@@ -88,6 +88,8 @@ class Config {
|
|
88
88
|
static getPackageDir() {
|
89
89
|
return this.#packageDir;
|
90
90
|
}
|
91
|
-
}
|
92
91
|
|
93
|
-
|
92
|
+
getSiteName() {
|
93
|
+
return this.#config.siteName ?? "California Plants";
|
94
|
+
}
|
95
|
+
}
|
package/lib/ebook/ebookpage.js
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
import * as fs from "node:fs";
|
2
2
|
|
3
|
-
class EBookPage {
|
3
|
+
export class EBookPage {
|
4
4
|
#fileName;
|
5
5
|
#title;
|
6
6
|
#rootPrefix;
|
7
7
|
|
8
8
|
/**
|
9
|
-
*
|
10
9
|
* @param {string} fileName
|
11
10
|
* @param {string} title
|
12
11
|
* @param {string} rootPrefix
|
@@ -56,5 +55,3 @@ class EBookPage {
|
|
56
55
|
return html;
|
57
56
|
}
|
58
57
|
}
|
59
|
-
|
60
|
-
export { EBookPage };
|
@@ -1,14 +1,8 @@
|
|
1
|
+
import path from "node:path";
|
1
2
|
import { Files } from "../files.js";
|
2
3
|
import { SiteGenerator } from "../sitegenerator.js";
|
3
4
|
|
4
|
-
class EBookSiteGenerator extends SiteGenerator {
|
5
|
-
/**
|
6
|
-
* @param {string} baseDir
|
7
|
-
*/
|
8
|
-
constructor(baseDir) {
|
9
|
-
super(baseDir);
|
10
|
-
}
|
11
|
-
|
5
|
+
export class EBookSiteGenerator extends SiteGenerator {
|
12
6
|
#pageEnd() {
|
13
7
|
return "</body></html>";
|
14
8
|
}
|
@@ -47,10 +41,8 @@ class EBookSiteGenerator extends SiteGenerator {
|
|
47
41
|
writeTemplate(content, attributes, filename) {
|
48
42
|
const depth = (filename.match(/\//g) || []).length;
|
49
43
|
Files.write(
|
50
|
-
|
51
|
-
this.#wrap(depth, content, attributes)
|
44
|
+
path.join(this.getBaseDir(), filename),
|
45
|
+
this.#wrap(depth, content, attributes),
|
52
46
|
);
|
53
47
|
}
|
54
48
|
}
|
55
|
-
|
56
|
-
export { EBookSiteGenerator };
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { GlossaryPages as BaseGlossaryPages } from "../web/glossarypages.js";
|
2
2
|
import { EBook } from "./ebook.js";
|
3
3
|
|
4
|
-
class GlossaryPages extends BaseGlossaryPages {
|
4
|
+
export class GlossaryPages extends BaseGlossaryPages {
|
5
5
|
/**
|
6
6
|
* @param {import("../sitegenerator.js").SiteGenerator} siteGenerator
|
7
7
|
*/
|
@@ -39,5 +39,3 @@ class GlossaryPages extends BaseGlossaryPages {
|
|
39
39
|
return spineEntries.join("");
|
40
40
|
}
|
41
41
|
}
|
42
|
-
|
43
|
-
export { GlossaryPages };
|
package/lib/ebook/plantbook.js
CHANGED
@@ -29,7 +29,7 @@ class PlantBook extends EBook {
|
|
29
29
|
);
|
30
30
|
|
31
31
|
this.#taxa = taxa;
|
32
|
-
const generator = new EBookSiteGenerator(this.getContentDir());
|
32
|
+
const generator = new EBookSiteGenerator(config, this.getContentDir());
|
33
33
|
this.#glossary = new GlossaryPages(generator);
|
34
34
|
this.#images = new Images(generator, this.getContentDir(), taxa);
|
35
35
|
}
|
package/lib/files.js
CHANGED
package/lib/htmltaxon.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
import path from "node:path";
|
1
2
|
import { Config } from "./config.js";
|
2
3
|
import { DateUtils } from "./dateutils.js";
|
3
4
|
import { ExternalSites } from "./externalsites.js";
|
4
5
|
import { HTML } from "./html.js";
|
5
|
-
import { Markdown } from "./markdown.js";
|
6
6
|
import { RarePlants } from "./rareplants.js";
|
7
7
|
import { TextUtils } from "./textutils.js";
|
8
|
+
import { HTMLFragments } from "./utils/htmlFragments.js";
|
8
9
|
|
9
10
|
/**
|
10
11
|
* @type {Record<string,import("./types.js").TaxaColDef>}
|
@@ -204,12 +205,12 @@ class HTMLTaxon {
|
|
204
205
|
* @returns {string}
|
205
206
|
*/
|
206
207
|
static getFooterHTML(taxon) {
|
207
|
-
const footerTextPath =
|
208
|
-
Config.getPackageDir()
|
209
|
-
"/data/text/"
|
210
|
-
taxon.getBaseFileName()
|
211
|
-
|
212
|
-
return
|
208
|
+
const footerTextPath = path.join(
|
209
|
+
Config.getPackageDir(),
|
210
|
+
"/data/text/",
|
211
|
+
`${taxon.getBaseFileName()}.footer.md`,
|
212
|
+
);
|
213
|
+
return HTMLFragments.getMarkdownSection(footerTextPath);
|
213
214
|
}
|
214
215
|
|
215
216
|
/**
|
@@ -271,18 +272,6 @@ class HTMLTaxon {
|
|
271
272
|
return html;
|
272
273
|
}
|
273
274
|
|
274
|
-
/**
|
275
|
-
* @param {string} filePath
|
276
|
-
* @returns {string}
|
277
|
-
*/
|
278
|
-
static getMarkdownSection(filePath) {
|
279
|
-
const footerMarkdown = Markdown.fileToHTML(filePath);
|
280
|
-
if (footerMarkdown) {
|
281
|
-
return HTML.wrap("div", footerMarkdown, "section");
|
282
|
-
}
|
283
|
-
return "";
|
284
|
-
}
|
285
|
-
|
286
275
|
/**
|
287
276
|
* @param {import("./types.js").Taxon} taxon
|
288
277
|
*/
|
package/lib/index.d.ts
CHANGED
@@ -15,6 +15,10 @@ type RefSourceCode =
|
|
15
15
|
| "jepson"
|
16
16
|
| "rpi";
|
17
17
|
|
18
|
+
type SiteGeneratorOptions = {
|
19
|
+
passThroughPatterns?: string[];
|
20
|
+
};
|
21
|
+
|
18
22
|
type TaxaColDef<T> = {
|
19
23
|
title: string;
|
20
24
|
class?: string;
|
@@ -46,11 +50,20 @@ export type TaxonData = TaxonomyData & {
|
|
46
50
|
taxon_name: string;
|
47
51
|
};
|
48
52
|
|
53
|
+
export type TaxonOverrides = {
|
54
|
+
status?: NativeStatusCode;
|
55
|
+
};
|
56
|
+
|
49
57
|
// Classes
|
50
58
|
|
51
59
|
export class BasePageRenderer {
|
52
|
-
static
|
60
|
+
static newSiteGenerator(
|
61
|
+
config: Config,
|
53
62
|
outputDir: string,
|
63
|
+
options?: SiteGeneratorOptions,
|
64
|
+
): SiteGenerator;
|
65
|
+
static renderBasePages<T extends Taxon>(
|
66
|
+
siteGenerator: SiteGenerator,
|
54
67
|
taxa: Taxa<T>,
|
55
68
|
familyCols?: TaxaColDef<T>[],
|
56
69
|
): void;
|
@@ -73,6 +86,11 @@ export class CSV {
|
|
73
86
|
fileName: string,
|
74
87
|
delimeter?: string,
|
75
88
|
): Record<string, string>[];
|
89
|
+
static writeFileObject(
|
90
|
+
fileName: string,
|
91
|
+
data: Record<string, any>[],
|
92
|
+
headerData: string[],
|
93
|
+
): void;
|
76
94
|
}
|
77
95
|
|
78
96
|
export class ErrorLog {
|
@@ -104,6 +122,7 @@ export class Files {
|
|
104
122
|
targetFileName: string | undefined,
|
105
123
|
): Promise<Headers>;
|
106
124
|
static mkdir(dir: string): void;
|
125
|
+
static read(path: string): string;
|
107
126
|
static rmDir(dir: string): void;
|
108
127
|
static write(fileName: string, data: string, overwrite?: boolean): void;
|
109
128
|
}
|
@@ -140,6 +159,10 @@ export class HTML {
|
|
140
159
|
): string;
|
141
160
|
}
|
142
161
|
|
162
|
+
export class HTMLFragments {
|
163
|
+
static getMarkdownSection(filePath: string): string;
|
164
|
+
}
|
165
|
+
|
143
166
|
export class HTMLTaxon {
|
144
167
|
static addLink(
|
145
168
|
links: string[],
|
@@ -164,12 +187,6 @@ export class HTMLTaxon {
|
|
164
187
|
header: string,
|
165
188
|
className?: string,
|
166
189
|
): string;
|
167
|
-
static getMarkdownSection(filePath: string): string;
|
168
|
-
}
|
169
|
-
|
170
|
-
export class Jekyll {
|
171
|
-
static hasInclude(baseDir: string, path: string): boolean;
|
172
|
-
static include(fileName: string): string;
|
173
190
|
}
|
174
191
|
|
175
192
|
export class Photo {
|
@@ -185,13 +202,19 @@ export class Program {
|
|
185
202
|
static getProgram(): Command;
|
186
203
|
}
|
187
204
|
|
205
|
+
export class SiteGenerator {
|
206
|
+
generate(outputDir: string): Promise<void>;
|
207
|
+
getBaseDir(): string;
|
208
|
+
getFrontMatter(atts: Record<string, string | undefined>): string;
|
209
|
+
}
|
210
|
+
|
188
211
|
export class Taxa<T> {
|
189
212
|
constructor(
|
190
|
-
inclusionList: Record<string,
|
213
|
+
inclusionList: Record<string, TaxonOverrides> | true,
|
191
214
|
errorLog: ErrorLog,
|
192
215
|
showFlowerErrors: boolean,
|
193
216
|
taxonFactory?: (td: TaxonData, g: Genera) => T,
|
194
|
-
extraTaxa?:
|
217
|
+
extraTaxa?: TaxonOverrides[],
|
195
218
|
extraSynonyms?: Record<string, string>[],
|
196
219
|
);
|
197
220
|
getTaxon(name: string): T;
|
package/lib/index.js
CHANGED
@@ -7,10 +7,11 @@ import { ExternalSites } from "./externalsites.js";
|
|
7
7
|
import { Families } from "./taxonomy/families.js";
|
8
8
|
import { Files } from "./files.js";
|
9
9
|
import { HTML } from "./html.js";
|
10
|
+
import { HTMLFragments } from "./utils/htmlFragments.js";
|
10
11
|
import { HTMLTaxon } from "./htmltaxon.js";
|
11
|
-
import { Jekyll } from "./jekyll.js";
|
12
12
|
import { PlantBook } from "./ebook/plantbook.js";
|
13
13
|
import { Program } from "./program.js";
|
14
|
+
import { SiteGenerator } from "./sitegenerator.js";
|
14
15
|
import { Taxa } from "./taxonomy/taxa.js";
|
15
16
|
import { Taxon } from "./taxonomy/taxon.js";
|
16
17
|
|
@@ -24,10 +25,11 @@ export {
|
|
24
25
|
Families,
|
25
26
|
Files,
|
26
27
|
HTML,
|
28
|
+
HTMLFragments,
|
27
29
|
HTMLTaxon,
|
28
|
-
Jekyll,
|
29
30
|
PlantBook,
|
30
31
|
Program,
|
32
|
+
SiteGenerator,
|
31
33
|
Taxa,
|
32
34
|
Taxon,
|
33
35
|
};
|
package/lib/jekyll.js
CHANGED
@@ -1,71 +1,52 @@
|
|
1
|
+
import * as child_process from "node:child_process";
|
2
|
+
import * as path from "node:path";
|
1
3
|
import { Files } from "./files.js";
|
2
4
|
import { SiteGenerator } from "./sitegenerator.js";
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
import { Config } from "./config.js";
|
6
|
+
|
7
|
+
export class Jekyll extends SiteGenerator {
|
8
|
+
copyGeneratorFiles() {
|
9
|
+
// First copy default files from package.
|
10
|
+
Files.copyDir(
|
11
|
+
path.join(Config.getPackageDir(), "./generators/jekyll"),
|
12
|
+
this.getBaseDir(),
|
13
|
+
);
|
14
|
+
// Then copy files from current dir (which may override default files).
|
15
|
+
Files.copyDir("./generators/jekyll", this.getBaseDir());
|
12
16
|
}
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
async generate() {
|
19
|
+
/**
|
20
|
+
* @param {string[]} configFiles
|
21
|
+
* @param {string} dir
|
22
|
+
* @param {string} name
|
23
|
+
*/
|
24
|
+
function addConfigFile(configFiles, dir, name) {
|
25
|
+
const fullPath = path.join(dir, name);
|
26
|
+
if (Files.exists(fullPath)) {
|
27
|
+
configFiles.push(fullPath);
|
28
|
+
}
|
21
29
|
}
|
22
|
-
if (!atts.layout) {
|
23
|
-
lines.push("layout: default");
|
24
|
-
}
|
25
|
-
lines.push(FRONT_DELIM);
|
26
|
-
return lines.join("\n") + "\n";
|
27
|
-
}
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
* @param {string} path
|
32
|
-
*/
|
33
|
-
static hasInclude(baseDir, path) {
|
34
|
-
return Files.exists(baseDir + "/_includes/" + path);
|
35
|
-
}
|
31
|
+
const srcDir = "./output";
|
32
|
+
const destDir = "./public";
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
*/
|
40
|
-
static include(path) {
|
41
|
-
// This works for .md includes; should have conditional logic to detect other types.
|
42
|
-
return (
|
43
|
-
"{% capture my_include %}{% include " +
|
44
|
-
path +
|
45
|
-
" %}{% endcapture %}{{ my_include | markdownify }}"
|
46
|
-
);
|
47
|
-
}
|
34
|
+
// Remove existing files.
|
35
|
+
Files.rmDir(destDir);
|
48
36
|
|
49
|
-
|
50
|
-
* @param {string} baseDir
|
51
|
-
* @param {string} path
|
52
|
-
* @param {string} data
|
53
|
-
*/
|
54
|
-
static writeInclude(baseDir, path, data) {
|
55
|
-
Files.write(baseDir + "/_includes/" + path, data);
|
56
|
-
}
|
37
|
+
const options = ["--source", srcDir, "--destination", destDir];
|
57
38
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
39
|
+
// Find out what config files are available.
|
40
|
+
/** @type {string[]} */
|
41
|
+
const configFiles = [];
|
42
|
+
addConfigFile(configFiles, srcDir, "_config.yml");
|
43
|
+
addConfigFile(configFiles, srcDir, "_config-local.yml");
|
44
|
+
addConfigFile(configFiles, ".", "_config-dev.yml");
|
45
|
+
options.push("--config", `"${configFiles.join()}"`);
|
46
|
+
|
47
|
+
const result = child_process.execSync(
|
48
|
+
"bundle exec jekyll build " + options.join(" "),
|
67
49
|
);
|
50
|
+
console.log(result.toString());
|
68
51
|
}
|
69
52
|
}
|
70
|
-
|
71
|
-
export { Jekyll };
|
package/lib/markdown.js
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
import markdownIt from "markdown-it";
|
2
2
|
import { Files } from "./files.js";
|
3
3
|
|
4
|
-
class Markdown {
|
4
|
+
export class Markdown {
|
5
5
|
static #md = new markdownIt({ xhtmlOut: true });
|
6
6
|
|
7
7
|
/**
|
8
8
|
* @param {string} filePath
|
9
|
-
* @returns {string
|
9
|
+
* @returns {string}
|
10
10
|
*/
|
11
11
|
static fileToHTML(filePath) {
|
12
12
|
if (!Files.exists(filePath)) {
|
13
|
-
return;
|
13
|
+
return "";
|
14
14
|
}
|
15
15
|
return this.strToHTML(Files.read(filePath));
|
16
16
|
}
|
@@ -22,5 +22,3 @@ class Markdown {
|
|
22
22
|
return this.#md.render(str);
|
23
23
|
}
|
24
24
|
}
|
25
|
-
|
26
|
-
export { Markdown };
|