ramnathv/rNotebook

Add support for passing gist id as parameter

Opened this issue · 1 comments

For example, http://ramnathv.github.io/rNotebook/?c06d4f0488af3dbdedc4 should automatically load the contents of the gist.

I can extend this to load urls as well. The code is already there in ace-shiny.js, but needs to be cleaned up a bit.

This should be done for both the Shiny and OpenCPU versions of the notebook.

For the Shiny version, I can use parseQueryString which makes it easy to return key value pairs of the query string. I can combine this with the clientData parameter introduced in Shiny, which makes it easy to retrieve information about the URL.

shinyServer(function(input, output, clientData) {

  # Return the components of the URL in a string:
  output$urlText <- renderText({
    paste(sep = "",
      "protocol: ", clientData$url_protocol, "\n",
      "hostname: ", clientData$url_hostname, "\n",
      "pathname: ", clientData$url_pathname, "\n",
      "port: ",     clientData$url_port,     "\n",
      "search: ",   clientData$url_search,   "\n"
    )
  })

  # Parse the GET query string
  output$queryText <- renderText({
    query <- parseQueryString(clientData$url_search)

    # Return a string with key-value pairs
    paste(names(query), query, sep = "=", collapse=", ")
  })
})