Skip to content

Commit

Permalink
Expanded description of how to use the cookie banner
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbielby committed Feb 13, 2024
1 parent 02eca50 commit 2085897
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 3 deletions.
35 changes: 34 additions & 1 deletion R/cookies.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ dfe_cookie_script <- function() {
#' functionality is provided by cookieBannerServer(), whilst users will also
#' need to include the dfe_cookie_script() function in their ui.R file.
#'
#' To use the banner, first copy the file cookie-consent.js from the js/ folder
#' of this package to the www/ folder of your R-Shiny app. Then add the
#' following lines to your ui.R:
#' dfe_cookie_script()
#' cookieBannerUI("cookies", name = "My DfE R-Shiny data dashboard")
#'
#' And add the following in server.R:
#' output$cookie_status <- dfeshiny::cookieBannerServer(
#' "cookies",
#' input.cookies = reactive(input$cookies),
#' input.remove = reactive(input$remove),
#' parent_session = session
#' )
#'
#' Note that you should also include dfeshiny::support_panel() in your
#' navListPanel()
#'
#' @param id Shiny tag shared with cookieBannerServer()
#' @param name Name of the dashboard on which the cookie authorisation is being
#' applied
Expand Down Expand Up @@ -85,6 +102,23 @@ cookieBannerUI <- function(id, name = "DfE R-Shiny dashboard template") {
#' reject cookie consent for the provision of Google Analytics tracking on DfE
#' R-Shiny dashboards.
#'
#' To use the banner, first copy the file cookie-consent.js from the js/ folder
#' of this package to the www/ folder of your R-Shiny app. Then add the
#' following lines to your ui.R:
#' dfe_cookie_script()
#' cookieBannerUI("cookies", name = "My DfE R-Shiny data dashboard")
#'
#' And add the following in server.R:
#' output$cookie_status <- dfeshiny::cookieBannerServer(
#' "cookies",
#' input.cookies = reactive(input$cookies),
#' input.remove = reactive(input$remove),
#' parent_session = session
#' )
#'
#' Note that you should also include dfeshiny::support_panel() in your
#' navListPanel()
#'
#' @param id Shiny tag shared with cookieBannerUI()
#' @param input.cookies The cookie input passed from cookies.js (should always
#' be reactive(input$cookies))
Expand Down Expand Up @@ -173,7 +207,6 @@ cookieBannerServer <- function(id, input.cookies, input.remove, parent_session)
return(renderText({

Check warning

Code scanning / lintr

no visible global function definition for 'renderText' Warning

no visible global function definition for 'renderText'
cookie_text_stem <- "You have chosen to"
cookie_text_tail <- "the use of cookies on this website."
message(paste("Cookie status:", input.cookies()))
if (!is.null(input.cookies())) {
if ("dfe_analytics" %in% names(input.cookies())) {
if (input.cookies()$dfe_analytics == "granted") {
Expand Down
26 changes: 24 additions & 2 deletions man/cookieBannerServer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions man/cookieBannerUI.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2085897

Please sign in to comment.