ThinkR-open / golem

A Framework for Building Robust Shiny Apps
https://thinkr-open.github.io/golem/
Other
904 stars 132 forks source link

Location for static HTML files to deploy with golem app #626

Closed mcsiple closed 3 years ago

mcsiple commented 3 years ago

Hi golem developers, Thank you for making this great helper package-- it has helped me a lot in putting together and deploying my package! This question is sort of esoteric but maybe others have the same one. I have an app with one tab that displays documentation, and the app loads a different html file depending on the language that the user has selected. When I'm running the app on the Shiny server, I just store the html files in a directory, but I don't know where to put them when I'm writing this package.

In my first attempt, I put them in a subdirectory of the R directory:

R/Documentation/docfile_en.html R/Documentation/docfile_es.html ...etc

When I install the package from github, I get the following error:

warning in file(con, "r") :
  cannot open file 'C:/Users/pun009/AppData/Local/Temp/RtmpI5OJuG/R.INSTALL2ef859b84601/mmrefpoints/R/Documentation/ProjectionModel_en.html': No such file or directory
Warning: Error in file: cannot open the connection

I imagine that other Shiny developers have html files they want to insert in their apps using shiny::includeHTML(). Where should I put the files?

Thank you!

VincentGuyader commented 3 years ago

Hi

You can't create subdirectory in the R folder. And R folder is only for R functions (and roxygen2 documentation)

You can put your html file into inst/ folder and then use app_sys function to use it.

Is your application open source? Can you share a link?

Regards

mcsiple commented 3 years ago

Hi Vincent-- thank you. I see, I'll put it in inst/ instead. Here is the link to my app on github. I know there are many other issues that remain but I think this one is the most important!

VincentGuyader commented 3 years ago

please have a look to my fork here :

https://github.com/VincentGuyader/mmrefpoints

https://github.com/mcsiple/mmrefpoints/compare/master...VincentGuyader:master

And because your app_server file is 1500 line long, please use shiny modules :) (I know it can be scary at first, but once you've started you can't do without it).

mcsiple commented 3 years ago

Excellent! That worked wonderfully, thank you.

I also moved my report.Rmd (an HTML report generated by the app) to inst/ and it works great. Lots of other issues to sort out but at least it is functional enough to run the app when it installs. And yes re: modules, I know...I learned Shiny as I was writing it and some pieces are very inefficient. I'll work on that! Thanks again.