@ca-plant-list/ca-plant-list 0.3.6 → 0.3.7
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/synonyms.csv +24 -1
- package/data/taxa.csv +40 -26
- package/data/text/Antirrhinum-thompsonii.md +1 -0
- package/data/text/Calyptridium-monospermum.md +1 -0
- package/data/text/Calyptridium-ubellatum.md +1 -0
- package/data/text/Clarkia-affinis.md +1 -0
- package/data/text/Clarkia-breweri.md +1 -0
- package/data/text/Clarkia-concinna-subsp-automixa.md +1 -0
- package/data/text/Clarkia-modesta.md +1 -0
- package/data/text/Clarkia-purpurea-subsp-quadrivulnera.md +1 -0
- package/data/text/Clarkia-rubicunda.md +1 -0
- package/data/text/Delphinium-californicum-subsp-californicum.md +1 -1
- package/data/text/Delphinium-californicum-subsp-interius.md +1 -0
- package/data/text/Delphinium-hesperium-subsp-hesperium.md +1 -1
- package/data/text/Delphinium-hesperium-subsp-pallescens.md +1 -0
- package/data/text/Delphinium-parryi-subsp-parryi.md +1 -0
- package/data/text/Erythranthe-moschata.md +1 -0
- package/data/text/Erythranthe-primuloides.md +1 -0
- package/data/text/Erythranthe-tilingii.md +1 -0
- package/data/text/Lilium-pardalinum-subsp-shastense.md +1 -0
- package/data/text/Logfia-filaginoides.md +1 -0
- package/data/text/Logfia-gallica.md +1 -0
- package/data/text/Malacothamnus-arcuatus-var-elmeri.md +1 -0
- package/data/text/Malacothamnus-fremontii-var-fremontii.md +1 -0
- package/data/text/Trifolium-obtusiflorum.md +1 -0
- package/data/text/Trifolium-willdenovii.md +1 -0
- package/lib/ebook/images.js +49 -40
- package/lib/ebook/pages/page_list_species.js +15 -9
- package/lib/ebook/pages/taxonpage.js +2 -5
- package/lib/ebook/xhtml.js +3 -5
- package/lib/families.js +0 -2
- package/lib/genera.js +1 -3
- package/lib/genericpage.js +26 -18
- package/lib/generictaxaloader.js +1 -1
- package/lib/htmltaxon.js +29 -12
- package/lib/markdown.js +7 -9
- package/lib/pagerenderer.js +127 -82
- package/lib/plants/glossary.js +9 -14
- package/lib/taxa.js +9 -12
- package/lib/taxaloader.js +3 -1
- package/lib/taxon.js +2 -4
- package/lib/web/glossarypages.js +31 -18
- package/package.json +1 -2
- package/scripts/build-ebook.js +1 -1
- package/scripts/build-site.js +34 -24
- package/types/classes.d.ts +26 -0
@@ -1,13 +1,10 @@
|
|
1
1
|
import imageSize from "image-size";
|
2
|
-
import { Config, Files } from "@ca-plant-list/ca-plant-list";
|
3
2
|
import { EBookPage } from "../ebookpage.js";
|
4
3
|
import { XHTML } from "../xhtml.js";
|
5
4
|
import { Markdown } from "../../markdown.js";
|
6
|
-
// eslint-disable-next-line no-unused-vars
|
7
|
-
import { Taxon } from "../../taxon.js";
|
8
|
-
// eslint-disable-next-line no-unused-vars
|
9
|
-
import { Image } from "../image.js";
|
10
5
|
import { HTMLTaxon } from "../../htmltaxon.js";
|
6
|
+
import { Config } from "../../config.js";
|
7
|
+
import { Files } from "../../files.js";
|
11
8
|
|
12
9
|
class TaxonPage extends EBookPage {
|
13
10
|
#outputDir;
|
package/lib/ebook/xhtml.js
CHANGED
package/lib/families.js
CHANGED
package/lib/genera.js
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
import { Config } from "./config.js";
|
2
|
-
import { Families } from "./families.js";
|
3
2
|
import { Files } from "./files.js";
|
4
|
-
// eslint-disable-next-line no-unused-vars
|
5
|
-
import { Taxon } from "./taxon.js";
|
6
3
|
|
7
4
|
class Genera {
|
8
5
|
#families;
|
9
6
|
#genera;
|
10
7
|
|
11
8
|
/**
|
9
|
+
*
|
12
10
|
* @param {Families} families
|
13
11
|
*/
|
14
12
|
constructor(families) {
|
package/lib/genericpage.js
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
-
import { Config
|
1
|
+
import { Config } from "./config.js";
|
2
|
+
import { Files } from "./files.js";
|
3
|
+
import { HTML } from "./html.js";
|
4
|
+
import { Jekyll } from "./jekyll.js";
|
2
5
|
import { Markdown } from "./markdown.js";
|
3
6
|
|
4
7
|
class GenericPage {
|
5
|
-
|
6
8
|
#outputDir;
|
7
9
|
#title;
|
8
10
|
#baseFileName;
|
9
11
|
#js;
|
10
12
|
|
11
|
-
constructor(
|
13
|
+
constructor(outputDir, title, baseFileName, js) {
|
12
14
|
this.#outputDir = outputDir;
|
13
15
|
this.#title = title;
|
14
16
|
this.#baseFileName = baseFileName;
|
@@ -25,31 +27,38 @@ class GenericPage {
|
|
25
27
|
}
|
26
28
|
|
27
29
|
getFrontMatter() {
|
28
|
-
return
|
29
|
-
|
30
|
-
|
31
|
-
+
|
30
|
+
return (
|
31
|
+
"---\n" +
|
32
|
+
'title: "' +
|
33
|
+
this.#title +
|
34
|
+
'"\n' +
|
35
|
+
(this.#js ? "js: " + this.#js + "\n" : "") +
|
36
|
+
"---\n"
|
37
|
+
);
|
32
38
|
}
|
33
39
|
|
34
40
|
getMarkdown() {
|
35
41
|
// Include site-specific markdown.
|
36
|
-
let html = this.#getMarkdown(
|
42
|
+
let html = this.#getMarkdown("intros");
|
37
43
|
|
38
44
|
// Include package markdown.
|
39
|
-
const mdPath =
|
40
|
-
|
41
|
-
|
45
|
+
const mdPath =
|
46
|
+
Config.getPackageDir() + "/data/text/" + this.#baseFileName + ".md";
|
47
|
+
if (Files.exists(mdPath)) {
|
48
|
+
html += HTML.wrap("div", Markdown.fileToHTML(mdPath), {
|
49
|
+
class: "section",
|
50
|
+
});
|
42
51
|
}
|
43
52
|
|
44
53
|
return html;
|
45
54
|
}
|
46
55
|
|
47
|
-
#getMarkdown(
|
56
|
+
#getMarkdown(path) {
|
48
57
|
const textPath = path + "/" + this.#baseFileName + ".md";
|
49
|
-
if (
|
58
|
+
if (!Jekyll.hasInclude(this.#outputDir, textPath)) {
|
50
59
|
return "";
|
51
60
|
}
|
52
|
-
return HTML.wrap(
|
61
|
+
return HTML.wrap("div", Jekyll.include(textPath), { class: "section" });
|
53
62
|
}
|
54
63
|
|
55
64
|
getOutputDir() {
|
@@ -60,10 +69,9 @@ class GenericPage {
|
|
60
69
|
return this.#title;
|
61
70
|
}
|
62
71
|
|
63
|
-
writeFile(
|
64
|
-
Files.write(
|
72
|
+
writeFile(html) {
|
73
|
+
Files.write(this.#outputDir + "/" + this.#baseFileName + ".html", html);
|
65
74
|
}
|
66
|
-
|
67
75
|
}
|
68
76
|
|
69
|
-
export { GenericPage };
|
77
|
+
export { GenericPage };
|
package/lib/generictaxaloader.js
CHANGED
package/lib/htmltaxon.js
CHANGED
@@ -1,10 +1,26 @@
|
|
1
1
|
import { DateUtils } from "./dateutils.js";
|
2
2
|
import { HTML } from "./html.js";
|
3
|
-
// eslint-disable-next-line no-unused-vars
|
4
|
-
import { Taxon } from "./taxon.js";
|
5
3
|
import { TextUtils } from "./textutils.js";
|
6
4
|
|
7
5
|
class HTMLTaxon {
|
6
|
+
/**
|
7
|
+
* @param {string[]} colors
|
8
|
+
*/
|
9
|
+
static getFlowerColors(colors) {
|
10
|
+
let html = "";
|
11
|
+
if (colors) {
|
12
|
+
for (const color of colors) {
|
13
|
+
html += HTML.textElement("img", "", {
|
14
|
+
src: "./i/f-" + color + ".svg",
|
15
|
+
alt: color + " flowers",
|
16
|
+
title: color,
|
17
|
+
class: "flr-color",
|
18
|
+
});
|
19
|
+
}
|
20
|
+
}
|
21
|
+
return html;
|
22
|
+
}
|
23
|
+
|
8
24
|
/**
|
9
25
|
* @param {Taxon} taxon
|
10
26
|
* @param {string} classNames
|
@@ -24,16 +40,7 @@ class HTMLTaxon {
|
|
24
40
|
|
25
41
|
if (colors || monthStart) {
|
26
42
|
let html = "Flowers: ";
|
27
|
-
|
28
|
-
for (const color of colors) {
|
29
|
-
html += HTML.textElement("img", "", {
|
30
|
-
src: "./i/f-" + color + ".svg",
|
31
|
-
alt: color + " flowers",
|
32
|
-
title: color,
|
33
|
-
class: "flr-color",
|
34
|
-
});
|
35
|
-
}
|
36
|
-
}
|
43
|
+
html += this.getFlowerColors(colors);
|
37
44
|
if (monthStart && monthEnd) {
|
38
45
|
html += HTML.wrap(
|
39
46
|
"span",
|
@@ -47,6 +54,16 @@ class HTMLTaxon {
|
|
47
54
|
}
|
48
55
|
return HTML.wrap("div", parts.join(""), { class: classNames });
|
49
56
|
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* @param {Taxon} taxon
|
60
|
+
*/
|
61
|
+
static getLink(taxon) {
|
62
|
+
return (
|
63
|
+
HTML.getLink(taxon.getFileName(), taxon.getName()) +
|
64
|
+
this.getFlowerColors(taxon.getFlowerColors())
|
65
|
+
);
|
66
|
+
}
|
50
67
|
}
|
51
68
|
|
52
69
|
export { HTMLTaxon };
|
package/lib/markdown.js
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
import markdownIt from "markdown-it";
|
2
|
-
import { Files } from "
|
2
|
+
import { Files } from "./files.js";
|
3
3
|
|
4
4
|
class Markdown {
|
5
|
+
static #md = new markdownIt({ xhtmlOut: true });
|
5
6
|
|
6
|
-
static
|
7
|
-
|
8
|
-
static fileToHTML( filePath ) {
|
9
|
-
return this.strToHTML( Files.read( filePath ) );
|
7
|
+
static fileToHTML(filePath) {
|
8
|
+
return this.strToHTML(Files.read(filePath));
|
10
9
|
}
|
11
10
|
|
12
|
-
static strToHTML(
|
13
|
-
return this.#md.render(
|
11
|
+
static strToHTML(str) {
|
12
|
+
return this.#md.render(str);
|
14
13
|
}
|
15
|
-
|
16
14
|
}
|
17
15
|
|
18
|
-
export { Markdown };
|
16
|
+
export { Markdown };
|
package/lib/pagerenderer.js
CHANGED
@@ -1,71 +1,93 @@
|
|
1
|
-
import {
|
2
|
-
import { TAXA_LIST_COLS } from "./taxa.js";
|
1
|
+
import { Taxa, TAXA_LIST_COLS } from "./taxa.js";
|
3
2
|
import { PageTaxon } from "./web/pagetaxon.js";
|
4
3
|
import { RarePlants } from "./rareplants.js";
|
5
4
|
import { BasePageRenderer } from "./basepagerenderer.js";
|
6
5
|
import { GenericPage } from "./genericpage.js";
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
import { Files } from "./files.js";
|
7
|
+
import { HTML } from "./html.js";
|
8
|
+
|
9
|
+
const ENDANGERED_COLS = [
|
10
|
+
TAXA_LIST_COLS.SPECIES,
|
11
|
+
TAXA_LIST_COLS.COMMON_NAME,
|
12
|
+
TAXA_LIST_COLS.CESA,
|
13
|
+
TAXA_LIST_COLS.FESA,
|
14
|
+
];
|
15
|
+
const RPI_COLUMNS = [
|
16
|
+
TAXA_LIST_COLS.SPECIES_BARE,
|
17
|
+
TAXA_LIST_COLS.COMMON_NAME,
|
18
|
+
TAXA_LIST_COLS.CNPS_RANK,
|
19
|
+
];
|
10
20
|
|
11
21
|
class PageRenderer extends BasePageRenderer {
|
22
|
+
static render(outputDir, config, taxa) {
|
23
|
+
super.render(outputDir, taxa);
|
12
24
|
|
13
|
-
|
14
|
-
|
15
|
-
super.render( outputDir, taxa );
|
16
|
-
|
17
|
-
this.renderLists( outputDir, config, taxa );
|
25
|
+
this.renderLists(outputDir, config, taxa);
|
18
26
|
|
19
27
|
const taxonList = taxa.getTaxonList();
|
20
|
-
for (
|
21
|
-
new PageTaxon(
|
28
|
+
for (const taxon of taxonList) {
|
29
|
+
new PageTaxon(outputDir, config, taxon).render();
|
22
30
|
}
|
23
|
-
|
24
31
|
}
|
25
32
|
|
26
|
-
static renderLists(
|
27
|
-
|
28
|
-
function getListArray( listInfo, attributes = {}, columns ) {
|
29
|
-
|
33
|
+
static renderLists(outputDir, config, taxa) {
|
34
|
+
function getListArray(listInfo, attributes = {}, columns) {
|
30
35
|
const listArray = [];
|
31
|
-
for (
|
36
|
+
for (const list of listInfo) {
|
32
37
|
const listTaxa = [];
|
33
38
|
const calfloraTaxa = [];
|
34
39
|
const iNatTaxa = [];
|
35
|
-
for (
|
36
|
-
if (
|
37
|
-
listTaxa.push(
|
38
|
-
calfloraTaxa.push(
|
39
|
-
iNatTaxa.push(
|
40
|
+
for (const taxon of taxa.getTaxonList()) {
|
41
|
+
if (list.include(taxon)) {
|
42
|
+
listTaxa.push(taxon);
|
43
|
+
calfloraTaxa.push(taxon.getCalfloraName());
|
44
|
+
iNatTaxa.push(taxon.getINatName());
|
40
45
|
}
|
41
46
|
}
|
42
47
|
|
43
|
-
if (
|
48
|
+
if (listTaxa.length === 0) {
|
44
49
|
continue;
|
45
50
|
}
|
46
51
|
|
47
|
-
Files.write(
|
48
|
-
|
52
|
+
Files.write(
|
53
|
+
outputDir + "/calflora_" + list.filename + ".txt",
|
54
|
+
calfloraTaxa.join("\n")
|
55
|
+
);
|
56
|
+
Files.write(
|
57
|
+
outputDir + "/inat_" + list.filename + ".txt",
|
58
|
+
iNatTaxa.join("\n")
|
59
|
+
);
|
49
60
|
|
50
61
|
const cols = columns ? columns : list.columns;
|
51
|
-
new PageTaxonList(
|
62
|
+
new PageTaxonList(outputDir, list.name, list.filename).render(
|
63
|
+
listTaxa,
|
64
|
+
cols
|
65
|
+
);
|
52
66
|
|
53
67
|
// Check for sublists.
|
54
|
-
const subListHTML = list.listInfo
|
55
|
-
|
56
|
-
|
68
|
+
const subListHTML = list.listInfo
|
69
|
+
? getListArray(list.listInfo, { class: "indent" }, cols)
|
70
|
+
: "";
|
71
|
+
|
72
|
+
listArray.push(
|
73
|
+
HTML.getLink("./" + list.filename + ".html", list.name) +
|
74
|
+
" (" +
|
75
|
+
listTaxa.length +
|
76
|
+
")" +
|
77
|
+
subListHTML
|
78
|
+
);
|
57
79
|
}
|
58
80
|
|
59
|
-
return renderList(
|
81
|
+
return renderList(listArray, attributes);
|
60
82
|
}
|
61
83
|
|
62
|
-
function renderList(
|
63
|
-
return HTML.wrap(
|
84
|
+
function renderList(listsHTML, attributes = {}) {
|
85
|
+
return HTML.wrap("ul", HTML.arrayToLI(listsHTML), attributes);
|
64
86
|
}
|
65
87
|
|
66
|
-
function renderSection(
|
67
|
-
let html =
|
68
|
-
html += HTML.textElement(
|
88
|
+
function renderSection(title, listsHTML) {
|
89
|
+
let html = '<div class="section">';
|
90
|
+
html += HTML.textElement("h2", title);
|
69
91
|
html += listsHTML;
|
70
92
|
html += "</div>";
|
71
93
|
return html;
|
@@ -75,10 +97,22 @@ class PageRenderer extends BasePageRenderer {
|
|
75
97
|
{
|
76
98
|
title: "All Species",
|
77
99
|
listInfo: [
|
78
|
-
{
|
79
|
-
|
80
|
-
|
81
|
-
|
100
|
+
{
|
101
|
+
name: config.getLabel("native", "Native"),
|
102
|
+
filename: "list_native",
|
103
|
+
include: (t) => t.isNative(),
|
104
|
+
},
|
105
|
+
{
|
106
|
+
name: config.getLabel("introduced", "Introduced"),
|
107
|
+
filename: "list_introduced",
|
108
|
+
include: (t) => !t.isNative(),
|
109
|
+
},
|
110
|
+
{
|
111
|
+
name: "All Plants",
|
112
|
+
filename: "list_all",
|
113
|
+
include: () => true,
|
114
|
+
},
|
115
|
+
],
|
82
116
|
},
|
83
117
|
{
|
84
118
|
title: "Rare Plants",
|
@@ -86,101 +120,112 @@ class PageRenderer extends BasePageRenderer {
|
|
86
120
|
{
|
87
121
|
name: "CNPS Ranked Plants",
|
88
122
|
filename: "list_rpi",
|
89
|
-
include: (
|
123
|
+
include: (t) => t.getRPIRank() !== undefined,
|
90
124
|
columns: RPI_COLUMNS,
|
91
125
|
listInfo: [
|
92
126
|
{
|
93
|
-
name: RarePlants.getRPIRankDescription(
|
127
|
+
name: RarePlants.getRPIRankDescription("1A"),
|
94
128
|
filename: "list_rpi_1a",
|
95
|
-
include: (
|
129
|
+
include: (t) => t.getRPIRank() === "1A",
|
96
130
|
},
|
97
131
|
{
|
98
|
-
name: RarePlants.getRPIRankDescription(
|
132
|
+
name: RarePlants.getRPIRankDescription("1B"),
|
99
133
|
filename: "list_rpi_1b",
|
100
|
-
include: (
|
134
|
+
include: (t) => t.getRPIRank() === "1B",
|
101
135
|
},
|
102
136
|
{
|
103
|
-
name: RarePlants.getRPIRankDescription(
|
137
|
+
name: RarePlants.getRPIRankDescription("2A"),
|
104
138
|
filename: "list_rpi_2a",
|
105
|
-
include: (
|
139
|
+
include: (t) => t.getRPIRank() === "2A",
|
106
140
|
},
|
107
141
|
{
|
108
|
-
name: RarePlants.getRPIRankDescription(
|
142
|
+
name: RarePlants.getRPIRankDescription("2B"),
|
109
143
|
filename: "list_rpi_2b",
|
110
|
-
include: (
|
144
|
+
include: (t) => t.getRPIRank() === "2B",
|
111
145
|
},
|
112
146
|
{
|
113
|
-
name: RarePlants.getRPIRankDescription(
|
147
|
+
name: RarePlants.getRPIRankDescription("3"),
|
114
148
|
filename: "list_rpi_3",
|
115
|
-
include: (
|
149
|
+
include: (t) => t.getRPIRank() === "3",
|
116
150
|
},
|
117
151
|
{
|
118
|
-
name: RarePlants.getRPIRankDescription(
|
152
|
+
name: RarePlants.getRPIRankDescription("4"),
|
119
153
|
filename: "list_rpi_4",
|
120
|
-
include: (
|
154
|
+
include: (t) => t.getRPIRank() === "4",
|
121
155
|
},
|
122
|
-
]
|
156
|
+
],
|
123
157
|
},
|
124
158
|
{
|
125
159
|
name: "Endangered Species",
|
126
160
|
filename: "list_endangered",
|
127
|
-
include: (
|
161
|
+
include: (t) => t.getCESA() || t.getFESA(),
|
128
162
|
columns: ENDANGERED_COLS,
|
129
163
|
},
|
130
|
-
]
|
164
|
+
],
|
131
165
|
},
|
132
166
|
];
|
133
167
|
|
134
|
-
let html =
|
135
|
-
for (
|
168
|
+
let html = '<div class="wrapper">';
|
169
|
+
for (const section of sections) {
|
170
|
+
const listHTML = getListArray(
|
171
|
+
section.listInfo,
|
172
|
+
section.listInfo.columns
|
173
|
+
);
|
136
174
|
|
137
|
-
|
138
|
-
|
139
|
-
if ( listHTML.length > 0 ) {
|
140
|
-
html += renderSection( section.title, listHTML );
|
175
|
+
if (listHTML.length > 0) {
|
176
|
+
html += renderSection(section.title, listHTML);
|
141
177
|
}
|
142
|
-
|
143
178
|
}
|
144
|
-
html += renderSection(
|
179
|
+
html += renderSection(
|
180
|
+
"Taxonomy",
|
181
|
+
renderList([HTML.getLink("./list_families.html", "Plant Families")])
|
182
|
+
);
|
145
183
|
|
146
184
|
html += "</div>";
|
147
185
|
|
148
186
|
// Write lists to includes directory so it can be inserted into pages.
|
149
|
-
Files.write(
|
150
|
-
|
187
|
+
Files.write(outputDir + "/_includes/plantlists.html", html);
|
151
188
|
}
|
152
|
-
|
153
189
|
}
|
154
190
|
|
155
191
|
class PageTaxonList extends GenericPage {
|
156
|
-
|
157
|
-
|
158
|
-
super( outputDir, title, baseName );
|
192
|
+
constructor(outputDir, title, baseName) {
|
193
|
+
super(outputDir, title, baseName);
|
159
194
|
}
|
160
195
|
|
161
|
-
render(
|
162
|
-
|
196
|
+
render(taxa, columns) {
|
163
197
|
let html = this.getDefaultIntro();
|
164
198
|
|
165
|
-
html +=
|
199
|
+
html += '<div class="wrapper">';
|
166
200
|
|
167
|
-
html +=
|
168
|
-
html += Taxa.getHTMLTable(
|
201
|
+
html += '<div class="section">';
|
202
|
+
html += Taxa.getHTMLTable(taxa, columns);
|
169
203
|
html += "</div>";
|
170
204
|
|
171
|
-
html +=
|
172
|
-
html += HTML.textElement(
|
205
|
+
html += '<div class="section">';
|
206
|
+
html += HTML.textElement("h2", "Download");
|
173
207
|
html += "<ul>";
|
174
|
-
html +=
|
175
|
-
|
208
|
+
html +=
|
209
|
+
"<li>" +
|
210
|
+
HTML.getLink(
|
211
|
+
"./calflora_" + this.getBaseFileName() + ".txt",
|
212
|
+
"Calflora List"
|
213
|
+
) +
|
214
|
+
"</li>";
|
215
|
+
html +=
|
216
|
+
"<li>" +
|
217
|
+
HTML.getLink(
|
218
|
+
"./inat_" + this.getBaseFileName() + ".txt",
|
219
|
+
"iNaturalist List"
|
220
|
+
) +
|
221
|
+
"</li>";
|
176
222
|
html += "</ul>";
|
177
223
|
html += "</div>";
|
178
224
|
|
179
225
|
html += "</div>";
|
180
226
|
|
181
|
-
this.writeFile(
|
182
|
-
|
227
|
+
this.writeFile(html);
|
183
228
|
}
|
184
229
|
}
|
185
230
|
|
186
|
-
export { PageRenderer };
|
231
|
+
export { PageRenderer };
|
package/lib/plants/glossary.js
CHANGED
@@ -1,38 +1,34 @@
|
|
1
|
-
import { Config
|
1
|
+
import { Config } from "../config.js";
|
2
|
+
import { Files } from "../files.js";
|
2
3
|
|
3
4
|
class Glossary {
|
4
|
-
|
5
5
|
#srcPath;
|
6
6
|
#srcEntries = [];
|
7
7
|
|
8
8
|
constructor() {
|
9
|
-
|
10
9
|
this.#srcPath = Config.getPackageDir() + "/data/glossary";
|
11
10
|
|
12
11
|
// Find all entries in the glossary directory.
|
13
|
-
const entries = Files.getDirEntries(
|
14
|
-
for (
|
15
|
-
this.#srcEntries.push(
|
12
|
+
const entries = Files.getDirEntries(this.#srcPath).sort();
|
13
|
+
for (const entry of entries) {
|
14
|
+
this.#srcEntries.push(new GlossaryEntry(this.#srcPath, entry));
|
16
15
|
}
|
17
|
-
|
18
16
|
}
|
19
17
|
|
20
18
|
getEntries() {
|
21
19
|
return this.#srcEntries;
|
22
20
|
}
|
23
|
-
|
24
21
|
}
|
25
22
|
|
26
23
|
class GlossaryEntry {
|
27
|
-
|
28
24
|
#srcPath;
|
29
25
|
#fileName;
|
30
26
|
#term;
|
31
27
|
|
32
|
-
constructor(
|
28
|
+
constructor(srcPath, fileName) {
|
33
29
|
this.#srcPath = srcPath;
|
34
30
|
this.#fileName = fileName;
|
35
|
-
this.#term = fileName.split(
|
31
|
+
this.#term = fileName.split(".")[0];
|
36
32
|
}
|
37
33
|
|
38
34
|
getHTMLFileName() {
|
@@ -40,13 +36,12 @@ class GlossaryEntry {
|
|
40
36
|
}
|
41
37
|
|
42
38
|
getMarkdown() {
|
43
|
-
return Files.read(
|
39
|
+
return Files.read(this.#srcPath + "/" + this.#fileName);
|
44
40
|
}
|
45
41
|
|
46
42
|
getTermName() {
|
47
43
|
return this.#term;
|
48
44
|
}
|
49
|
-
|
50
45
|
}
|
51
46
|
|
52
|
-
export { Glossary };
|
47
|
+
export { Glossary };
|