@ca-plant-list/ca-plant-list 0.4.26 → 0.4.28
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/exceptions.json +0 -27
- package/data/genera.json +52 -28
- package/data/glossary/anther.md +3 -0
- package/data/glossary/filament.md +3 -0
- package/data/glossary/stamen.md +3 -0
- package/data/illustrations/inkscape/stamen.svg +132 -0
- package/data/inatobsphotos.csv +0 -5
- package/data/inattaxonphotos.csv +69 -64
- package/data/synonyms.csv +155 -164
- package/data/taxa.csv +38 -38
- package/data/text/Dichelostemma-congestum.md +1 -0
- package/data/text/Dipterostemon-capitatus-subsp-capitatus.md +1 -0
- package/generators/eleventy/layouts/h1.njk +6 -0
- package/generators/eleventy/layouts/html.njk +55 -0
- package/lib/basepagerenderer.js +35 -15
- 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 +20 -8
- 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/taxon.js +5 -1
- package/lib/tools/cch2.js +37 -18
- package/lib/tools/jepsonfamilies.js +1 -1
- 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/scripts/cpl-photos.js +61 -24
- package/scripts/cpl-tools.js +4 -1
- package/static/assets/js/nameSearchData.js +2 -0
- package/{jekyll → static}/assets/js/name_search.js +12 -14
- package/static/name_search.html +15 -0
- package/jekyll/_includes/glossary.html +0 -0
- 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}/assets/js/ui.js +0 -0
- /package/{jekyll → static}/assets/js/utils.js +0 -0
- /package/{jekyll → static}/index.md +0 -0
package/lib/web/pageFamily.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ExternalSites } from "../externalsites.js";
|
2
|
-
import { GenericPage } from "
|
2
|
+
import { GenericPage } from "./pageGeneric.js";
|
3
3
|
import { HTML } from "../html.js";
|
4
4
|
import { HTMLTaxon } from "../htmltaxon.js";
|
5
5
|
import { Sections } from "../taxonomy/families.js";
|
@@ -8,11 +8,11 @@ export class PageFamilyList extends GenericPage {
|
|
8
8
|
#families;
|
9
9
|
|
10
10
|
/**
|
11
|
-
* @param {
|
11
|
+
* @param {import("../types.js").SiteGenerator} siteGenerator
|
12
12
|
* @param {import("../types.js").Family[]} families
|
13
13
|
*/
|
14
|
-
constructor(
|
15
|
-
super(
|
14
|
+
constructor(siteGenerator, families) {
|
15
|
+
super(siteGenerator, "Families", "list_families");
|
16
16
|
this.#families = families;
|
17
17
|
}
|
18
18
|
|
@@ -28,7 +28,7 @@ export class PageFamilyList extends GenericPage {
|
|
28
28
|
const taxa = sections[name];
|
29
29
|
|
30
30
|
// Render the section page.
|
31
|
-
new PageSection(this.
|
31
|
+
new PageSection(this.getSiteGenerator(), name, taxa).render(
|
32
32
|
taxaColumns,
|
33
33
|
);
|
34
34
|
|
@@ -69,13 +69,13 @@ export class PageFamilyList extends GenericPage {
|
|
69
69
|
}
|
70
70
|
|
71
71
|
/**
|
72
|
-
* @param {
|
72
|
+
* @param {import("../types.js").SiteGenerator} siteGenerator
|
73
73
|
* @param {import("../types.js").TaxaColDef[]} [taxaColumns]
|
74
74
|
*/
|
75
|
-
renderPages(
|
75
|
+
renderPages(siteGenerator, taxaColumns) {
|
76
76
|
for (const family of this.#families) {
|
77
77
|
if (family.getTaxa()) {
|
78
|
-
new PageFamily(
|
78
|
+
new PageFamily(siteGenerator, family).render(taxaColumns);
|
79
79
|
}
|
80
80
|
}
|
81
81
|
}
|
@@ -85,11 +85,11 @@ class PageFamily extends GenericPage {
|
|
85
85
|
#family;
|
86
86
|
|
87
87
|
/**
|
88
|
-
* @param {
|
88
|
+
* @param {import("../types.js").SiteGenerator} siteGenerator
|
89
89
|
* @param {import("../types.js").Family} family
|
90
90
|
*/
|
91
|
-
constructor(
|
92
|
-
super(
|
91
|
+
constructor(siteGenerator, family) {
|
92
|
+
super(siteGenerator, family.getName(), family.getBaseFileName());
|
93
93
|
this.#family = family;
|
94
94
|
}
|
95
95
|
|
@@ -124,12 +124,12 @@ class PageSection extends GenericPage {
|
|
124
124
|
#taxa;
|
125
125
|
|
126
126
|
/**
|
127
|
-
* @param {
|
127
|
+
* @param {import("../types.js").SiteGenerator} siteGenerator
|
128
128
|
* @param {string} name
|
129
129
|
* @param {import("../types.js").Taxon[]} taxa
|
130
130
|
*/
|
131
|
-
constructor(
|
132
|
-
super(
|
131
|
+
constructor(siteGenerator, name, taxa) {
|
132
|
+
super(siteGenerator, name, name);
|
133
133
|
this.#taxa = taxa;
|
134
134
|
}
|
135
135
|
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import path from "node:path";
|
2
|
+
import { Config } from "../config.js";
|
3
|
+
import { Files } from "../files.js";
|
4
|
+
import { HTMLFragments } from "../utils/htmlFragments.js";
|
5
|
+
|
6
|
+
export class GenericPage {
|
7
|
+
#siteGenerator;
|
8
|
+
#title;
|
9
|
+
#baseFileName;
|
10
|
+
#js;
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @param {import("../types.js").SiteGenerator} siteGenerator
|
14
|
+
* @param {string} title
|
15
|
+
* @param {string} baseFileName
|
16
|
+
* @param {string} [js]
|
17
|
+
*/
|
18
|
+
constructor(siteGenerator, title, baseFileName, js) {
|
19
|
+
this.#siteGenerator = siteGenerator;
|
20
|
+
this.#title = title;
|
21
|
+
this.#baseFileName = baseFileName;
|
22
|
+
this.#js = js;
|
23
|
+
}
|
24
|
+
|
25
|
+
getBaseFileName() {
|
26
|
+
return this.#baseFileName;
|
27
|
+
}
|
28
|
+
|
29
|
+
getDefaultIntro() {
|
30
|
+
let html = this.getFrontMatter();
|
31
|
+
return html + this.getMarkdown();
|
32
|
+
}
|
33
|
+
|
34
|
+
getFrontMatter() {
|
35
|
+
return this.#siteGenerator.getFrontMatter({
|
36
|
+
title: this.#title,
|
37
|
+
js: this.#js,
|
38
|
+
});
|
39
|
+
}
|
40
|
+
|
41
|
+
getMarkdown() {
|
42
|
+
const localTextPath = path.join(
|
43
|
+
"./data/intros",
|
44
|
+
`${this.#baseFileName}.md`,
|
45
|
+
);
|
46
|
+
const globalTextPath = path.join(
|
47
|
+
Config.getPackageDir(),
|
48
|
+
"./data/text/",
|
49
|
+
`${this.#baseFileName}.md`,
|
50
|
+
);
|
51
|
+
return (
|
52
|
+
HTMLFragments.getMarkdownSection(localTextPath) +
|
53
|
+
HTMLFragments.getMarkdownSection(globalTextPath)
|
54
|
+
);
|
55
|
+
}
|
56
|
+
|
57
|
+
getOutputDir() {
|
58
|
+
return this.#siteGenerator.getBaseDir();
|
59
|
+
}
|
60
|
+
|
61
|
+
getSiteGenerator() {
|
62
|
+
return this.#siteGenerator;
|
63
|
+
}
|
64
|
+
|
65
|
+
getTitle() {
|
66
|
+
return this.#title;
|
67
|
+
}
|
68
|
+
|
69
|
+
/**
|
70
|
+
* @param {string} html
|
71
|
+
*/
|
72
|
+
writeFile(html) {
|
73
|
+
Files.write(
|
74
|
+
path.join(this.getOutputDir(), `${this.#baseFileName}.html`),
|
75
|
+
html,
|
76
|
+
);
|
77
|
+
}
|
78
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { RarePlants } from "../rareplants.js";
|
2
|
-
import { GenericPage } from "
|
2
|
+
import { GenericPage } from "./pageGeneric.js";
|
3
3
|
import { HTML } from "../html.js";
|
4
4
|
import { HTMLTaxon } from "../htmltaxon.js";
|
5
5
|
|
@@ -8,12 +8,12 @@ export class PageTaxon extends GenericPage {
|
|
8
8
|
#taxon;
|
9
9
|
|
10
10
|
/**
|
11
|
-
* @param {
|
11
|
+
* @param {import("../types.js").SiteGenerator} siteGenerator
|
12
12
|
* @param {import("../config.js").Config} config
|
13
13
|
* @param {import("../types.js").Taxon} taxon
|
14
14
|
*/
|
15
|
-
constructor(
|
16
|
-
super(
|
15
|
+
constructor(siteGenerator, config, taxon) {
|
16
|
+
super(siteGenerator, taxon.getName(), taxon.getBaseFileName());
|
17
17
|
this.#config = config;
|
18
18
|
this.#taxon = taxon;
|
19
19
|
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { GenericPage } from "./pageGeneric.js";
|
2
|
+
import { HTML } from "../html.js";
|
3
|
+
import { HTMLTaxon } from "../htmltaxon.js";
|
4
|
+
|
5
|
+
export class PageTaxonList extends GenericPage {
|
6
|
+
/**
|
7
|
+
* @param {import("../types.js").SiteGenerator} siteGenerator
|
8
|
+
* @param {string} title
|
9
|
+
* @param {string} baseName
|
10
|
+
*/
|
11
|
+
constructor(siteGenerator, title, baseName) {
|
12
|
+
super(siteGenerator, title, baseName);
|
13
|
+
}
|
14
|
+
|
15
|
+
/**
|
16
|
+
*
|
17
|
+
* @param {import("../types.js").Taxon[]} taxa
|
18
|
+
* @param {import("../types.js").TaxaColDef[]|undefined} columns
|
19
|
+
*/
|
20
|
+
render(taxa, columns) {
|
21
|
+
let html = this.getDefaultIntro();
|
22
|
+
|
23
|
+
html += '<div class="wrapper">';
|
24
|
+
|
25
|
+
html += '<div class="section">';
|
26
|
+
html += HTMLTaxon.getTaxaTable(taxa, columns);
|
27
|
+
html += "</div>";
|
28
|
+
|
29
|
+
html += '<div class="section nobullet">';
|
30
|
+
html += HTML.textElement("h2", "Download");
|
31
|
+
html += "<ul>";
|
32
|
+
html +=
|
33
|
+
"<li>" +
|
34
|
+
HTML.getLink(
|
35
|
+
"./calflora_" + this.getBaseFileName() + ".txt",
|
36
|
+
"Calflora List",
|
37
|
+
) +
|
38
|
+
"</li>";
|
39
|
+
html +=
|
40
|
+
"<li>" +
|
41
|
+
HTML.getLink(
|
42
|
+
"./inat_" + this.getBaseFileName() + ".txt",
|
43
|
+
"iNaturalist List",
|
44
|
+
) +
|
45
|
+
"</li>";
|
46
|
+
html += "</ul>";
|
47
|
+
html += "</div>";
|
48
|
+
|
49
|
+
html += "</div>";
|
50
|
+
|
51
|
+
this.writeFile(html);
|
52
|
+
}
|
53
|
+
}
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
1
|
+
import { RarePlants } from "../rareplants.js";
|
2
|
+
import { BasePageRenderer } from "../basepagerenderer.js";
|
3
|
+
import { Files } from "../files.js";
|
4
|
+
import { HTML } from "../html.js";
|
5
|
+
import { TAXA_LIST_COLS } from "../htmltaxon.js";
|
6
|
+
import { PageTaxonList } from "./pageTaxonList.js";
|
7
|
+
import { HTMLFragments } from "../utils/htmlFragments.js";
|
8
|
+
import { PageTaxon } from "./pageTaxon.js";
|
8
9
|
|
9
10
|
const ENDANGERED_COLS = [
|
10
11
|
TAXA_LIST_COLS.SPECIES,
|
@@ -18,33 +19,33 @@ const RPI_COLUMNS = [
|
|
18
19
|
TAXA_LIST_COLS.CNPS_RANK,
|
19
20
|
];
|
20
21
|
|
21
|
-
class PageRenderer extends BasePageRenderer {
|
22
|
+
export class PageRenderer extends BasePageRenderer {
|
22
23
|
/**
|
23
|
-
* @param {
|
24
|
-
* @param {import('
|
25
|
-
* @param {import("
|
24
|
+
* @param {import("../types.js").SiteGenerator} siteGenerator
|
25
|
+
* @param {import('../config.js').Config} config
|
26
|
+
* @param {import("../types.js").Taxa} taxa
|
26
27
|
*/
|
27
|
-
static
|
28
|
-
super.renderBasePages(
|
28
|
+
static renderAll(siteGenerator, config, taxa) {
|
29
|
+
super.renderBasePages(siteGenerator, taxa);
|
29
30
|
|
30
|
-
this.renderLists(
|
31
|
+
this.renderLists(siteGenerator, config, taxa);
|
31
32
|
|
32
33
|
const taxonList = taxa.getTaxonList();
|
33
34
|
for (const taxon of taxonList) {
|
34
|
-
new PageTaxon(
|
35
|
+
new PageTaxon(siteGenerator, config, taxon).render();
|
35
36
|
}
|
36
37
|
}
|
37
38
|
|
38
39
|
/**
|
39
|
-
* @param {
|
40
|
-
* @param {import('
|
41
|
-
* @param {import("
|
40
|
+
* @param {import("../types.js").SiteGenerator} siteGenerator
|
41
|
+
* @param {import('../config.js').Config} config
|
42
|
+
* @param {import("../types.js").Taxa} taxa
|
42
43
|
*/
|
43
|
-
static renderLists(
|
44
|
+
static renderLists(siteGenerator, config, taxa) {
|
44
45
|
/**
|
45
46
|
* @param {ListInfo[]} listInfo
|
46
47
|
* @param {Object<string,string>} attributes
|
47
|
-
* @param {import("
|
48
|
+
* @param {import("../types.js").TaxaColDef[]} [columns]
|
48
49
|
* @returns {string}
|
49
50
|
*/
|
50
51
|
function getListArray(listInfo, attributes = {}, columns) {
|
@@ -75,10 +76,11 @@ class PageRenderer extends BasePageRenderer {
|
|
75
76
|
);
|
76
77
|
|
77
78
|
const cols = columns ? columns : list.columns;
|
78
|
-
new PageTaxonList(
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
new PageTaxonList(
|
80
|
+
siteGenerator,
|
81
|
+
list.name,
|
82
|
+
list.filename,
|
83
|
+
).render(listTaxa, cols);
|
82
84
|
|
83
85
|
// Check for sublists.
|
84
86
|
const subListHTML = list.listInfo
|
@@ -117,7 +119,9 @@ class PageRenderer extends BasePageRenderer {
|
|
117
119
|
return html;
|
118
120
|
}
|
119
121
|
|
120
|
-
|
122
|
+
const outputDir = siteGenerator.getBaseDir();
|
123
|
+
|
124
|
+
/** @typedef {{name:string,filename:string,include:function(import("../types.js").Taxon):boolean,columns?:import("../types.js").TaxaColDef[],listInfo?:ListInfo[]}} ListInfo */
|
121
125
|
/** @type {{title:string,listInfo:ListInfo[]}[]} */
|
122
126
|
const sections = [
|
123
127
|
{
|
@@ -191,7 +195,10 @@ class PageRenderer extends BasePageRenderer {
|
|
191
195
|
},
|
192
196
|
];
|
193
197
|
|
194
|
-
let html =
|
198
|
+
let html =
|
199
|
+
HTMLFragments.getMarkdownSection("./data/intros/index_lists.md") +
|
200
|
+
'<div class="wrapper">';
|
201
|
+
|
195
202
|
for (const section of sections) {
|
196
203
|
const listHTML = getListArray(section.listInfo);
|
197
204
|
|
@@ -208,59 +215,10 @@ class PageRenderer extends BasePageRenderer {
|
|
208
215
|
|
209
216
|
html += "</div>";
|
210
217
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
class PageTaxonList extends GenericPage {
|
217
|
-
/**
|
218
|
-
* @param {string} outputDir
|
219
|
-
* @param {string} title
|
220
|
-
* @param {string} baseName
|
221
|
-
*/
|
222
|
-
constructor(outputDir, title, baseName) {
|
223
|
-
super(outputDir, title, baseName);
|
224
|
-
}
|
225
|
-
|
226
|
-
/**
|
227
|
-
*
|
228
|
-
* @param {import("./types.js").Taxon[]} taxa
|
229
|
-
* @param {import("./types.js").TaxaColDef[]|undefined} columns
|
230
|
-
*/
|
231
|
-
render(taxa, columns) {
|
232
|
-
let html = this.getDefaultIntro();
|
233
|
-
|
234
|
-
html += '<div class="wrapper">';
|
235
|
-
|
236
|
-
html += '<div class="section">';
|
237
|
-
html += HTMLTaxon.getTaxaTable(taxa, columns);
|
238
|
-
html += "</div>";
|
239
|
-
|
240
|
-
html += '<div class="section nobullet">';
|
241
|
-
html += HTML.textElement("h2", "Download");
|
242
|
-
html += "<ul>";
|
243
|
-
html +=
|
244
|
-
"<li>" +
|
245
|
-
HTML.getLink(
|
246
|
-
"./calflora_" + this.getBaseFileName() + ".txt",
|
247
|
-
"Calflora List",
|
248
|
-
) +
|
249
|
-
"</li>";
|
250
|
-
html +=
|
251
|
-
"<li>" +
|
252
|
-
HTML.getLink(
|
253
|
-
"./inat_" + this.getBaseFileName() + ".txt",
|
254
|
-
"iNaturalist List",
|
255
|
-
) +
|
256
|
-
"</li>";
|
257
|
-
html += "</ul>";
|
258
|
-
html += "</div>";
|
259
|
-
|
260
|
-
html += "</div>";
|
261
|
-
|
262
|
-
this.writeFile(html);
|
218
|
+
siteGenerator.writeTemplate(
|
219
|
+
html,
|
220
|
+
{ title: "Plant lists" },
|
221
|
+
"index_lists.html",
|
222
|
+
);
|
263
223
|
}
|
264
224
|
}
|
265
|
-
|
266
|
-
export { PageRenderer };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ca-plant-list/ca-plant-list",
|
3
|
-
"version": "0.4.
|
4
|
-
"description": "Tools to create
|
3
|
+
"version": "0.4.28",
|
4
|
+
"description": "Tools to create files for a website listing plants in an area of California.",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": {
|
7
7
|
"type": "git",
|
@@ -12,9 +12,10 @@
|
|
12
12
|
"files": [
|
13
13
|
"data",
|
14
14
|
"ebook",
|
15
|
-
"
|
15
|
+
"generators",
|
16
16
|
"lib",
|
17
|
-
"scripts"
|
17
|
+
"scripts",
|
18
|
+
"static"
|
18
19
|
],
|
19
20
|
"exports": {
|
20
21
|
".": "./lib/index.js"
|
@@ -22,10 +23,10 @@
|
|
22
23
|
"types": "./lib/index.d.ts",
|
23
24
|
"scripts": {
|
24
25
|
"check": "npm run eslint && npm run tsc && npm run jest",
|
25
|
-
"eslint": "
|
26
|
+
"eslint": "eslint",
|
26
27
|
"jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js tests",
|
27
|
-
"prettier": "
|
28
|
-
"tsc": "
|
28
|
+
"prettier": "prettier -l .",
|
29
|
+
"tsc": "tsc"
|
29
30
|
},
|
30
31
|
"bin": {
|
31
32
|
"ca-plant-list": "scripts/build-site.js",
|
@@ -35,10 +36,11 @@
|
|
35
36
|
"inatobsphotos": "scripts/inatobsphotos.js"
|
36
37
|
},
|
37
38
|
"dependencies": {
|
39
|
+
"@11ty/eleventy": "^3.0.0",
|
38
40
|
"@htmltools/scrape": "^0.1.1",
|
39
41
|
"archiver": "^5.3.1",
|
40
42
|
"cli-progress": "^3.12.0",
|
41
|
-
"commander": "^
|
43
|
+
"commander": "^13.1.0",
|
42
44
|
"csv-parse": "^5.6.0",
|
43
45
|
"csv-stringify": "^6.5.2",
|
44
46
|
"exceljs": "^4.4.0",
|
@@ -55,9 +57,9 @@
|
|
55
57
|
"@types/markdown-it": "^14.1.2",
|
56
58
|
"@types/node": "^22.10.7",
|
57
59
|
"@types/unzipper": "^0.10.9",
|
58
|
-
"eslint": "^9.
|
60
|
+
"eslint": "^9.20.1",
|
59
61
|
"jest": "^29.7.0",
|
60
|
-
"prettier": "^3.
|
62
|
+
"prettier": "^3.5.1",
|
61
63
|
"puppeteer": "^24.1.1",
|
62
64
|
"typescript": "^5.7.3"
|
63
65
|
}
|
package/scripts/build-site.js
CHANGED
@@ -1,76 +1,44 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
|
3
|
-
import * as child_process from "node:child_process";
|
4
|
-
import * as path from "node:path";
|
5
3
|
import { Config } from "../lib/config.js";
|
6
|
-
import { PageRenderer } from "../lib/
|
4
|
+
import { PageRenderer } from "../lib/web/renderAllPages.js";
|
7
5
|
import { Files } from "../lib/files.js";
|
8
6
|
import { Program } from "../lib/program.js";
|
9
7
|
import { Taxa } from "../lib/taxonomy/taxa.js";
|
10
8
|
import { ErrorLog } from "../lib/errorlog.js";
|
11
9
|
|
12
|
-
class JekyllRenderer {
|
13
|
-
#srcDir = "./output";
|
14
|
-
#destDir = "./public";
|
15
|
-
|
16
|
-
async renderPages() {
|
17
|
-
/**
|
18
|
-
* @param {string[]} configFiles
|
19
|
-
* @param {string} dir
|
20
|
-
* @param {string} name
|
21
|
-
*/
|
22
|
-
function addConfigFile(configFiles, dir, name) {
|
23
|
-
const fullPath = path.join(dir, name);
|
24
|
-
if (Files.exists(fullPath)) {
|
25
|
-
configFiles.push(fullPath);
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
// Remove existing files.
|
30
|
-
Files.rmDir(this.#destDir);
|
31
|
-
|
32
|
-
const options = [
|
33
|
-
"--source",
|
34
|
-
this.#srcDir,
|
35
|
-
"--destination",
|
36
|
-
this.#destDir,
|
37
|
-
];
|
38
|
-
|
39
|
-
// Find out what config files are available.
|
40
|
-
/** @type {string[]} */
|
41
|
-
const configFiles = [];
|
42
|
-
addConfigFile(configFiles, this.#srcDir, "_config.yml");
|
43
|
-
addConfigFile(configFiles, this.#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(" "),
|
49
|
-
);
|
50
|
-
console.log(result.toString());
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
10
|
/**
|
55
|
-
* @param {
|
11
|
+
* @param {{outputdir:string,datadir:string,webdir:string,showFlowerErrors:boolean,render:boolean}} options
|
56
12
|
*/
|
57
13
|
async function build(options) {
|
58
|
-
|
59
|
-
const
|
14
|
+
console.info("generating templates");
|
15
|
+
const outputDir = options.outputdir;
|
16
|
+
Files.rmDir(outputDir);
|
17
|
+
const errorLog = new ErrorLog(outputDir + "/errors.tsv");
|
60
18
|
const taxa = new Taxa(
|
61
19
|
Program.getIncludeList(options.datadir),
|
62
20
|
errorLog,
|
63
21
|
options.showFlowerErrors,
|
64
22
|
);
|
65
|
-
|
23
|
+
const config = new Config(options.datadir);
|
24
|
+
const generator = PageRenderer.newSiteGenerator(config, outputDir);
|
25
|
+
PageRenderer.renderAll(generator, config, taxa);
|
66
26
|
errorLog.write();
|
67
27
|
|
68
|
-
|
69
|
-
|
70
|
-
|
28
|
+
if (options.render) {
|
29
|
+
console.info("generating site");
|
30
|
+
Files.rmDir(options.webdir);
|
31
|
+
await generator.generate(options.webdir);
|
32
|
+
}
|
71
33
|
}
|
72
34
|
|
73
35
|
const program = Program.getProgram();
|
36
|
+
program.option(
|
37
|
+
"--no-render",
|
38
|
+
"Do not render full HTML output (only build the templates)",
|
39
|
+
);
|
40
|
+
program.option("-w, --webdir", "Directory for fully processed files", "public");
|
41
|
+
|
74
42
|
program.action(build);
|
75
43
|
|
76
44
|
await program.parseAsync();
|