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

New runtime option nbReload to reload the page if open ? #135

Open
Kiloneie opened this issue Sep 22, 2022 · 5 comments
Open

New runtime option nbReload to reload the page if open ? #135

Kiloneie opened this issue Sep 22, 2022 · 5 comments

Comments

@Kiloneie
Copy link

Currently nbShow opens the file in the browser after c -r, but it does not care if it is already opened, so it always opens up a new instance. Would it be possible to have a nbReload option that would reload the page instead ? Or even open the page if it's not open, and then reload on it's subsequent runs ?

@HugoGranstrom
Copy link
Collaborator

I'm not sure how this would be done, nimib would somehow have to know that a browser has the file open and then somehow request the browser to reload the page. I'm not sure if that's possible (in a simple, portable way for all browsers). There are options for you, though:

  1. Only use --nbShow on the first run and then run without it the subsequent times and reload the same page it previously opened manually.
  2. Use an automatically reloading local server (I use Live Server for VSCodium) and open the resulting HTML file using it. When you later rebuild (without --nbShow) the file, the server will notice that the HTML file has been changed and reload the page automatically for you.
  3. If you are using VSCodium/VSCode, there is a plugin nimiBoost which lets you preview the document in a preview window inside the editor. (It opens a new window each time though, but it's easier to deal with there)

@Kiloneie
Copy link
Author

Live Server extension works exactly how i wanted it, thank you.

@pietroppeter
Copy link
Owner

in principle I think there should be a way to this in nimib without relying on an external plugin. We would need to serve the file through localhost, watch for changes and serve again. not sure if a runtime option is the best way* to do that (if it is I might want to call it --nbServe), but I guess we could keep open this issue for further brainstorming.

An automatic reload is indeed something missing in nimib that would help iterating on a document. I do not use that extension (nice to know it exists) and end up having tons of tabs open...

*although I cannot resist thinking how to implement this with a runtime option:

  • if --nbServe is given then after saving the html instead of opening the browser the system should launch a small (nim) webserver that serves the static file and watches for changes
  • the issue is where we find this webserver, I guess there are a few of them already present around that could be added as dependency, not sure if any of them has also a watch functionality

@pietroppeter pietroppeter reopened this Sep 23, 2022
@dlesnoff
Copy link
Contributor

Can we run a small local server with node.js maybe ?
Github uses Jekyll (Ruby).
I am not sure if we should add them as a dependency. We can simply recommend users to use their favorite one and give some examples in the README.md. It is still more a comfort feature than something mandatory.
I am attached to a low count of packages and dependencies.

@pietroppeter
Copy link
Owner

pietroppeter commented Mar 10, 2023

Defintely not with nodejs ;), but likely with a simple Nim server like nimhttpd + some watch mechanism. I am not sure if this use case warrants for something more than that.

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

4 participants