Skip to content

Commit

Permalink
🐜 Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Mar 28, 2020
1 parent 1482953 commit 7b4fd68
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 16 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 <[email protected]>", "MikoΕ‚aj Bochenski <[email protected]>"]
version = "0.4.1"
version = "0.4.2"

[deps]
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Expand Down
21 changes: 16 additions & 5 deletions assets/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class PlutoConnection {
},
redirect: 'follow',
referrerPolicy: 'no-referrer',
//body: "hiiiii"
}).then((response) => {
return response.json()
}).then((response) => {
Expand All @@ -21,14 +20,16 @@ class PlutoConnection {
}

waitForOnline() {
this.currentlyConnected = false
this.onDisconnect()

setTimeout(() => {
this.ping(() => {
if (this.psocket.readyState != WebSocket.OPEN) {
this.waitForOnline()
} else {
this.onConnect()
this.currentlyConnected = true
this.onReconnect()
}
}, () => {
this.waitForOnline()
Expand Down Expand Up @@ -111,6 +112,7 @@ class PlutoConnection {
this.psocket.onopen = () => {
this.send("connect", {})
this.send("getallnotebooks", {})
this.currentlyConnected = true
console.log("socket opened")
onSucces()
}
Expand All @@ -126,14 +128,23 @@ class PlutoConnection {
this.startSocketConnection(() => {
this.onEstablishConnection()
})
}, this.onDisconnect)
}, () => {
this.currentlyConnected = true
this.onDisconnect()
})
}

constructor(onUpdate, onEstablishConnection, onConnect, onDisconnect){
constructor(onUpdate, onEstablishConnection, onReconnect, onDisconnect){
this.onUpdate = onUpdate
this.onEstablishConnection = onEstablishConnection
this.onConnect = onConnect
this.onReconnect = onReconnect
this.onDisconnect = onDisconnect

this.currentlyConnected = false

window.addEventListener("unload", e => {
this.send("disconnect", {})
})
}

// TODO: reconnect with a delay if the last request went poorly
Expand Down
10 changes: 5 additions & 5 deletions assets/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
} */

main {
min-height: calc(100vh - 100px - 4em);
margin: 0 auto;
margin-top: 100px;
min-height: calc(100vh - 100px - 4em);
max-width: 960px;
align-content: center;
padding: 8px;
Expand All @@ -96,7 +96,7 @@
z-index: 20;
background: hsla(0, 100%, 100%, 80%);
width: 100%;
min-height: 70px;
min-height: 60px;
overflow: hidden;
/* white-space: nowrap; */
/*font-weight: normal;*/
Expand All @@ -112,7 +112,7 @@
#logocontainer {
margin: 0 auto;
max-width: 960px;
padding-top: 13px;
padding-top: 10px;
padding-left: 20px;
padding-bottom: 0px;
}
Expand All @@ -134,7 +134,7 @@
display: inline;
border-bottom: none;
font-family: 'Roboto Mono', monospace !important;
font-size: 1.1em;
font-size: 0.8em;
letter-spacing: 1px;
}

Expand All @@ -145,7 +145,7 @@
#printernametitle {
opacity: .6;
font-style: normal;
font-weight: 400;
font-weight: 500;
}

body.disconnected>header {
Expand Down
14 changes: 12 additions & 2 deletions assets/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,27 @@ document.addEventListener("DOMContentLoaded", () => {
}, 3000)
}

function onConnect() {
function onReconnect() {
document.body.classList.remove("disconnected")
document.querySelector("meta[name=theme-color]").content = "#fff"
for (var uuid in window.codeMirrors) {
window.codeMirrors[uuid].options.disableInput = false
}
}

function onDisconnect() {
document.body.classList.add("disconnected")
document.querySelector("meta[name=theme-color]").content = "#DEAF91"
setTimeout(() => {
if(!client.currentlyConnected){
for (var uuid in window.codeMirrors) {
window.codeMirrors[uuid].options.disableInput = true
}
}
}, 5000)
}

window.client = new PlutoConnection(onUpdate, onEstablishConnection, onConnect, onDisconnect)
window.client = new PlutoConnection(onUpdate, onEstablishConnection, onReconnect, onDisconnect)
client.notebookID = notebookID
client.initialize()

Expand Down
2 changes: 0 additions & 2 deletions src/react/WorkspaceManager.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function get_workspace(notebook::Notebook)::Workspace
end

function delete_funcs(notebook::Notebook, to_delete::Set{Symbol})
# TODO: treat methods separately
ws = get_workspace(notebook)
for funcname in to_delete
try
Expand All @@ -69,7 +68,6 @@ function delete_funcs(notebook::Notebook, to_delete::Set{Symbol})
end

function delete_vars(notebook::Notebook, to_delete::Set{Symbol})
# TODO: treat methods separately
ws = get_workspace(notebook)
ws.deleted_vars = ws.deleted_vars βˆͺ to_delete
end
Expand Down
4 changes: 4 additions & 0 deletions src/webserver/Dynamic.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import JSON

# JSON.jl doesn't define a serialization method for MIME objects, so we add one ourselves:
import JSON: lower
JSON.lower(m::MIME) = string(m)

struct UpdateMessage
type::Symbol
message::Any
Expand Down
5 changes: 4 additions & 1 deletion src/webserver/NotebookServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ responses = Dict{Symbol,Function}()
addresponse(f::Function, endpoint::Symbol) = responses[endpoint] = f


"Will _synchronously_ run the notebook server. (i.e. blocking call)"
"""Start a Pluto server _synchronously_ (i.e. blocking call) on `http://localhost:[port]/`.
This will start the static HTTP server and a WebSocket server. Pluto Notebooks will be started dynamically (by user input)."""
function run(port = 1234, launchbrowser = false)
serversocket = Sockets.listen(UInt16(port))
@async HTTP.serve(Sockets.localhost, UInt16(port), stream = true, server = serversocket) do http::HTTP.Stream
Expand Down Expand Up @@ -131,6 +133,7 @@ function run(port = 1234, launchbrowser = false)

if messagetype == :disconnect
delete!(connectedclients, client.id)
close(clientstream)
elseif messagetype == :connect
# nothing more to do
else
Expand Down

2 comments on commit 7b4fd68

@fonsp
Copy link
Owner Author

@fonsp fonsp commented on 7b4fd68 Mar 28, 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/11751

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.4.2 -m "<description of version>" 7b4fd684810c70be4aa6a159b123e75fe0f72f4a
git push origin v0.4.2

Please sign in to comment.