@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.
Files changed (53) hide show
  1. package/data/taxa.csv +7 -6
  2. package/data/text/Erodium-botrys.footer.md +3 -0
  3. package/data/text/Erodium-botrys.md +1 -0
  4. package/data/text/Erodium-brachycarpum.footer.md +3 -0
  5. package/data/text/Erodium-brachycarpum.md +1 -0
  6. package/data/text/Erodium-cicutarium.md +1 -0
  7. package/data/text/Erodium-moschatum.footer.md +3 -0
  8. package/data/text/Erodium-moschatum.md +1 -0
  9. package/generators/eleventy/layouts/h1.njk +6 -0
  10. package/generators/eleventy/layouts/html.njk +55 -0
  11. package/lib/basepagerenderer.js +36 -18
  12. package/lib/config.js +5 -3
  13. package/lib/ebook/ebookpage.js +1 -4
  14. package/lib/ebook/ebooksitegenerator.js +4 -12
  15. package/lib/ebook/glossarypages.js +1 -3
  16. package/lib/ebook/plantbook.js +1 -1
  17. package/lib/files.js +1 -0
  18. package/lib/htmltaxon.js +8 -19
  19. package/lib/index.d.ts +32 -9
  20. package/lib/index.js +4 -2
  21. package/lib/jekyll.js +40 -59
  22. package/lib/markdown.js +3 -5
  23. package/lib/sitegenerator.js +68 -12
  24. package/lib/taxonomy/taxa.js +4 -4
  25. package/lib/types.js +4 -0
  26. package/lib/utils/eleventyGenerator.js +82 -0
  27. package/lib/utils/htmlFragments.js +19 -0
  28. package/lib/web/glossarypages.js +6 -10
  29. package/lib/web/pageFamily.js +14 -14
  30. package/lib/web/pageGeneric.js +78 -0
  31. package/lib/web/{pagetaxon.js → pageTaxon.js} +4 -4
  32. package/lib/web/pageTaxonList.js +53 -0
  33. package/lib/{pagerenderer.js → web/renderAllPages.js} +38 -80
  34. package/package.json +12 -10
  35. package/scripts/build-site.js +20 -52
  36. package/static/assets/js/nameSearchData.js +2 -0
  37. package/static/assets/js/name_search.js +203 -0
  38. package/static/assets/js/ui.js +11 -0
  39. package/static/assets/js/utils.js +56 -0
  40. package/static/name_search.html +15 -0
  41. package/jekyll/_includes/glossary.html +0 -0
  42. package/jekyll/assets/js/name_search.js +0 -165
  43. package/jekyll/assets/js/ui.js +0 -10
  44. package/jekyll/assets/js/utils.js +0 -26
  45. package/jekyll/name_search.html +0 -17
  46. package/lib/genericpage.js +0 -88
  47. /package/{jekyll → generators}/_includes/analytics.html +0 -0
  48. /package/{jekyll → generators}/_includes/menu_extra.html +0 -0
  49. /package/{jekyll → generators/jekyll}/_config.yml +0 -0
  50. /package/{jekyll → generators/jekyll}/_layouts/default.html +0 -0
  51. /package/{jekyll → generators/jekyll}/_layouts/html.html +0 -0
  52. /package/{jekyll → static}/assets/css/main.css +0 -0
  53. /package/{jekyll → static}/index.md +0 -0
