Skip to content

Commit

Permalink
feat: generalize footer HTML tools (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkenny54 authored Dec 14, 2024
1 parent 2fa5479 commit 8114cfa
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion data/taxa.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ Maianthemum racemosum,false Solomon's seal,N,32495,10096,51062,Large False Solom
Maianthemum stellatum,,N,32497,9629,53268,False Solomon Seal
Malacothamnus arcuatus var. elmeri,,N,108345,14681,1497404,Eastern Bewildering Bushmallow,perennial,pink,4,5,1065,1B.2,,,S2,G2
Malacothamnus fremontii var. fremontii,long-haired unfurled bushmallow,N,108341,14689,70398,,perennial,pink,5,6
Malacothamnus hallii,,N,108345,14681,1497404,,,,,,1065,1B.2,,,S2,G2
Malacothamnus hallii,Hall's bushmallow,N,108345,14681,1497404,,perennial,pink,4,5,1065,1B.2,,,S2,G2
Malacothrix californica,,N,4059,5325,58026,California Desertdandelion
Malacothrix clevelandii,Cleveland's malacothrix,N,4060,5326,58841,Cleveland's Desertdandelion
Malacothrix coulteri,snake's-head,N,4061,5327,58027,Snake's Head
Expand Down
6 changes: 6 additions & 0 deletions data/text/Eriastrum-ertterae.footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Resources

- Gowen, David. “[TWO NEW SPECIES OF ERIASTRUM (POLEMONIACEAE) FROM CALIFORNIA.](http://www.jstor.org/stable/24621044)” Journal of the Botanical Research Institute of Texas, vol. 7, no. 1, 2013, pp. 21–24. JSTOR
- California Department of Fish and Wildlife (CDFW). 2023. [Report to the Fish and Game
Commission, status review of Lime Ridge eriastrum (_Eriastrum ertterae_)](https://nrm.dfg.ca.gov/FileHandler.ashx?DocumentID=213638&inline). California Department
of Fish and Wildlife
3 changes: 3 additions & 0 deletions data/text/Malacothamnus-arcuatus-var-elmeri.footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Resources

- Morse, Keir (2023). [Malacothamnus Volume 3 - A Revised Treatment of the Genus Malacothamnus (Malvaceae) Based on Morphological and Phylogenetic Evidence](https://doi.org/10.6084/m9.figshare.23937066.v1). figshare. Book.
3 changes: 3 additions & 0 deletions data/text/Malacothamnus-fremontii-var-fremontii.footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Resources

- Morse, Keir (2023). [Malacothamnus Volume 3 - A Revised Treatment of the Genus Malacothamnus (Malvaceae) Based on Morphological and Phylogenetic Evidence](https://doi.org/10.6084/m9.figshare.23937066.v1). figshare. Book.
3 changes: 3 additions & 0 deletions data/text/Malacothamnus-hallii.footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Resources

- Morse, Keir (2023). [Malacothamnus Volume 3 - A Revised Treatment of the Genus Malacothamnus (Malvaceae) Based on Morphological and Phylogenetic Evidence](https://doi.org/10.6084/m9.figshare.23937066.v1). figshare. Book.
14 changes: 14 additions & 0 deletions lib/htmltaxon.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Config } from "./config.js";
import { DateUtils } from "./dateutils.js";
import { HTML } from "./html.js";
import { Markdown } from "./markdown.js";
Expand Down Expand Up @@ -127,6 +128,19 @@ class HTMLTaxon {
: HTML.wrap("div", parts.join(""), { class: classNames });
}

/**
* @param {Taxon} taxon
* @returns {string}
*/
static getFooterHTML(taxon) {
const footerTextPath =
Config.getPackageDir() +
"/data/text/" +
taxon.getBaseFileName() +
".footer.md";
return HTMLTaxon.getMarkdownSection(footerTextPath);
}

/**
* @param {Taxon} taxon
*/
Expand Down
1 change: 1 addition & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class HTML {
}

export class HTMLTaxon {
static getFooterHTML(taxon: Taxon): string;
static getListSectionHTML(
list: string[],
header: string,
Expand Down
8 changes: 1 addition & 7 deletions lib/web/pagetaxon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { GenericPage } from "../genericpage.js";
import { ExternalSites } from "../externalsites.js";
import { HTML } from "../html.js";
import { HTMLTaxon } from "../htmltaxon.js";
import { Config } from "../config.js";

class PageTaxon extends GenericPage {
#config;
Expand Down Expand Up @@ -188,12 +187,7 @@ class PageTaxon extends GenericPage {
);
html += "</div>";

const footerTextPath =
Config.getPackageDir() +
"/data/text/" +
this.getBaseFileName() +
".footer.md";
html += HTMLTaxon.getMarkdownSection(footerTextPath);
html += HTMLTaxon.getFooterHTML(this.#taxon);

const photos = this.#taxon.getPhotos();
if (photos.length > 0) {
Expand Down

0 comments on commit 8114cfa

Please sign in to comment.