Skip to content

Commit

Permalink
🦊 Browser compat fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed May 20, 2020
1 parent 1ee7804 commit 9c61c4a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 81 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.9.1"
version = "0.9.2"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
7 changes: 6 additions & 1 deletion assets/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,13 @@ function rewrittenError(old_raw) {
return new_raw
}

// move up the dom tree until the tag is found
function parentByTag(el, tag) {
return (!el || el.tagName == tag) ? el : parentByTag(el.parentElement, tag)
}

function errorHint(e) {
const cellNode = e.path.find(el => el.tagName == "CELL")
const cellNode = parentByTag(e.target, "CELL")
wrapInBlock(window.codeMirrors[cellNode.id], "begin")
requestChangeRemoteCell(cellNode.id)
e.preventDefault()
Expand Down
8 changes: 7 additions & 1 deletion assets/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@ function render_notebooklist(list) {

/* RUN & SHUT DOWN IN BACKGROUND */

// move up the dom tree until the tag is found
function parentByTag(el, tag) {
return (!el || el.tagName == tag) ? el : parentByTag(el.parentElement, tag)
}

function onSessionClick(event) {
const li = event.path.find(el => el.tagName == "LI")
console.log
const li = parentByTag(event.target, "LI")
if(li.classList.replace("running", "transitioning")) {
if (confirm("Shut down notebook process?")) {
client.send("shutdownworkspace", {
Expand Down
22 changes: 2 additions & 20 deletions src/notebookserver/Client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,10 @@ function clientupdate_cell_folded(notebook::Notebook, cell::Cell, folded::Bool;
end

function clientupdate_notebook_list(notebooks; initiator::Union{Initiator,Missing}=missing)

short_paths = Dict()

notebookpaths = map(values(notebooks)) do notebook
pathsep = Sys.iswindows() ? '\\' : '/'
path_split = split(notebook.path, pathsep)
if path_split[1] == ""
path_split = path_split[2:end]
end
NotebookPath(notebook.uuid, path_split, "", -1)
end

make_paths_distinct!(Set(notebookpaths))

short_paths = Dict(map(notebookpaths) do np
np.uuid => np.current_path
end...)

update = UpdateMessage(:notebook_list,
Dict(:notebooks => [Dict(
:uuid => string(notebook.uuid),
:uuid => notebook.uuid,
:path => notebook.path,
:shortpath => short_paths[notebook.uuid]
:shortpath => basename(notebook.path)
) for notebook in values(notebooks)]), nothing, nothing, initiator)
end
58 changes: 0 additions & 58 deletions src/webserver/Dynamic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,64 +25,6 @@ function serialize_message(message::UpdateMessage)
sprint(serialize_message_to_stream, message)
end




"To be used in `make_paths_distinct!`"
mutable struct NotebookPath
uuid
path_split
current_path
current_depth
end

function count_occurances(vals)
counts = Dict()
for v in vals
old = get(counts, v, 0)
counts[v] = old + 1
end
counts
end

"""For internal use. Takes a Set of `NotebookPath`s and gives each a short path (e.g. `to/file.jl` from `/path/to/file.jl`), with the guarantee that all final short paths will be distinct.
For example, the set
`/a/b/c.jl`, `/a/P/c.jl`, `/Q/b/c.jl`, '/a/b/R.jl'
will become
`/a/b/c.jl`, `P/c.jl`, `/Q/b/c.jl`, 'R.jl'"""
function make_paths_distinct!(notebookpaths::Set{NotebookPath})
counts = count_occurances(np.current_path for np in notebookpaths)
for (current_path, count) in counts
if count == 1 && !isempty(current_path)
# done!
else
# these need to be made distinct by extending their paths

not_yet_distinct = filter(notebookpaths) do np
np.current_path == current_path
end

for np in not_yet_distinct
np.current_depth += 1
np.current_path = joinpath(np.path_split[end-np.current_depth : end]...)
if np.current_depth == length(np.path_split) - 1
delete!(not_yet_distinct, np)
if !Sys.iswindows()
np.current_path = '/' * np.current_path
end
end
end

make_paths_distinct!(not_yet_distinct)
end
end
end


function change_cellinput!(notebook, cell, newcode; initiator::Union{Initiator, Missing}=missing)
# i.e. Ctrl+Enter was pressed on this cell
# we update our `Notebook` and start execution
Expand Down

2 comments on commit 9c61c4a

@fonsp
Copy link
Owner Author

@fonsp fonsp commented on 9c61c4a May 20, 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/15077

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.9.2 -m "<description of version>" 9c61c4a95a5775c27aed66a63625d6ad3fa5724d
git push origin v0.9.2

Please sign in to comment.