-
Notifications
You must be signed in to change notification settings - Fork 423
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
Add notebook source preview and export #457
Conversation
lib/livebook/session.ex
Outdated
@@ -410,6 +418,11 @@ defmodule Livebook.Session do | |||
{:reply, summary_from_state(state), state} | |||
end | |||
|
|||
def handle_call(:get_notebook_source, _from, state) do | |||
content = LiveMarkdown.Export.notebook_to_markdown(state.data.notebook) | |||
{:reply, content, state} |
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.
I am wondering if we should return the data and do the conversion on the client to avoid blocking the server?
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.
Good call, copying is cheaper. Also having the data we can export it into any other format without involving the session!
@@ -0,0 +1,66 @@ | |||
defmodule LivebookWeb.SessionLive.ExportComponent do |
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.
Curiosity: does this need to be a live component?
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.
I guess we want to take a snapshot at the moment we press export? 🤔 hence it having its own state?
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, we need to make sure to only load the content from session once.
@@ -34,6 +34,8 @@ defmodule LivebookWeb.Router do | |||
live "/sessions/:id/settings/runtime", SessionLive, :runtime_settings | |||
live "/sessions/:id/settings/file", SessionLive, :file_settings | |||
live "/sessions/:id/bin", SessionLive, :bin | |||
live "/sessions/:id/export", SessionLive, :export | |||
get "/sessions/:id/export/download", SessionController, :download_source |
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.
We will likely have different URLs per export. But it is fine, we can namespace them later.
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.
Definitely, maybe format as URL parameter.
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.
Some questions but no blockers!
Closes #101. The .livemd source is a starting point, we will have more export formats.
export.mp4