Skip to content

Commit

Permalink
support for standard Pluto
Browse files Browse the repository at this point in the history
  • Loading branch information
schlichtanders committed Sep 11, 2024
1 parent 66662c7 commit 9385df9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JolinPluto"
uuid = "5b0b4ef8-f4e6-4363-b674-3f031f7b9530"
authors = ["Stephan Sahm <[email protected]> and contributors"]
version = "0.1.88"
version = "0.1.89"

[deps]
AbstractPlutoDingetjes = "6e696c72-6542-2067-7265-42206c756150"
Expand Down
11 changes: 6 additions & 5 deletions ext/PythonCallExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,17 @@ end
# ipywidgets support
# ==================

# global initialization needed for ipywidgets - this is now also included in Pluto base, so no need for this here any longer
# the downside was that on reload, this was not really executed in the correct order.
# still somewhen it would be nice for a package like this to create a __pluto_init__ hook or similar to ingest this in a more modular way
# Something similar to IPyWidget_init() is now also included in Jolin's Pluto base.
# (The downside was that on reload, this was not really executed in the correct order.
# still somewhen it would be nice for a package like this to create a __pluto_init__ hook or similar to ingest this in a more modular way)
# In anyway, JolinPluto is meant to support standard Pluto too, so it is important for it to be accessible and useful from standard Julia Pluto.

"""
IPyWidget_init()
Initialize javascript for ipywidgets to work inside Pluto.
"""
IPyWidget_init() = @htl """
JolinPluto.IPyWidget_init() = @htl """
<!-- Load RequireJS, used by the IPywidgets for dependency management -->
<script
src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"
Expand Down Expand Up @@ -130,7 +131,7 @@ function Base.show(io::IO, m::MIME"text/html", w::JolinPluto.IPyWidget)
div.value = $(pyconvert(Any, w.widget.value))
if((window.require == null) || window.specified){
div.innerHTML = '<p>Could not find ipywidgets javascript dependencies. This should not happen, please contact <a href="mailto:[email protected]">[email protected]</a>. </p>'
div.innerHTML = '<p>⚠️ Activate ipywidgets by running the following once inside Pluto ⚠️ <pre><code>using Jolin # or using JolinPluto<br/>IPyWidget_init() # <-- this is important</code></pre> </p>'
}
// TODO renderWidgets(div) has the advantage that no duplicates appear
Expand Down
2 changes: 1 addition & 1 deletion src/JolinPluto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export Setter, @get, @cell_ids_create_wrapper, @cell_ids_push!
export cell_ids_create_wrapper, cell_ids_push!, cell_ids_push
export MD, format_html, _HTML
export viewof
export IPyWidget
export IPyWidget, IPyWidget_init

using Dates, HTTP, JSON3, Git, JWTs, UUIDs, Base64
using HypertextLiteral, Continuables
Expand Down
1 change: 1 addition & 0 deletions src/languages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function lang_get_global end

# Python specific stuff

function IPyWidget_init() end

# this is defined here so that it can also be used in standard Pluto and Julia notebooks which may use ipywidgets
"""
Expand Down

0 comments on commit 9385df9

Please sign in to comment.