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

Added serving the output directory if html-based format are selected. #3780

Merged
merged 8 commits into from Jul 30, 2013
Merged

Added serving the output directory if html-based format are selected. #3780

merged 8 commits into from Jul 30, 2013

Conversation

damianavila
Copy link
Member

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.

@@ -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"]:
Copy link
Member

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.

Copy link
Member Author

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.

@Carreau
Copy link
Member

Carreau commented Jul 26, 2013

what about adding the --serve option to nbconvert so that you can chose to serve or not ?

@damianavila
Copy link
Member Author

Yeah, it can be possible, to not force the serve option... I like the idea.

@damianavila
Copy link
Member Author

OK, I follow your comments @Carreau, and now we have a --serve flag fot the command line. ;-)

@jdfreder
Copy link
Member

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?

@damianavila
Copy link
Member Author

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...

@damianavila
Copy link
Member Author

Not ready for review yet...

@damianavila
Copy link
Member Author

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()
Copy link
Member

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 ?

Copy link
Member Author

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...

@Carreau
Copy link
Member

Carreau commented Jul 29, 2013

small comments. I like the --post serve :-)

@damianavila
Copy link
Member Author

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""")

Copy link
Member

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) ?

Copy link
Member Author

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?

Copy link
Member

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..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... no problem ;-)

@damianavila
Copy link
Member Author

Done! ;-)

@Carreau
Copy link
Member

Carreau commented Jul 29, 2013

+1. @jdfreder merge ?

@minrk
Copy link
Member

minrk commented Jul 29, 2013

👍

@jdfreder
Copy link
Member

👍 looks great @damianavila Thanks for the hard work!

jdfreder added a commit that referenced this pull request Jul 30, 2013
Added serving the output directory if html-based format are selected.
@jdfreder jdfreder merged commit c6497ff into ipython:master Jul 30, 2013
@damianavila damianavila deleted the reveal_writer branch July 30, 2013 05:54
@damianavila
Copy link
Member Author

Thanks!

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Added serving the output directory if html-based format are selected.
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

Successfully merging this pull request may close these issues.

None yet

4 participants