Skip to content

Commit

Permalink
Adding cookie header script
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbielby committed Feb 12, 2024
1 parent 21d5b6d commit 70172f4
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 48 deletions.
61 changes: 40 additions & 21 deletions R/cookies.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#' cookieHeaderUI
#'
#' @return tags$head()
#' @export
#'
#' @examples
#' cookieHeaderUI()
cookieHeaderUI <- function() {

Check notice

Code scanning / lintr

Variable and function name style should match snake_case or symbols. Note

Variable and function name style should match snake_case or symbols.
tags$head(

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'
tags$script(
src = paste0(
"https://cdn.jsdelivr.net/npm/js-cookie@rc/",
"dist/js.cookie.min.js"
)
),
tags$script(src = "cookie-consent.js")
)
}

#' cookieBannerUI
#'
#' @description
Expand All @@ -13,42 +32,43 @@
#' @export
#'
#' @examples
#' cookieBannerUI("cookies", name='My DfE R-Shiny data dashboard')
cookieBannerUI <- function(id, name = "DfE R-Shiny dashboard template"){
#' cookieBannerUI("cookies", name = "My DfE R-Shiny data dashboard")
cookieBannerUI <- function(id, name = "DfE R-Shiny dashboard template") {

Check notice

Code scanning / lintr

Variable and function name style should match snake_case or symbols. Note

Variable and function name style should match snake_case or symbols.
tags$div(

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'

Check warning

Code scanning / lintr

no visible binding for global variable 'tags' Warning

no visible binding for global variable 'tags'
id=NS(id,"cookieDiv"),
class="govuk-cookie-banner",
`data-nosnippet role`="region",
`aria-label`="Cookies on name",
id = NS(id, "cookieDiv"),

Check warning

Code scanning / lintr

no visible global function definition for 'NS' Warning

no visible global function definition for 'NS'

Check warning

Code scanning / lintr

no visible global function definition for 'NS' Warning

no visible global function definition for 'NS'

Check warning

Code scanning / lintr

no visible global function definition for 'NS' Warning

no visible global function definition for 'NS'

Check warning

Code scanning / lintr

no visible global function definition for 'NS' Warning

no visible global function definition for 'NS'

Check warning

Code scanning / lintr

no visible global function definition for 'NS' Warning

no visible global function definition for 'NS'
class = "govuk-cookie-banner",
`data-nosnippet role` = "region",
`aria-label` = "Cookies on name",
tags$div(
id=NS(id,"cookieMain"),
class="govuk-cookie-banner__message govuk-width-container",
id = NS(id, "cookieMain"),
class = "govuk-cookie-banner__message govuk-width-container",
tags$div(
class="govuk-grid-row",
class = "govuk-grid-row",
tags$div(
class="govuk-grid-column-two-thirds",
class = "govuk-grid-column-two-thirds",
tags$h2(
class="govuk-cookie-banner__heading govuk-heading-m",
name),
class = "govuk-cookie-banner__heading govuk-heading-m",
name
),
tags$div(
class="govuk-cookie-banner__content",
class = "govuk-cookie-banner__content",
tags$p(
class="govuk-body",
class = "govuk-body",
"We use some essential cookies to make this service work."
),
tags$p(
class="govuk-body",
class = "govuk-body",
"We'd also like to use analytics cookies so we can understand
how you use the service and make improvements."
)
)
)
),
tags$div(
class="govuk-button-group",
actionButton(NS(id,"cookieAccept"), label = "Accept analytics cookies"),
actionButton(NS(id,"cookieReject"), label = "Reject analytics cookies"),
actionButton(NS(id,"cookieLink"), label = "View cookies")
class = "govuk-button-group",
actionButton(NS(id, "cookieAccept"), label = "Accept analytics cookies"),

Check warning

Code scanning / lintr

no visible global function definition for 'actionButton' Warning

no visible global function definition for 'actionButton'

Check warning

Code scanning / lintr

no visible global function definition for 'actionButton' Warning

no visible global function definition for 'actionButton'

Check warning

Code scanning / lintr

no visible global function definition for 'actionButton' Warning

no visible global function definition for 'actionButton'

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 81 characters. Note

Lines should not be more than 80 characters. This line is 81 characters.
actionButton(NS(id, "cookieReject"), label = "Reject analytics cookies"),

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 81 characters. Note

Lines should not be more than 80 characters. This line is 81 characters.
actionButton(NS(id, "cookieLink"), label = "View cookies")
)
)
)
Expand All @@ -74,7 +94,7 @@ cookieBannerUI <- function(id, name = "DfE R-Shiny dashboard template"){
#'
#' @examples
#' cookieBannerServer("cookies", input.cookies = reactive(input$cookies), input.remove = reactive(input$remove))

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 112 characters. Note

Lines should not be more than 80 characters. This line is 112 characters.
cookieBannerServer <- function(id, input.cookies=NULL, input.remove=NULL) {
cookieBannerServer <- function(id, input.cookies = NULL, input.remove = NULL) {

Check notice

Code scanning / lintr

Variable and function name style should match snake_case or symbols. Note

Variable and function name style should match snake_case or symbols.

Check notice

Code scanning / lintr

Variable and function name style should match snake_case or symbols. Note

Variable and function name style should match snake_case or symbols.

Check notice

Code scanning / lintr

Variable and function name style should match snake_case or symbols. Note

Variable and function name style should match snake_case or symbols.
moduleServer(id, function(input, output, session) {

Check warning

Code scanning / lintr

no visible global function definition for 'moduleServer' Warning

no visible global function definition for 'moduleServer'
observeEvent(input.cookies(), {

Check warning

Code scanning / lintr

no visible global function definition for 'observeEvent' Warning

no visible global function definition for 'observeEvent'
print(input.cookies()$`_ga_Z967JJVQQX`)
Expand Down Expand Up @@ -144,6 +164,5 @@ cookieBannerServer <- function(id, input.cookies=NULL, input.remove=NULL) {
session$sendCustomMessage("analytics-consent", msg)
print(input$cookies)
})

})
}
54 changes: 27 additions & 27 deletions R/standard_panels.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,38 @@ support_panel <- function(
tags$a(href = paste0("mailto:", team_email), team_email, .noWS = c("after")), "."
),
h2("Find more information on the data"),
if (ees_publication) {
p(
"The parent statistical release of this dashboard, along with methodological information, is available at the following link: ",
tags$a(
href = paste0("https://explore-education-statistics.service.gov.uk/find-statistics/", publication_stub),
ifelse(!is.null(publication_name), publication_name, "Explore Education Statistics"),
.noWS = c("after")
),
". The statistical release provides additional ",
tags$a(
href = paste0("https://explore-education-statistics.service.gov.uk/find-statistics/", publication_stub, "/data guidance"),
"data guidance",
.noWS = c("after")
),
" and ",
tags$a(
href = paste0("https://explore-education-statistics.service.gov.uk/find-statistics/", publication_stub,'#explore-data-and-files'),
"tools to access and interogate the underling data",
.noWS = c("after")
),
if (ees_publication) {
p(
"The parent statistical release of this dashboard, along with methodological information, is available at the following link: ",

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 144 characters. Note

Lines should not be more than 80 characters. This line is 144 characters.
tags$a(
href = paste0("https://explore-education-statistics.service.gov.uk/find-statistics/", publication_stub),

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 122 characters. Note

Lines should not be more than 80 characters. This line is 122 characters.
ifelse(!is.null(publication_name), publication_name, "Explore Education Statistics"),

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 103 characters. Note

Lines should not be more than 80 characters. This line is 103 characters.
.noWS = c("after")
),
". The statistical release provides additional ",
tags$a(
href = paste0("https://explore-education-statistics.service.gov.uk/find-statistics/", publication_stub, "/data guidance"),

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 140 characters. Note

Lines should not be more than 80 characters. This line is 140 characters.
"data guidance",
.noWS = c("after")
),
" and ",
tags$a(
href = paste0("https://explore-education-statistics.service.gov.uk/find-statistics/", publication_stub, "#explore-data-and-files"),

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 148 characters. Note

Lines should not be more than 80 characters. This line is 148 characters.
"tools to access and interogate the underling data",
.noWS = c("after")
),
" contained in this dashboard."
)
} else {
p(
"The parent statistical release of this dashboard, along with methodological information, is available at the following link: ",
a(
)
} else {
p(
"The parent statistical release of this dashboard, along with methodological information, is available at the following link: ",

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 144 characters. Note

Lines should not be more than 80 characters. This line is 144 characters.
a(
href = alt_href,
publication_name,
.noWS = c("after")
)
)
},
)
},
h2("Contact us"),
p(
"If you have questions about the dashboard or data within it, please contact us at ",
Expand Down

0 comments on commit 70172f4

Please sign in to comment.