Skip to content

DashR does not currently have the get_asset_url method for loading asset URLs like Dash for Python #158

Closed

Description

@HammadTheOne

As originally referenced in a DashR docs issue, Dash for R currently lacks this method which is featured in the Python version. Based on the Python implementation, it would grab the asset URL from the assets directory without needing to specify the exact path.

@rpkyle @HammadTheOne - Do you think we could get a get_asset_url into Dash for R before the next release? Here is the implementation in Python:
https://github.com/plotly/dash/blob/e622f2a31202302d0c305c56e738d1ea369403e6/dash/dash.py#L1559-L1566

If it's not in Dash for R, then we can include it in this example as a helper function.

Originally posted by @chriddyp in https://github.com/plotly/dash-enterprise-docs/pull/95

Activity

  1. self-assigned this
    on Dec 23, 2019
  2. rpkyle commented on Dec 23, 2019

    @rpkyle
    Contributor

    Thanks @HammadTheOne -- I meant to reply earlier; just did that now.

    It's correct to say that Dash for R doesn't have this method, because the function isn't associated with the Dash R6 class, but rather an unexported function in utils.R:

    dashR/R/utils.R

    Lines 583 to 598 in 5f2942c

    get_asset_url <- function(asset_path, prefix = "/") {
    # the subpath is stored in the names attribute
    # of the return object from get_asset_path, so
    # we can retrieve it using names()
    asset <- names(asset_path)
    # strip one or more trailing slashes, since we'll
    # introduce one when we concatenate the prefix and
    # asset path
    prefix <- gsub(pattern = "/+$",
    replacement = "",
    x = prefix)
    # prepend the asset name with the route prefix
    return(paste(prefix, asset, sep="/"))
    }

    @HammadTheOne I can make this change via PR, and will ask you for review.

  3. rpkyle commented on Dec 23, 2019

    @rpkyle
    Contributor

    Thanks @HammadTheOne -- I've responded in the original thread, but I think I'll have to add in a check for the names attribute to make this usable by developers, even if exported. If there is no name associated with the path, the function will infer it from the asset map, otherwise it will use the one passed.

  4. rpkyle commented on Jan 3, 2020

    @rpkyle
    Contributor

    Closed by way of #160.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions