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

Add notebook source preview and export #457

Merged
merged 2 commits into from
Jul 22, 2021
Merged

Conversation

jonatanklosko
Copy link
Member

Closes #101. The .livemd source is a starting point, we will have more export formats.

export.mp4

@@ -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}
Copy link
Contributor

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?

Copy link
Member Author

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
Copy link
Contributor

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?

Copy link
Contributor

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?

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, 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
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

@josevalim josevalim left a 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!

@jonatanklosko jonatanklosko merged commit 6575791 into main Jul 22, 2021
@jonatanklosko jonatanklosko deleted the jk-export-source branch July 22, 2021 23:18
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.

Add buttons to export / download / view source for the whole notebook
2 participants