Skip to content

Commit

Permalink
πŸ¦‰ Fix #45 and #55 and #57
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Apr 4, 2020
1 parent 6da9543 commit 8489fc1
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Pluto"
uuid = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
license = "MIT"
authors = ["Fons van der Plas <fonsvdplas@gmail.com>", "MikoΕ‚aj Bochenski <iceflamecode@gmail.com>"]
version = "0.5.10"
version = "0.5.11"

[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
5 changes: 5 additions & 0 deletions assets/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ class PlutoConnection {
}
this.psocket.onopen = () => {
this.sendreceive("connect", {}).then(u => {
if(this.notebookID && !u.message.notebookExists){
// https://github.com/fonsp/Pluto.jl/issues/55
document.location.href = "/"
return
}
this.currentlyConnected = true
console.log("socket opened")
onSucces()
Expand Down
8 changes: 7 additions & 1 deletion assets/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,13 @@ document.addEventListener("DOMContentLoaded", () => {
})

Promise.all(promises).then(() => {
document.body.classList.remove("loading")
// We do a code completion request to trigger starting the workpsace
client.sendreceive("complete", {
query: "nothinginparticular"
}).then(() => {
document.body.classList.remove("loading")
console.info("Workspace initialized")
})
})
}).catch(console.error)

Expand Down
8 changes: 8 additions & 0 deletions assets/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ celloutput p:last-child {


/* HEADER */
header {
transition: background-color .5s ease-in-out;
background-color: white;
}

body.loading header {
background-color: hsla(290, 10%, 59%, 0.14);
}


/* MAIN */
Expand Down
25 changes: 23 additions & 2 deletions src/notebookserver/Notebook.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,38 @@ function load_notebook(io, path)
end

function load_notebook(path::String)
backupPath = path
while isfile(backupPath)
backupPath = backupPath * ".backup"
end
cp(path, backupPath)

local loaded
open(path, "r") do io
load_notebook(io, path)
loaded = load_notebook(io, path)
end

save_notebook(loaded)

if only_versions_differ(path, backupPath)
rm(backupPath)
else
@warn "Old Pluto notebook might not have loaded correctly. Backup saved to: " backupPath
end

loaded
end

function move_notebook(notebook::Notebook, newpath::String)
# Will throw exception and return if anything goes wrong, so at least one file is guaranteed to exist.
oldpath = notebook.path
save_notebook(notebook, oldpath)
save_notebook(notebook, newpath)
@assert read(notebook.path, String) == read(newpath, String)
@assert only_versions_differ(oldpath, newpath)
notebook.path = newpath
rm(oldpath)
end

function only_versions_differ(pathA::AbstractString, pathB::AbstractString)
readlines(pathA)[3:end] == readlines(pathB)[3:end]
end
2 changes: 1 addition & 1 deletion src/webserver/Dynamic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ end


responses[:connect] = (body, notebook=nothing; initiator::Union{Initiator, Missing}=missing) -> begin
putclientupdates!(initiator, UpdateMessage(:πŸ‘‹, Dict(), nothing, nothing, initiator))
putclientupdates!(initiator, UpdateMessage(:πŸ‘‹, Dict(:notebookExists => (notebook != nothing)), nothing, nothing, initiator))
end

responses[:getversion] = (body, notebook=nothing; initiator::Union{Initiator, Missing}=missing) -> begin
Expand Down

2 comments on commit 8489fc1

@fonsp
Copy link
Owner Author

@fonsp fonsp commented on 8489fc1 Apr 4, 2020

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/12252

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.11 -m "<description of version>" 8489fc1851b591ae17b195acf6f3697180f1141d
git push origin v0.5.11

Please sign in to comment.