I am trying to add the shiny app into golem structure. Therefore, everything that I am asking here should be in line with golem structure.
Here is the problem:
I cannot add my html into a module. And that is why I get the following error:
cannot open file 'www/workflow_accordion.html': No such file or directory
Here is the module I have added to app_ui (make sure you see the golem structure here https://engineering-shiny.org/golem.html )
#' mod_workflows_ui
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_workflows_ui <- function(id){
ns <- NS(id)
shiny::tabPanel(
"Workflows", icon = icon("list"),
div(
class = "container",
shinyLP::jumbotron(
"Workflows",
"How to use the Bioinformatics for the Bench apps to access specific datasets and answer biological questions",
button = FALSE
),
hr(),
includeHTML("Documentation/workflow_accordion.html"),
br(),
br(),
br()
)
)
tags$footer(
includeHTML("Documentation/footer.html")
)
}
#' mod_workflows_server
#'
#' @noRd
mod_workflows_server <- function(id){
ns <- session$ns
}
This module is added into several parts as per golem structure:
mod_workflows_ui("mod_workflows_ui_1")
golem::add_module(name = "workflow_app", with_test = TRUE)
After that I call in the mod_tutorials in app_ui file like this:
shiny::tabPanel("Workflow", icon = icon("graduation-cap"),mod_workflow_ui("mod_workflow_ui_1"))
,
And then I go int run_dev and just run the app.
Now the issue is that I get this error:
cannot open file 'Documentation/workflow_accordion.html': No such file or directory
What am I missing? Why does it do this and how I can solve it, I am open for other ways of solving this matter.
Okay, I have 2 html's that I deal with above.
I will take only one example, the 'footer.html' since it is a bit harder to deal but because this is the exact pattern I have applied for the other html file.
But firstly, I have tried several ideas:
1. includeHTML("www/footer.html")
2. app_sys("app/www/footer.html")
Yet, none of these work. Apparently html files aren't specific to golem, according to @Colin Fay, as he mentioned here: https://github.com/ThinkR-open/golem/issues/890 Actually tried all his ideas and still, it did not work.
However,
what I have done was to take what was written in html and turn it into a module according to golem structure:
#' mod_footer_ui UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_footer_ui <- function(id) {
ns <- NS(id)
tagList(
tags$footer(
HTML(
r"(
<div class="container">
<div class="row">
<div class="col-sm-3">
<img padding: 10px 10px; height="150px" src="www/logo_v4.png">
</div>
<div class="col-sm-3">
<h4>Links</h4>
<ul>
<li><a href="http://goto.az/logo">goto.az/bftb</a></li>
<li><a href="https://website/groups/430852910696122/">Workplace Group</a></li>
<li><a href="https://website/sites/Bench/SitePages/Bench.aspx">Tutorial Recordings</a></li>
</ul>
</div>
<div class="col-sm-3">
<h4>About us</h4>
landing page was built by my name and other people's name. Please contact us with suggestions.
</div>
<div class="col-sm-3">
<h4>Support</h4>
<ul>
<li><a href="mailto:">Contact </a></li>
<li><a href="mailto:">Contact </a></li>
<li><a href="mailto:"></a></li>
</ul>
</div>
</div>
</div>
<br>)
)"
)
)
)
}
#' mod_footer_server Server Functions
#'
#' @noRd
mod_footer_server <- function(id){
ns <- session$ns
}
Then adding these modules to golem scripts found in :
golem::add_module(name = "footer_app", with_test = TRUE)
mod_footer_ui("mod_footer_ui_1")
tags$footer(mod_footer_ui("mod_footer_ui_1"))
Then run the script provided in golem run_dev
and it works beautifully!