Skip to content
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

chrome_print URL regeneration #113

Open
r2evans opened this issue Jul 5, 2019 · 2 comments
Open

chrome_print URL regeneration #113

r2evans opened this issue Jul 5, 2019 · 2 comments

Comments

@r2evans
Copy link

r2evans commented Jul 5, 2019

Migrated from #97.

I'm sorry for hijacked a completed PR @cderv, I was wondering if the PR was either prematurely merged or something else. I notice a difference in the app's URL (and # handling) when an app is loaded from the dashboard (still with the right nav-bar with info/access/runtime/.../logs) and loaded full-browser ("normal" users). I wonder if there's a way for the app to know this in real-time so that the URL can be generated correctly. Perhaps session$request$SCRIPT_NAME?

Below is the original comment, thanks.


As an aside, @RLesur, the sample app is ignoring leading path information (such as on a reverse-proxied RStudio Connect (RSC)). Something like:

--- app.R.orig  2019-07-03 16:10:34.538559600 -0700
+++ app.R       2019-07-03 15:52:33.365021700 -0700
@@ -14,10 +14,11 @@
   ## browser()
   # get the url
   url <- sprintf(
-    "%s//%s:%s",
+    "%s//%s:%s%s",
     session$clientData$url_protocol,
     session$clientData$url_hostname,
-    session$clientData$url_port
+    session$clientData$url_port,
+    session$clientData$url_pathname
   )
   # Get the inputs
   ## ipt <- reactiveValuesToList(input)

is a start. Unfortunately, in an RSC app it produces the first, when it should be producing the second:

# wrong
https://rsc.server.com/subdir/content/11/?_inputs_&bins=30 
# better
https://rsc.server.com/subdir/#/content/11/?_inputs_&bins=30 

I don't have a fully-functioning RSC-version yet. (I've been hijacking this PR and #91 to learn more about pagedown in shiny. Thanks!)

@RLesur
Copy link
Collaborator

RLesur commented Jul 5, 2019

The only goal of #97 was to enhance chrome_print() to create an async argument which can be used in any context . async = TRUE is required if the user wants to use chrome_print() in a Shiny app.

For instance, one can use this argument in the console

pagedown::chrome_print('https://pagedown.rbind.io/', async = TRUE)
#> <Promise [pending]>

When async = FALSE, the R session holds until chrome_print() terminates.

The chrome_print() function does not handle URLs. If an URL is provided through its input argument, this URL is taken as-is.
IMO, this point should be addressed in a dedicated vignette as @cderv suggests in #114

@r2evans
Copy link
Author

r2evans commented Jul 5, 2019

I see what you mean, the code above is specific to the example you posted in the previous issue and pull. I understand, and 114 is the right place to discuss it. I understand the purpose of async= and interpreted the shiny implications the same way.

I believe my use-case is just a little different from your previous example, so it might not be as immediate for me: in your case, you want a PDF version of the current app, widgets/controls and all; in my case, I believe that for each app.R, I will likely have a report.Rmd (parameterized, of course). Whether I use rmarkdown::render or rely on RSC to handle serving it is up for trial-and-debate.

Thanks for the discussion, I don't know that I need to keep this issue open, feel free to close if you think it best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants