Addins: Initiate drake -> drake$source_plan()
-> drake$makePlan()
.
web$browse()
to see the output.
If any change to Rmd or js/ and css/ folder, then web$update()
-> web$browse()
to see the change.
Your html output file is in web$output_filepath()
.
library(dplyr) library(htmltools) library(econR) .GlobalEnv$web <- econR::Web() web$foldername="www" # output folder name web$html_filename <- "index.html"
library(plotly)
plt_widget <- subplot( plot_ly(mpg, x = ~cty, y = ~hwy, name = "default"), plot_ly(mpg, x = ~cty, y = ~hwy) %>% add_markers(alpha = 0.2, name = "alpha") )
bodyTags <- { htmltools::tagList( tags$main( tags$h5(class="center-align", "Materialise with Plotly") ), tags$div(class="container", tags$div(class="row", tags$div(class="col s12", plt_widget) )) ) }
html_placeholder <- tagList( tags$head( do.call(htmltools::tagList, headTags), tags$meta( name="viewport", content="width=device-width, initial-scale=1.0" ) ), tags$body( do.call(htmltools::tagList, bodyTags) ) )
headTags <- { htmltools::tagList( htmltools::tags$link( href="https://fonts.googleapis.com/icon?family=Material+Icons", rel="stylesheet" ) ) }
myDependency <- htmltools::htmlDependency( name="myown", version="1.0", src=c(filepath=web$cssJsPath), stylesheet = "css/mystyle.css", script = "js/mydesign.js", head = '<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Sans+TC"> ', all_files = F )
web$config_cssJsPath("your_path")
in makecondition -- no need to change web$cssJsPath
(it will change accordingly).local_jquery <- htmltools::htmlDependency( name="jquery", version="3.5.1", src=c(href = "lib/jquery-3.5.1"), # to use the same library here must use href, not filepath; otherwise, the current jquery system will be removed. script = c("jquery.min.js") )
html_complete <- htmltools::tagList( html_placeholder, web$htmlDependencies$materialise(), local_jquery, myDependency )
local_jquery
with web$htmlDependencies$jquery()
htmltools::save_html( html_complete, file = web$output_filepath(), libdir="lib" )
web$browse()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.