@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.
Files changed (46) hide show
  1. package/data/synonyms.csv +24 -1
  2. package/data/taxa.csv +40 -26
  3. package/data/text/Antirrhinum-thompsonii.md +1 -0
  4. package/data/text/Calyptridium-monospermum.md +1 -0
  5. package/data/text/Calyptridium-ubellatum.md +1 -0
  6. package/data/text/Clarkia-affinis.md +1 -0
  7. package/data/text/Clarkia-breweri.md +1 -0
  8. package/data/text/Clarkia-concinna-subsp-automixa.md +1 -0
  9. package/data/text/Clarkia-modesta.md +1 -0
  10. package/data/text/Clarkia-purpurea-subsp-quadrivulnera.md +1 -0
  11. package/data/text/Clarkia-rubicunda.md +1 -0
  12. package/data/text/Delphinium-californicum-subsp-californicum.md +1 -1
  13. package/data/text/Delphinium-californicum-subsp-interius.md +1 -0
  14. package/data/text/Delphinium-hesperium-subsp-hesperium.md +1 -1
  15. package/data/text/Delphinium-hesperium-subsp-pallescens.md +1 -0
  16. package/data/text/Delphinium-parryi-subsp-parryi.md +1 -0
  17. package/data/text/Erythranthe-moschata.md +1 -0
  18. package/data/text/Erythranthe-primuloides.md +1 -0
  19. package/data/text/Erythranthe-tilingii.md +1 -0
  20. package/data/text/Lilium-pardalinum-subsp-shastense.md +1 -0
  21. package/data/text/Logfia-filaginoides.md +1 -0
  22. package/data/text/Logfia-gallica.md +1 -0
  23. package/data/text/Malacothamnus-arcuatus-var-elmeri.md +1 -0
  24. package/data/text/Malacothamnus-fremontii-var-fremontii.md +1 -0
  25. package/data/text/Trifolium-obtusiflorum.md +1 -0
  26. package/data/text/Trifolium-willdenovii.md +1 -0
  27. package/lib/ebook/images.js +49 -40
  28. package/lib/ebook/pages/page_list_species.js +15 -9
  29. package/lib/ebook/pages/taxonpage.js +2 -5
  30. package/lib/ebook/xhtml.js +3 -5
  31. package/lib/families.js +0 -2
  32. package/lib/genera.js +1 -3
  33. package/lib/genericpage.js +26 -18
  34. package/lib/generictaxaloader.js +1 -1
  35. package/lib/htmltaxon.js +29 -12
  36. package/lib/markdown.js +7 -9
  37. package/lib/pagerenderer.js +127 -82
  38. package/lib/plants/glossary.js +9 -14
  39. package/lib/taxa.js +9 -12
  40. package/lib/taxaloader.js +3 -1
  41. package/lib/taxon.js +2 -4
  42. package/lib/web/glossarypages.js +31 -18
  43. package/package.json +1 -2
  44. package/scripts/build-ebook.js +1 -1
  45. package/scripts/build-site.js +34 -24
  46. package/types/classes.d.ts +26 -0
package/lib/taxa.js CHANGED
@@ -2,14 +2,15 @@ import { Config } from "./config.js";
2
2
  import { HTML } from "./html.js";
3
3
  import { CSV } from "./csv.js";
4
4
  import { RarePlants } from "./rareplants.js";
5
- import { Families, Taxon } from "./index.js";
6
5
  import { Genera } from "./genera.js";
7
6
  import { TextUtils } from "./textutils.js";
7
+ import { Taxon } from "./taxon.js";
8
+ import { Families } from "./families.js";
8
9
 
