noaa-onms / cinms

Channel Islands National Marine Sanctuary
https://noaa-onms.github.io/cinms
MIT License
3 stars 1 forks source link

fix bugs rendering site with new `nms4r::render_all_rmd()` #78

Closed bbest closed 3 years ago

bbest commented 3 years ago

Hi Jai,

Thanks for explanation in https://github.com/marinebon/cinms/commit/da5a41dc245ecfffe123b156353869adac66f309#commitcomment-49328591 to my message "+ render_site.R after deleted by @superjai (why?!)":

Hey @bbest - that functionality was moved to nms4r. I believe the nms4r function you want is render_all_rmd() https://marinebon.org/nms4r/reference/render_all_rmd.html

I'm trying to setup Google Analytics for cinms #77. I updated the README.md to reflect this new way of rendering the pages:

# render only changed Rmds
nms4r::render_all_rmd()

# render all Rmds
render_all_rmd(render_all = T)

Looks like it's mostly working, but I ran into a snag running render_all_rmd(render_all = T) with modals/kelp-forest-biogenic-invertebrates.Rmd. Could you please look into getting this to work?

Thanks, Ben

PS Here's the log output for the problematic file...

processing file: kelp-forest-biogenic-invertebrates.rmd
  |.............................                             |  50%
label: unnamed-chunk-1 (with options) 
List of 1
 $ include: symbol F

  |..........................................................| 100%
  ordinary text without R code

output file: kelp-forest-biogenic-invertebrates.knit.md

/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS kelp-forest-biogenic-invertebrates.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /Users/bbest/github/cinms/modals/kelp-forest-biogenic-invertebrates.glossarized.html --lua-filter /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --variable bs3=TRUE --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --css _modal_styles.css --css modal_libs/font-awesome-5.3.1/css/all.min.css --css modal_libs/font-awesome-5.3.1/css/v4-shims.min.css --variable theme=lumen --include-in-header /var/folders/2r/grqvdjfn04361tzk8mh60st40000gn/T//RtmpNTFqtJ/rmarkdown-str4e992f5ecc85.html --include-in-header ../libs/Ganalytics.html 
[WARNING] This document format requires a nonempty <title> element.
  Please specify either 'title' or 'pagetitle' in the metadata,
  e.g. by using --metadata pagetitle="..." on the command line.
  Falling back to 'kelp-forest-biogenic-invertebrates.utf8'

Output created: modals/kelp-forest-biogenic-invertebrates.glossarized.html
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS kelp-forest-biogenic-invertebrates.glossarized.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /Users/bbest/github/cinms/modals/kelp-forest-biogenic-invertebrates.html --lua-filter /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --variable bs3=TRUE --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --css _modal_styles.css --css modal_libs/font-awesome-5.3.1/css/all.min.css --css modal_libs/font-awesome-5.3.1/css/v4-shims.min.css --variable theme=lumen --include-in-header /var/folders/2r/grqvdjfn04361tzk8mh60st40000gn/T//RtmpNTFqtJ/rmarkdown-str4e9978c5480e.html --include-in-header ../libs/Ganalytics.html 
[WARNING] This document format requires a nonempty <title> element.
  Please specify either 'title' or 'pagetitle' in the metadata,
  e.g. by using --metadata pagetitle="..." on the command line.
  Falling back to 'kelp-forest-biogenic-invertebrates.glossarized.utf8'

Output created: /Users/bbest/github/cinms/modals/kelp-forest-biogenic-invertebrates.html

processing file: kelp-forest-biogenic-invertebrates.rmd
  |.............................                             |  50%
label: unnamed-chunk-1 (with options) 
List of 1
 $ include: symbol F

  |..........................................................| 100%
  ordinary text without R code

output file: kelp-forest-biogenic-invertebrates.knit.md

/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS kelp-forest-biogenic-invertebrates.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /Users/bbest/github/cinms/modals//temp_file.html --lua-filter /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --variable bs3=TRUE --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --css _modal_styles.css --css modal_libs/font-awesome-5.3.1/css/all.min.css --css modal_libs/font-awesome-5.3.1/css/v4-shims.min.css --variable theme=lumen --include-in-header /var/folders/2r/grqvdjfn04361tzk8mh60st40000gn/T//RtmpNTFqtJ/rmarkdown-str4e99fa2cba1.html --include-in-header ../libs/Ganalytics.html 
[WARNING] This document format requires a nonempty <title> element.
  Please specify either 'title' or 'pagetitle' in the metadata,
  e.g. by using --metadata pagetitle="..." on the command line.
  Falling back to 'kelp-forest-biogenic-invertebrates.utf8'

Output created: modals//temp_file.html
Error in while (!(input_lines[i] == "</head>")) { : 
  missing value where TRUE/FALSE needed
In addition: There were 50 or more warnings (use warnings() to see the first 50)
superjai commented 3 years ago

hey @bbest - issue fixed. The problem was with the capitalization of the extension of kelp-forest-biogenic-invertebrates.rmd. All other R Markdown files in that folder have the extension ".Rmd". This one has the extension ".rmd". The function nms4r::generate_html_4_rmd(), on one line, is case sensitive with the extension. I fixed that one line, so that the function is no longer sensitive to capitalization in the extension.

Line 58 in the function goes from:

  target_html <- gsub("Rmd", "html", target_rmd)

to:

  target_html <- gsub("Rmd", "html", target_rmd, ignore.case = TRUE)

I updated the _site.yml file in the modals folder to include Ganalytics.html. I then reran all of the modal R Markdown files using nms4r::render_all_rmd(render_all=T) and it all worked fine.

However, I was unable to push my changes up to the cinms repo, as RStudio kept crashing if I attempted to push more than one file at a time. This seems to be some particular problem with the cinms repo and Windows, as I am not having this issue with other repos. I tried several fixes to solve the issue, but no luck.

So, I think that you will need to update the modal windows, as I am unable to do so. I did update the _site.yml in the modals folder of the repo to include Ganalytics. You'll just need to pull that and then you can run nms4r::render_all_rmd(render_all=T). Hopefully you won't have the same issue as I did when committing your changes.

superjai commented 3 years ago

@bbest - success! I used github desktop and was able to push my updated files for the modal folder. So, no need for you to run render_all_rmd