Skip to content

Favicon fix #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- Fixed a `favicon` response console error issue by adding a default favicon for Dash apps. [#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)

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"), person("Ryan Patrick", "Kyle", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5829-9867"), email = "[email protected]"), 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 = "[email protected]"), 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:
Expand Down
30 changes: 8 additions & 22 deletions R/dash.R
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -1893,15 +1897,15 @@ Dash <- R6::R6Class(
if ("/favicon.ico" %in% names(private$asset_map$other)) {
favicon <- sprintf("<link href=\"/_favicon.ico\" rel=\"icon\" type=\"image/x-icon\">")
} else {
favicon <- ""
favicon_url <- sprintf('\"%s_favicon.ico\"', self$config$requests_pathname_prefix)
favicon <- sprintf("<link href=%s rel=\"icon\" type=\"image/x-icon\">", favicon_url)
}

# set script tag to invoke a new dash_renderer
scripts_invoke_renderer <- sprintf("<script id=\"%s\" type=\"%s\">%s</script>",
"_dash-renderer",
"application/javascript",
"var renderer = new DashRenderer();")

# add inline tags
scripts_inline <- private$inline_scripts

Expand Down Expand Up @@ -1961,24 +1965,6 @@ Dash <- R6::R6Class(
private$.index <- private$template_index
}

# define the react-entry-point
app_entry <- "<div id='react-entry-point'><div class='_dash-loading'>Loading...</div></div>"
# define the dash default config key
config <- sprintf("<script id='_dash-config' type='application/json'> %s </script>", 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(
'<!DOCTYPE html>
Expand Down
Binary file added inst/extdata/favicon.ico
Binary file not shown.