9
10
  const FLOWER_COLORS = [
10
11
  { name: "white", color: "white" },
11
12
  { name: "red", color: "red" },
12
- { name: "pink", color: "pink" },
13
+ { name: "pink", color: "#ff69b4" },
13
14
  { name: "orange", color: "orange" },
14
15
  { name: "yellow", color: "yellow" },
15
16
  { name: "blue", color: "blue" },
@@ -19,7 +20,7 @@ const FLOWER_COLORS = [
19
20
  ];
20
21
 
21
22
  /**
22
- * @type {Object.<string,import("./index.js").TaxaCol>}
23
+ * @type {Object<string,{title:string,data:function (Taxon):string}>}
23
24
  */
24
25
  const TAXA_LIST_COLS = {
25
26
  CESA: {
@@ -98,14 +99,10 @@ class Taxa {
98
99
  #isSubset;
99
100
 
100
101
  /**
101
- *
102
- * @param {*} inclusionList
102
+ * @param {string[]|boolean} inclusionList
103
103
  * @param {ErrorLog} errorLog
104
- * @param {*} showFlowerErrors
105
- * @param {*} taxaMeta
106
- * @param {*} taxonClass
107
- * @param {*} extraTaxa
108
- * @param {*} extraSynonyms
104
+ * @param {boolean} showFlowerErrors
105
+ * @param {Taxon} taxonClass
109
106
  */
110
107
  constructor(
111
108
  inclusionList,
@@ -162,7 +159,7 @@ class Taxa {
162
159
 
163
160
  /**
164
161
  * @param {Taxon[]} taxa
165
- * @param {import("./index.js").TaxaCol[]} columns
162
+ * @param {TaxaCol} columns
166
163
  */
167
164
  static getHTMLTable(taxa, columns = DEFAULT_COLUMNS) {
168
165
  let html = "<table><thead>";
@@ -259,7 +256,7 @@ class Taxa {
259
256
  }
260
257
 
261
258
  /**
262
- * @param {import("./index.js").TaxonData[]} taxaCSV
259
+ * @param {TaxonData[]} taxaCSV
263
260
  * @param {Taxon} taxonClass
264
261
  * @param {boolean} showFlowerErrors
265
262
  */
package/lib/taxaloader.js CHANGED
@@ -1,5 +1,7 @@
1
+ import { CSV } from "./csv.js";
2
+ import { Files } from "./files.js";
1
3
  import { GenericTaxaLoader } from "./generictaxaloader.js";
2
- import { CSV, Files, Taxa } from "./index.js";
4
+ import { Taxa } from "./taxa.js";
3
5
 
4
6
  class TaxaLoader extends GenericTaxaLoader {
5
7
  /**
package/lib/taxon.js CHANGED
@@ -1,7 +1,5 @@
1
- import { HTML } from "./index.js";
1
+ import { HTML } from "./html.js";
2
2
  import { RarePlants } from "./rareplants.js";
3
- // eslint-disable-next-line no-unused-vars
4
- import { Genera } from "./genera.js";
5
3
 
6
4
  const TAXA_COLNAMES = {
7
5
  BLOOM_START: "bloom_start",
@@ -38,7 +36,7 @@ class Taxon {
38
36
  #synonyms = [];
39
37
 
40
38
  /**
41
- * @param {import("./index.js").TaxonData} data
39
+ * @param {TaxonData} data
42
40
  * @param {Genera} genera
43
41
  */
44
42
  constructor(data, genera) {
@@ -1,46 +1,60 @@
1
- import { Files, HTML } from "@ca-plant-list/ca-plant-list";
2
1
  import { Glossary } from "../plants/glossary.js";
3
2
  import { Markdown } from "../markdown.js";
3
+ import { HTML } from "../html.js";
4
+ import { Files } from "../files.js";
4
5
 
5
6
  const ENTRY_DIR = "g";
6
7
 
7
8
  class GlossaryPages {
8
-
9
9
  #siteGenerator;
10
10
  #glossary;
11
11
 
12
- constructor( siteGenerator ) {
12
+ constructor(siteGenerator) {
13
13
  this.#siteGenerator = siteGenerator;
14
14
  this.#glossary = new Glossary();
15
15
  }
16
16
 
17
- #generateEntryPage( entry ) {
17
+ #generateEntryPage(entry) {
18
18
  const title = entry.getTermName();
19
- let html = HTML.textElement( "h1", title );
20
- html += HTML.wrap( "div", Markdown.strToHTML( entry.getMarkdown() ), { class: "glossary" } );
21
- this.#siteGenerator.writeTemplate( html, { title: title }, Files.join( ENTRY_DIR, title + ".html" ) );
19
+ let html = HTML.textElement("h1", title);
20
+ html += HTML.wrap("div", Markdown.strToHTML(entry.getMarkdown()), {
21
+ class: "glossary",
22
+ });
23
+ this.#siteGenerator.writeTemplate(
24
+ html,
25
+ { title: title },
26
+ Files.join(ENTRY_DIR, title + ".html")
27
+ );
22
28
  }
23
29
 
24
30
  #generateEntryPages() {
25
-
26
31
  // Make sure output directory exists.
27
- this.#siteGenerator.mkdir( ENTRY_DIR );
32
+ this.#siteGenerator.mkdir(ENTRY_DIR);
28
33
 
29
34
  const entries = this.#glossary.getEntries();
30
- for ( const entry of entries ) {
31
- this.#generateEntryPage( entry );
35
+ for (const entry of entries) {
36
+ this.#generateEntryPage(entry);
32
37
  }
33
38
  }
34
39
 
35
40
  #generateIndexPage() {
36
41
  const links = [];
37
42
  const entries = this.#glossary.getEntries();
38
- for ( const entry of entries ) {
39
- links.push( HTML.getLink( Files.join( ENTRY_DIR, entry.getHTMLFileName() ), entry.getTermName() ) );
43
+ for (const entry of entries) {
44
+ links.push(
45
+ HTML.getLink(
46
+ Files.join(ENTRY_DIR, entry.getHTMLFileName()),
47
+ entry.getTermName()
48
+ )
49
+ );
40
50
  }
41
- let html = HTML.wrap( "h1", "Glossary" );
42
- html += HTML.wrap( "ol", HTML.arrayToLI( links ) );
43
- this.#siteGenerator.writeTemplate( html, { title: "Glossary" }, "glossary.html" );
51
+ let html = HTML.wrap("h1", "Glossary");
52
+ html += HTML.wrap("ol", HTML.arrayToLI(links));
53
+ this.#siteGenerator.writeTemplate(
54
+ html,
55
+ { title: "Glossary" },
56
+ "glossary.html"
57
+ );
44
58
  }
45
59
 
46
60
  getGlossary() {
@@ -51,7 +65,6 @@ class GlossaryPages {
51
65
  this.#generateIndexPage();
52
66
  this.#generateEntryPages();
53
67
  }
54
-
55
68
  }
56
69
 
57
- export { GlossaryPages };
70
+ export { GlossaryPages };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ca-plant-list/ca-plant-list",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Tools to create Jekyll files for a website listing plants in an area of California.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,7 +12,6 @@
12
12
  "exports": {
13
13
  ".": "./lib/index.js"
14
14
  },
15
- "types": "./lib/index.d.ts",
16
15
  "bin": {
17
16
  "ca-plant-list": "scripts/build-site.js",
18
17
  "ca-plant-book": "scripts/build-ebook.js"
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { PlantBook } from "@ca-plant-list/ca-plant-list";
4
3
  import { Config } from "../lib/config.js";
5
4
  import { Files } from "../lib/files.js";
5
+ import { PlantBook } from "../lib/ebook/plantbook.js";
6
6
  import { TaxaProcessor } from "../lib/taxaprocessor.js";
7
7
  import { CommandProcessor } from "../lib/commandprocessor.js";
8
8
 
@@ -2,54 +2,64 @@
2
2
 
3
3
  import * as child_process from "node:child_process";
4
4
  import * as path from "node:path";
5
- import { Files } from "@ca-plant-list/ca-plant-list";
6
5
  import { Config } from "../lib/config.js";
7
6
  import { PageRenderer } from "../lib/pagerenderer.js";
8
7
  import { CommandAndTaxaProcessor } from "../lib/commandandtaxaprocessor.js";
8
+ import { Files } from "../lib/files.js";
9
9
 
10
10
  class JekyllRenderer {
11
-
12
11
  #srcDir = "./output";
13
12
  #destDir = "./public";
14
13
 
15
14
  async renderPages() {
16
-
17
- function addConfigFile( configFiles, dir, name ) {
18
- const fullPath = path.join( dir, name );
19
- if ( Files.exists( fullPath ) ) {
20
- configFiles.push( fullPath );
15
+ function addConfigFile(configFiles, dir, name) {
16
+ const fullPath = path.join(dir, name);
17
+ if (Files.exists(fullPath)) {
18
+ configFiles.push(fullPath);
21
19
  }
22
20
  }
23
21
 
24
22
  // Remove existing files.
25
- Files.rmDir( this.#destDir );
23
+ Files.rmDir(this.#destDir);
26
24
 
27
- const options = [ "--source", this.#srcDir, "--destination", this.#destDir ];
25
+ const options = [
26
+ "--source",
27
+ this.#srcDir,
28
+ "--destination",
29
+ this.#destDir,
30
+ ];
28
31
 
29
32
  // Find out what config files are available.
30
33
  const configFiles = [];
31
- addConfigFile( configFiles, this.#srcDir, "_config.yml" );
32
- addConfigFile( configFiles, this.#srcDir, "_config-local.yml" );
33
- addConfigFile( configFiles, ".", "_config-dev.yml" );
34
- options.push( "--config", "\"" + configFiles.join() + "\"" );
35
-
36
- const result = child_process.execSync( "bundle exec jekyll build " + options.join( " " ) );
37
- console.log( result.toString() );
34
+ addConfigFile(configFiles, this.#srcDir, "_config.yml");
35
+ addConfigFile(configFiles, this.#srcDir, "_config-local.yml");
36
+ addConfigFile(configFiles, ".", "_config-dev.yml");
37
+ options.push("--config", '"' + configFiles.join() + '"');
38
+
39
+ const result = child_process.execSync(
40
+ "bundle exec jekyll build " + options.join(" ")
41
+ );
42
+ console.log(result.toString());
38
43
  }
39
-
40
44
  }
41
45
 
42
- async function generateSite( taxaProcessor ) {
43
-
46
+ async function generateSite(taxaProcessor) {
44
47
  const options = taxaProcessor.getOptions();
45
48
 
46
- PageRenderer.render( options.outputdir, new Config( options.datadir ), taxaProcessor.getTaxa() );
49
+ PageRenderer.render(
50
+ options.outputdir,
51
+ new Config(options.datadir),
52
+ taxaProcessor.getTaxa()
53
+ );
47
54
 
48
- console.log( "generating site" );
55
+ console.log("generating site");
49
56
  const r = new JekyllRenderer();
50
57
  await r.renderPages();
51
-
52
58
  }
53
59
 
54
- const gen = new CommandAndTaxaProcessor( "ca-plant-list", "A tool to generate a website with local plant data.", generateSite );
55
- await gen.process( generateSite );
60
+ const gen = new CommandAndTaxaProcessor(
61
+ "ca-plant-list",
62
+ "A tool to generate a website with local plant data.",
63
+ generateSite
64
+ );
65
+ await gen.process(generateSite);
@@ -0,0 +1,26 @@
1
+ declare class ErrorLog {
2
+ log(...args: string[]): void;
3
+ }
4
+
5
+ declare class Families {}
6
+
7
+ declare class Genera {}
8
+
9
+ declare class Taxon {
10
+ constructor(data: TaxonData, genera: Genera, meta: any);
11
+ getBloomEnd(): number;
12
+ getBloomStart(): number;
13
+ getCESA(): string;
14
+ getCommonNames(): string[];
15
+ getFESA(): string;
16
+ getFileName(): string;
17
+ getFlowerColors(): string[];
18
+ getHTMLLink(
19
+ href: boolean | string | undefined,
20
+ includeRPI: boolean
21
+ ): string;
22
+ getLifeCycle(): string;
23
+ getName(): string;
24
+ getRPIRankAndThreat(): string;
25
+ getRPIRankAndThreatTooltip(): string;
26
+ }