I would like to know if it is possible to extract the URL created by the Shiny Bookmark button? I know the Bookmark button is a special action button that can create a URL documenting all the input fields of a Shiny app. In addition to the default behavior, I want to save this URL to my Shiny app for further applications.
My ultimate goal is to see if I can feed in the Bookmark URL to the urlshorteneR
package to create a shorten URL and report back to the users. When the Shiny app contains a lot of input fields, the Bookmark URL becomes lengthy. This is why I think it would be handy to be able to shorten the URL automatically.
Below is an example. The following script is an example from the enableBookmarking
documentation. I uploaded it to the shinyapps.io
and created this link (https://yuchenw.shinyapps.io/Bookmark_Example/).
# Basic example with state encoded in URL
ui <- function(request) {
fluidPage(
textInput("txt", "Text"),
checkboxInput("chk", "Checkbox"),
bookmarkButton()
)
}
server <- function(input, output, session) { }
enableBookmarking("url")
shinyApp(ui, server)
Now if I want to save a state that the Checkbox
is TRUE
. I can click the Bookmark button and copy the URL (https://yuchenw.shinyapps.io/Bookmark_Example/?inputs&chk=true&txt=%22%22).
After that, I can use the urlshorteneR
package to shorten the URL as follows.
library(urlshorteneR)
url <- "https://yuchenw.shinyapps.io/Bookmark_Example/?_inputs_&chk=true&txt=%22%22"
isgd_LinksShorten(longUrl = url, showRequestURL = TRUE)
This works well. It would be great if I can extract the Bookmark URL and automate this process. Thankr you in advance for any help or suggestions.