@@ -1,165 +0,0 @@
1
- import { Utils } from "./utils.js";
2
-
3
- const MIN_LEN = 2;
4
- const MAX_RESULTS = 50;
5
-
6
- class Search {
7
-
8
- static #debounceTimer;
9
- static #searchData;
10
-
11
- static #debounce( timeout = 500 ) {
12
- clearTimeout( this.#debounceTimer );
13
- this.#debounceTimer = setTimeout( Search.#doSearch, timeout );
14
- }
15
-
16
- static #doSearch() {
17
-
18
- function matchTaxon( taxon, value ) {
19
-
20
- function matchSynonyms( syns, value ) {
21
- const matchedIndexes = [];
22
- if ( syns ) {
23
- for ( let index = 0; index < syns.length; index++ ) {
24
- if ( syns[ index ].includes( value ) ) {
25
- matchedIndexes.push( index );
26
- }
27
- }
28
- }
29
- return matchedIndexes;
30
- }
31
-
32
- const rawData = taxon[ 0 ];
33
- const name = taxon[ 1 ];
34
- const cn = taxon[ 2 ];
35
- const syns = matchSynonyms( taxon[ 3 ], value );
36
- if ( syns.length > 0 ) {
37
- // Include any matching synonyms.
38
- for ( const index of syns ) {
39
- matches.push( [ rawData[ 0 ], rawData[ 1 ], rawData[ 2 ][ index ] ] );
40
- }
41
- } else {
42
- // No synonyms match; see if the scientific or common names match.
43
- const namesMatch = name.includes( value ) || ( cn && cn.includes( value ) );
44
- if ( namesMatch ) {
45
- matches.push( [ rawData[ 0 ], rawData[ 1 ] ] );
46
- }
47
- }
48
-
49
- }
50
-
51
- Search.#debounceTimer = undefined;
52
-
53
- const value = Search.#normalizeName( document.getElementById( "name" ).value );
54
-
55
- const matches = [];
56
- const shouldSearch = ( value.length >= MIN_LEN );
57
-
58
- if ( shouldSearch ) {
59
-
60
- // If the search data is not done generating, try again later.
61
- if ( !Search.#searchData ) {
62
- this.#debounce( Search.#doSearch );
63
- }
64
-
65
- for ( const taxon of Search.#searchData ) {
66
- matchTaxon( taxon, value );
67
- }
68
- }
69
-
70
- const eBody = document.createElement( "tbody" );
71
- if ( matches.length <= MAX_RESULTS ) {
72
- for ( const match of matches ) {
73
-
74
- const tr = document.createElement( "tr" );
75
-
76
- // Scientific name.
77
- const name = match[ 0 ];
78
- const syn = match[ 2 ];
79
- const td1 = document.createElement( "td" );
80
- const link = Utils.domTaxonLink( name );
81
- td1.appendChild( link );
82
- if ( syn ) {
83
- td1.appendChild( document.createTextNode( " (" + syn + ")" ) );
84
- }
85
- tr.appendChild( td1 );
86
-
87
- const cn = match[ 1 ];
88
- const td2 = document.createElement( "td" );
89
- if ( cn ) {
90
- td2.textContent = cn;
91
- }
92
- tr.appendChild( td2 );
93
-
94
- eBody.appendChild( tr );
95
-
96
- }
97
- }
98
-
99
- // Delete current message
100
- const eMessage = document.getElementById( "message" );
101
- if ( eMessage.firstChild ) {
102
- eMessage.removeChild( eMessage.firstChild );
103
- }
104
- if ( shouldSearch ) {
105
- if ( matches.length === 0 ) {
106
- eMessage.textContent = "Nothing found.";
107
- }
108
- if ( matches.length > MAX_RESULTS ) {
109
- eMessage.textContent = "Too many results.";
110
- }
111
- }
112
-
113
- // Delete current results
114
- const eTable = document.getElementById( "results" );
115
- if ( eTable.firstChild ) {
116
- eTable.removeChild( eTable.firstChild );
117
- }
118
-
119
- eTable.appendChild( eBody );
120
- }
121
-
122
- static async generateSearchData() {
123
- const searchData = [];
124
- // eslint-disable-next-line no-undef
125
- for ( const taxon of NAMES ) {
126
- const taxonData = [ taxon ];
127
- taxonData.push( this.#normalizeName( taxon[ 0 ] ) );
128
- if ( taxon[ 1 ] ) {
129
- taxonData.push( taxon[ 1 ].toLowerCase() );
130
- }
131
- if ( taxon[ 2 ] ) {
132
- const syns = [];
133
- for ( const syn of taxon[ 2 ] ) {
134
- syns.push( this.#normalizeName( syn ) );
135
- }
136
- taxonData[ 3 ] = syns;
137
- }
138
- searchData.push( taxonData );
139
- }
140
- this.#searchData = searchData;
141
- }
142
-
143
- static #handleChange() {
144
- this.#debounce();
145
- }
146
-
147
- static #handleSubmit() {
148
- this.#debounce( 0 );
149
- }
150
-
151
- static init() {
152
- this.generateSearchData();
153
- const eName = document.getElementById( "name" );
154
- eName.focus();
155
- eName.oninput = ( ev ) => { return this.#handleChange( ev ); };
156
- document.getElementById( "search_form" ).onsubmit = () => { this.#handleSubmit(); return false; };
157
- }
158
-
159
- static #normalizeName( name ) {
160
- return name.toLowerCase().replace( / (subsp|var)\./, "" );
161
- }
162
-
163
- }
164
-
165
- Search.init();
@@ -1,10 +0,0 @@
1
- class UI {
2
-
3
- static init() {
4
- const tooltips = document.querySelectorAll( "span[title]" );
5
- [ ...tooltips ].map( tooltipTriggerEl => new bootstrap.Tooltip( tooltipTriggerEl ) );
6
- }
7
-
8
- }
9
-
10
- UI.init();
@@ -1,26 +0,0 @@
1
- class Utils {
2
-
3
- static domElement( name, attributes = {}, content ) {
4
- const e = document.createElement( name );
5
- for ( const [ k, v ] of Object.entries( attributes ) ) {
6
- e.setAttribute( k, v );
7
- }
8
- if ( content ) {
9
- e.textContent = content;
10
- }
11
- return e;
12
- }
13
-
14
- static domLink( href, text, attributes = {} ) {
15
- const e = this.domElement( "a", Object.assign( { href: href }, attributes ) );
16
- e.textContent = text;
17
- return e;
18
- }
19
-
20
- static domTaxonLink( name ) {
21
- return this.domLink( "./" + name.replaceAll( ".", "" ).replaceAll( " ", "-" ) + ".html", name );
22
- }
23
-
24
- }
25
-
26
- export { Utils };
@@ -1,17 +0,0 @@
1
- ---
2
- title: Name Search
3
- js: name_search.js
4
- ---
5
-
6
- <script>
7
- const NAMES = {% include names.json %};
8
- </script>
9
-
10
- <form id="search_form">
11
- <input type="text" id="name">
12
- <label for="name">Search for scientific name, common name, or synonym.</label>
13
- </form>
14
-
15
- <div class="section" id="message"></div>
16
-
17
- <table id="results"></table>
@@ -1,88 +0,0 @@
1
- import { Config } from "./config.js";
2
- import { Files } from "./files.js";
3
- import { HTML } from "./html.js";
4
- import { Jekyll } from "./jekyll.js";
5
- import { Markdown } from "./markdown.js";
6
-
7
- class GenericPage {
8
- #outputDir;
9
- #title;
10
- #baseFileName;
11
- #js;
12
-
13
- /**
14
- * @param {string} outputDir
15
- * @param {string} title
16
- * @param {string} baseFileName
17
- * @param {string} [js]
18
- */
19
- constructor(outputDir, title, baseFileName, js) {
20
- this.#outputDir = outputDir;
21
- this.#title = title;
22
- this.#baseFileName = baseFileName;
23
- this.#js = js;
24
- }
25
-
26
- getBaseFileName() {
27
- return this.#baseFileName;
28
- }
29
-
30
- getDefaultIntro() {
31
- let html = this.getFrontMatter();
32
- return html + this.getMarkdown();
33
- }
34
-
35
- getFrontMatter() {
36
- return (
37
- "---\n" +
38
- 'title: "' +
39
- this.#title +
40
- '"\n' +
41
- (this.#js ? "js: " + this.#js + "\n" : "") +
42
- "---\n"
43
- );
44
- }
45
-
46
- getMarkdown() {
47
- // Include site-specific markdown.
48
- let html = this.#getMarkdown("intros");
49
-
50
- // Include package markdown.
51
- const mdPath =
52
- Config.getPackageDir() + "/data/text/" + this.#baseFileName + ".md";
53
- const markdownHTML = Markdown.fileToHTML(mdPath);
54
- if (markdownHTML) {
55
- html += HTML.wrap("div", markdownHTML, { class: "section" });
56
- }
57
-
58
- return html;
59
- }
60
-
61
- /**
62
- * @param {string} path
63
- */
64
- #getMarkdown(path) {
65
- const textPath = path + "/" + this.#baseFileName + ".md";
66
- if (!Jekyll.hasInclude(this.#outputDir, textPath)) {
67
- return "";
68
- }
69
- return HTML.wrap("div", Jekyll.include(textPath), { class: "section" });
70
- }
71
-
72
- getOutputDir() {
73
- return this.#outputDir;
74
- }
75
-
76
- getTitle() {
77
- return this.#title;
78
- }
79
-
80
- /**
81
- * @param {string} html
82
- */
83
- writeFile(html) {
84
- Files.write(this.#outputDir + "/" + this.#baseFileName + ".html", html);
85
- }
86
- }
87
-
88
- export { GenericPage };
File without changes
File without changes
File without changes
File without changes