diff --git a/CHANGELOG.md b/CHANGELOG.md index 0691bbd8..a3321076 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,11 @@ All notable changes to `dash` will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [0.9.0] - 2020-10-31 +## [0.9.1] - 2020-11-16 +### Fixed +- A regression which prevented favicons from displaying properly has been resolved, and a default Dash favicon is now supplied when none is provided in the `assets` directory. [#240](https://github.com/plotly/dashr/pull/240) +## [0.9.0] - 2020-10-31 ### Fixed - Fixes a minor bug in `setCallbackContext` (described in [#236](https://github.com/plotly/dashR/issues/236)) which prevented pattern-matching callbacks from working properly if one or more `input` statements did not include a selector. [#237](https://github.com/plotly/dashR/pull/237) diff --git a/DESCRIPTION b/DESCRIPTION index dfabe490..aa522f42 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dash Title: An Interface to the Dash Ecosystem for Authoring Reactive Web Applications -Version: 0.9.0 +Version: 0.9.1 Authors@R: c(person("Chris", "Parmer", role = c("aut"), email = "chris@plotly.com"), person("Ryan Patrick", "Kyle", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5829-9867"), email = "ryan@plotly.com"), person("Carson", "Sievert", role = c("aut"), comment = c(ORCID = "0000-0002-4958-2844")), person("Hammad", "Khan", role = c("aut"), comment = c(ORCID = "0000-0003-2479-9841"), email = "hammadkhan@plotly.com"), person(family = "Plotly Technologies", role = "cph")) Description: A framework for building analytical web applications, Dash offers a pleasant and productive development experience. No JavaScript required. Depends: diff --git a/R/dash.R b/R/dash.R index bca7936c..fc30660f 100644 --- a/R/dash.R +++ b/R/dash.R @@ -116,7 +116,7 @@ Dash <- R6::R6Class( # ------------------------------------------------------------ router <- routr::RouteStack$new() server$set_data("user-routes", list()) # placeholder for custom routes - + # ensure that assets_folder is neither NULL nor character(0) if (!(is.null(private$assets_folder)) & length(private$assets_folder) != 0) { if (!(dir.exists(private$assets_folder)) && gsub("/+", "", assets_folder) != "assets") { @@ -494,13 +494,17 @@ Dash <- R6::R6Class( } TRUE }) - dash_favicon <- paste0(self$config$routes_pathname_prefix, "_favicon.ico") route$add_handler("get", dash_favicon, function(request, response, keys, ...) { asset_path <- get_asset_path(private$asset_map, "/favicon.ico") + # If custom favicon is not present, get the path for the default Dash favicon + if (is.na(names(asset_path))) { + asset_path <- system.file("extdata", "favicon.ico", package = "dash") + } + file_handle <- file(asset_path, "rb") response$body <- readBin(file_handle, raw(), @@ -1891,9 +1895,11 @@ Dash <- R6::R6Class( # create tag for favicon, if present # other_files_map[names(other_files_map) %in% "/favicon.ico"] if ("/favicon.ico" %in% names(private$asset_map$other)) { - favicon <- sprintf("") + favicon_url <- sprintf('\"%s_favicon.ico\"', self$config$requests_pathname_prefix) + favicon <- sprintf("", favicon_url) } else { - favicon <- "" + favicon_url <- sprintf('\"%s_favicon.ico\"', self$config$requests_pathname_prefix) + favicon <- sprintf("", favicon_url) } # set script tag to invoke a new dash_renderer @@ -1901,7 +1907,6 @@ Dash <- R6::R6Class( "_dash-renderer", "application/javascript", "var renderer = new DashRenderer();") - # add inline tags scripts_inline <- private$inline_scripts @@ -1961,24 +1966,6 @@ Dash <- R6::R6Class( private$.index <- private$template_index } - # define the react-entry-point - app_entry <- "
Loading...
" - # define the dash default config key - config <- sprintf("", to_JSON(self$config)) - - if (is.null(private$name)) - private$name <- 'Dash' - - if (!is.null(private$custom_index)) { - string_index <- glue::glue(private$custom_index, .open = "{%", .close = "%}") - - private$.index <- string_index - } - - else if (length(private$template_index) == 1) { - private$.index <- private$template_index - } - else { private$.index <- sprintf( ' diff --git a/inst/extdata/favicon.ico b/inst/extdata/favicon.ico new file mode 100644 index 00000000..465bf587 Binary files /dev/null and b/inst/extdata/favicon.ico differ diff --git a/tests/testthat/test-attributes.R b/tests/testthat/test-attributes.R index 11978254..78341fb4 100644 --- a/tests/testthat/test-attributes.R +++ b/tests/testthat/test-attributes.R @@ -4,7 +4,7 @@ test_that("stylesheets can be added with or without attributes", { library(dashHtmlComponents) stylesheet_pattern <- '^.*.*$' script_pattern <- '^.*", - "", + c("", + "", "" ) ) @@ -72,20 +72,20 @@ test_that("stylesheets can be added with or without attributes", { ) ) ) - + app$layout(htmlDiv( "Hello world!" ) ) - + request_with_attributes <- fiery::fake_request( "http://127.0.0.1:8050" ) - + # start up Dash briefly to generate the index app$run_server(block=FALSE) app$server$stop() - + response_with_attributes <- app$server$test_request(request_with_attributes) tags_by_line <- lapply(strsplit(response_with_attributes$body, "\n "), function(x) trimws(x))[[1]] @@ -110,7 +110,7 @@ test_that("stylesheets can be added with or without attributes", { "&m=", modtime) - all_tags <- glue::glue("", - "", + "", + "", "" ) ) @@ -156,7 +156,7 @@ test_that("invalid attributes trigger an error", { ) ) - expect_error(dash:::assertValidExternals(external_scripts, external_stylesheets), + expect_error(dash:::assertValidExternals(external_scripts, external_stylesheets), "The following script or stylesheet attributes are invalid: baz, foo, bar.") }) @@ -170,10 +170,10 @@ test_that("not passing named attributes triggers an error", { "moredata" ) ) - + external_scripts <- list() - expect_error(dash:::assertValidExternals(external_scripts, external_stylesheets), + expect_error(dash:::assertValidExternals(external_scripts, external_stylesheets), "Please verify that all attributes are named elements when specifying URLs for scripts and stylesheets.") }) @@ -228,7 +228,7 @@ test_that("passing a list with no href/src fails", { library(dashHtmlComponents) stylesheet_pattern <- '^.*.*$' script_pattern <- '^.*