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
Added serving the output directory if html-based format are selected. #3780
Conversation
@@ -210,6 +210,10 @@ def convert_notebooks(self): | |||
self.writer.write(output, resources, notebook_name=notebook_name) | |||
conversion_success += 1 | |||
|
|||
# If export_format is html-based, then serve the output directory | |||
if self.export_format in ["basic_html", "full_html", "reveal"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure for basic and full_html, reveal is pecial in the sens that it needs to be served to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, for reveal is necessary... for basic and full is dispensable... do you suggest to only serve reveal? I have no problems to eliminate basic and full, but I like the integral approach to serve all the html-based files... anyway no problems if I have to change it.
what about adding the --serve option to nbconvert so that you can chose to serve or not ? |
Yeah, it can be possible, to not force the serve option... I like the idea. |
OK, I follow your comments @Carreau, and now we have a |
Hi @damianavila , I add the notion of post-processors in #3784 (after a discussion with @ellisonbg and @fperez ). Right now I only have a PDF post-processor (but it should suffice as a decent example). I think this would fit better into the framework as a post-processor, would you mind taking a look at that and telling me what you think? |
You are right... fit better with post-processor (when I read yesterday your pdf post-processor it was inherited from writer class... jeje, how fast this is evolving ;-)... one of the problems of living away, I am always behind...). OK, I will look into it and make the proper changes... |
Not ready for review yet... |
OK, ready for review ;-) |
sa = httpd.socket.getsockname() | ||
print("Serving " + input[2:] + " on http://" + sa[0] + ":" + str(sa[1])) | ||
print("Use Control-C to stop this server.") | ||
httpd.serve_forever() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
want to use webbrowser package to open the browser automatically ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea, I will do the modification...
small comments. I like the |
Done! Now serve open a new tab (in your default browser) containing your "ready-to-go" slideshow. ;-) |
build_directory = Unicode(".", config=True, | ||
help="""Directory to write output to. Leave blank | ||
to output to the current directory""") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one last comment (yes I am annoying) open_in_browser = Bool(True, config=True)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He... your comments are always welcome ;-) but I don't catch your idea...
Something like:
if open_in_browser:
webbrowser.open(url, new=2)
to make the open configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes , like IPython notebook. But you forgot the self.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah... no problem ;-)
Done! ;-) |
+1. @jdfreder merge ? |
👍 |
👍 looks great @damianavila Thanks for the hard work! |
Added serving the output directory if html-based format are selected.
Thanks! |
Added serving the output directory if html-based format are selected.
OK, the rational: reveal, and the other html-based formats were born to be viewed in the browser, so I added a new
serve
function inside the FilesWriter class and I am calling it from Nbconvertapp only when the "reveal", "basic_html" or "full_html" are requested.In this way, the user have immediately access to the served
localhost:8000
and can see their reveal slideshow (or the other html-based files) in one step.Cheers.
Damián.
Update
I changed the implementation... now you have a
--serve
flag to call from command line, in this way you are not forced to serve the build directory, it is an option.To achieve this, I subclass the FileWriter class to add a serve function (not implemented in the FIleWriter class to avoid the serve of the build directory when the flag is not present.
Update
Now
--post serve
call a serve post processor.Thanks.