Skip to content

Commit

Permalink
Merge pull request #101 from dfe-analytical-services/eesp/restoring-c…
Browse files Browse the repository at this point in the history
…ookies-functionality

Re-instated cookie control
  • Loading branch information
t-surtees authored Oct 17, 2024
2 parents f79b7eb + 4fe7f10 commit 2d724a5
Show file tree
Hide file tree
Showing 22 changed files with 91 additions and 155 deletions.
27 changes: 13 additions & 14 deletions .hooks/pre-commit.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env Rscript
cat("Running commit hooks...",fill=TRUE)
cat("Running commit hooks...", fill = TRUE)
shhh <- suppressPackageStartupMessages # It's a library, so shhh!
shhh(library(dplyr))
shhh(library(dfeshiny))
Expand All @@ -17,12 +17,12 @@ cat("Contents of the .gitignore file:")
print(ign_files)

# Run a pass through the .gitignore files and look for any issues
if(ncol(ign_files)>1){
if (ncol(ign_files) > 1) {
cat("ERROR: It looks like you've got commas in the .gitignore. Please correct the .gitignore file and try again.")
error_flag <- TRUE
} else {
for(i in 1:nrow(ign_files)){
if(grepl(' ',ign_files$filename[i])){
for (i in 1:nrow(ign_files)) {
if (grepl(" ", ign_files$filename[i])) {
cat("ERROR: It looks like you've got spaces in filenames in the .gitignore. Please rename your files if they contain spaces and update the .gitignore file accordingly.")
error_flag <- TRUE
}
Expand All @@ -44,25 +44,24 @@ for (file in current_files$files) {
} else {
file_status <- (log_files %>% filter(filename == file))$status
if (!file_status %in% c("published", "Published", "reference", "Reference", "dummy", "Dummy")) {
if (!file %in% ign_files$filename & !grepl("unpublished",file)) {
if (!file %in% ign_files$filename & !grepl("unpublished", file)) {
cat("Error:", file, "is not logged as published or reference data in datafiles_log.csv and is not found in .gitignore.\n\n")
cat("If the file contains published or reference data then update its entry in datafiles_log.csv.\n\n")
cat("If the file contains unpublished data then add it to the .gitignore file.\n\n")
error_flag <- TRUE
}
else {
cat(file,"is recorded in the logfile as unpublished data and in .gitignore and so will not be included as part of the commit.\n\n")
} else {
cat(file, "is recorded in the logfile as unpublished data and in .gitignore and so will not be included as part of the commit.\n\n")
}
}
}
}

if(grepl('G-Z967JJVQQX', htmltools::includeHTML(("google-analytics.html"))) &
!(toupper(Sys.getenv("USERNAME")) %in% c("CFOSTER4", "CRACE", "LSELBY","RBIELBY", "JMACHIN"))){
cat("Cleaning out the template's Google Analytics tag.",fill=TRUE)
if (grepl("G-Z967JJVQQX", htmltools::includeHTML(("google-analytics.html"))) &
!(toupper(Sys.getenv("USERNAME")) %in% c("CFOSTER4", "CRACE", "LSELBY", "RBIELBY", "JMACHIN"))) {
cat("Cleaning out the template's Google Analytics tag.", fill = TRUE)
gsub_file("google-analytics.html", pattern = "G-Z967JJVQQX", replacement = "G-XXXXXXXXXX")
gsub_file("ui.R", pattern = "Z967JJVQQX", replacement = "XXXXXXXXXX")
system2(command = "git", args=c("add","google-analytics.html"))
system2(command = "git", args = c("add", "google-analytics.html"))
}

if (error_flag) {
Expand All @@ -71,12 +70,12 @@ if (error_flag) {
}

tidy_output <- tidy_code()
if(any(tidy_output)){
if (any(tidy_output)) {
error_flag <- TRUE
}

if (error_flag) {
cat("Warning: Code did not appear to have been tidied.\nI've run tidy code for you,
cat("Warning: Code did not appear to have been tidied.\nI've run tidy code for you,
please check your files and the dashboard still works and then re-stage and try committing again.")
quit(save = "no", status = 1, runLast = FALSE)
}
Expand Down
8 changes: 0 additions & 8 deletions R/dashboard_panels.R
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,3 @@ accessibility_panel <- function() {
)
)
}

# support panel
support_panel <- function() {
tabPanel(
"Support and feedback",
support_links() # defined in R/supporting_links.R
)
}
36 changes: 0 additions & 36 deletions R/support_links.R

This file was deleted.

53 changes: 2 additions & 51 deletions global.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,8 @@
#
#
# Install packages -----------------------------------------------
# This might be needed if it is your first time running the code.
# Uncomment out and run this section manually.

# packages_to_install <- c(
# "rsconnect",
# "shinyGovstyle",
# "shiny",
# "shinyjs",
# "tools",
# "testthat",
# "shinydashboard",
# "shinyWidgets",
# "shinyGovstyle",
# "data.table",
# "ggplot2",
# "plotly",
# "dplyr",
# "shinycssloaders",
# "tidyr",
# "stringr",
# "flexdashboard",
# "scales",
# "forcats",
# "openxlsx",
# "kableExtra",
# "metathis",
# "styler",
# "bit64",
# "DT",
# "raster",
# "leaflet",
# "sf",
# "checkmate",
# "janitor",
# "shinytest2",
# "diffviewer",
# "RODBC"
# )

# Install each package using install.packages()

# for (package in packages_to_install) {
# print(paste("Installing package:", package))
# install.packages(package)
# }

# Install "dfeshiny"

# renv::install("dfe-analytical-services/dfeshiny")

# Run renv::restore()
# If it doesn't work first time, maybe try renv::activate() and then renv::restore()

# Library calls ----------------------------------------------------------------------------------

Expand Down Expand Up @@ -128,7 +80,6 @@ appLoadingCSS <- "
}
"

source("R/support_links.R")
source("R/prerun_utils.R")

site_primary <- " https://department-for-education.shinyapps.io/pupil-attendance-in-schools"
Expand Down
Loading

0 comments on commit 2d724a5

Please sign in to comment.