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

Testing server feature and auto mode on/off - using the knit button #481

Closed
cderv opened this issue Oct 7, 2020 · 5 comments
Closed

Testing server feature and auto mode on/off - using the knit button #481

cderv opened this issue Oct 7, 2020 · 5 comments

Comments

@cderv
Copy link
Collaborator

cderv commented Oct 7, 2020

@yihui I wanted to share the workflow of what I tested so far to see if this is the correct behavior for you.

How it works for me

  • Open a blogdown project (default one from Create Project)
  • This will open a server:
    • blogdown:::preview_site(startup = TRUE) is ran in the console
    • The website opens in the viewer on homepage
  • Modify a Rmd post and save
  • With a delay the very first time, this is printed and the post is rendered
# printed in the console
Rendering content/post/2015-07-23-r-rmarkdown.Rmd... Done.
  • The edited post is not shown in the Viewer - I was under the impression that --navigateToChanged would have lead to that (from 104c41a) - Related to Website in Viewer is updated before Rmd rendering #486

  • navigating the website to the page in Viewer

  • Re modidying the Rmd post and saving. This is printed to the console

Rendering content/post/2015-07-23-r-rmarkdown.Rmd... Done.

The website in the viewer does not update, while the page is correctly opened. Unexpected ? Related to #486 Edit: It works now !

  • Opening the website in the browser by clicking "show in new window".
  • Remodifying the Rmd post 8and saving. Third output
    Rendering content/post/2015-07-23-r-rmarkdown.Rmd... Done.
    
  • Navigating in the post in the browser - last edit is shown.
  • Re modifying and saving. Another output:
Rendering content/post/2015-07-23-r-rmarkdown.Rmd... Done.

Browser is updated to last change I just made BUT Viewer is updated with previous to last change like above. Odd !! See #486 Edit: Also working now !

  • Stoping the server now: blogdown::stop_server().

    • No message and both browser and Viewer are still showing the website
    • But... hugo server is down.
    • If I try to reload the page... it fails as not hugo server.
    • Could we manage to close preview website somehow ? At least in the Viewer? It could be misleading that stop_server() output nothing and both website were still on5
  • Trying a dummy thing while hugo server is off: Re modifying the file and Saving...
    It still output in the console that it renders the Rmd
    Is this expected while we have stopped servers ? Edit: This has been addressed in PR Stop watching and building Rmd if server is stopped #488

And what about knitting the Rmd file directly ?

  • This opens Rmarkdown pane and shows
==> rmarkdown::render_site('C:/Users/chris/Documents/test-blogdown/content/post/2015-07-23-r-rmarkdown.Rmd',  encoding = 'UTF-8');
Rendering content/post/2015-07-23-r-rmarkdown.Rmd... Done.
  • while in console I got a new startup server opened but also a failed call to preview_site Edit: This is fixed in 0.20.14, I now got correctly
> blogdown:::preview_site()
Launching the server via the command:
  C:\Users\chris\AppData\Roaming\Hugo\hugo.exe server --bind 127.0.0.1 -p 4321 --themesDir themes -t hugo-lithium -D -F --navigateToChanged
Serving the directory . at http://127.0.0.1:4321
Launched the hugo server in the background (process ID: 46256). To stop it, call blogdown::stop_server() or restart the R session.
  • Re modifying the Rmd and saving, prints a message about clicking on the knit button... (I did not click the Knit button here)

I believe knit.on_save is still TRUE in this workflow because stopping server did not stop the watching. Edit: This is also fixed by #488

  • Knitting again rethrow the error with preview_site Edit: No more error in preview_site after installing Rmarkdown 2.4.2 (We require rmarkdown in dev version #483)
  • Re modifying and saving did not rerendered (because blogdown.knit.on_save = FALSE has been set as stated in the previous message)

~Note: in the middle of that, the website still open in my browser that I reloaded ealier and was failing; reloaded to the page I was editing : a delay in navigateToChanged ?~Edit: Also fixed

Some stuff above did not happened as I was expecting them to.
What do you think about that ? Did it work smoothly for you ?
Is it windows specific ? I did not try yet on Linux.

@cderv
Copy link
Collaborator Author

cderv commented Oct 8, 2020

I rerun the worflow with last version - some issue were fixed but other are still there

@cderv

This comment has been minimized.

@yihui
Copy link
Member

yihui commented Oct 9, 2020

The root cause of most problems in this issue is that --navigateToChanged is not supported well yet. I'll address these problems in #486.

The one below is different, so a separate reply:

  • Could we manage to close preview website somehow ? At least in the Viewer? It could be misleading that stop_server() output nothing and both website were still on

I could make the Viewer display something (e.g. saying that the server has been stopped), but I'm not sure if it's worth the effort, because this problem is not specific to blogdown. The content of the Viewer is always preserved when the R session is restarted, no matter whether the page is actually still alive.

If I were to display something at the end of stop_server() (e.g. I could run servr::browse_last() to show a dead site), but this will only work for RStudio Viewer, because RStudio Viewer doesn't have tabs like web browsers (only a single tab). If I open a new page to show the server has been stopped, it will just be displayed in the Viewer. However, it's hard to know if the user is actually using the Viewer or just a web browser. If she is using the latter, there isn't a way for me to shut down the page she was viewing previously and replace it with a page that says the server has been stopped. It's only possible to open a new tab (again, I don't know if I should open a browser tab, or open the Viewer).

If the user called stop_server() explicitly, I don't think she would be surprised that the page is actually dead even though it appears alive. If she restarted R, she will either discover that the page is dead soon, or see the website launched again (this is the default behavior). Either way, I feel this is a relatively small issue, but needs non-trivial effort to address it well. Actually, to address it well, I feel the work needs to be done in Hugo. It could use some JavaScript to gray out the page (like Shiny apps) after the server is shut down.

@cderv
Copy link
Collaborator Author

cderv commented Oct 9, 2020

Ok I have just updated the post above. Most of the issues has now been resolved and we have a more smooth workflow.

There is still the last issue you've replied separatly. I completly understand your point.

What about a message after blogdown::stop_server() that the server as indeed correctly been stopped ? Just a confirmation ?
We get a message when we start the server, when a Rmd file is rendered , but currently no message when stopping. That would confirm that the server is stopped, even if brower or viewer are still opened to last page.

If you don't think it is a good idea, we leave it like that and we can clause this issue I think.

@yihui
Copy link
Member

yihui commented Oct 9, 2020

Sounds like a good idea. I'll add a message. Thanks for the suggestion!

@yihui yihui closed this as completed in 0d75cb0 Oct 9, 2020
yihui pushed a commit that referenced this issue Oct 12, 2020
…nput_as_dir (#483)

to get rstudio/rmarkdown@6c5ea83 that should fix one issue described in #481 (pressing Knit triggers an error because RStudio detects "C:" as the project root for some reason when the actual root is in a directory of the C: drive)
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