👀 Reading hidden code
using HypertextLiteral
: @htl, @htl_str
h (generic function with 1 method)
👀 Reading hidden code
embed_pluto_notebook (generic function with 1 method)
👀 Reading hidden code
@htl """
<div class="embed-pe">
<pluto-editor
id=$("pe-$(rand(1:1000000))")
$(kwargs)
>
</pluto-editor>
</div>
<style>
.embed-pe {
height: 300px;
overflow-y: auto;
border-radius: 4px;
}
</style>
"""
end
👀 Reading hidden code
# embed_pluto_notebook(;
# notebookfile="https://featured.plutojl.org/basic/Basic%20mathematics.jl",
# notebookfile_integrity="sha256-gQ80NOuWT2AIckkUMVh2scKYdSD8wnurFqZ/R+WpI3c=",
# statefile="https://featured.plutojl.org/basic/Basic%20mathematics.plutostate",
# disable_ui=true,
# slider_server_url="https://fonsi.armada.silentech.gr/",
# )
👀 Reading hidden code
import Downloads
import URIs
👀 Reading hidden code
get (generic function with 1 method)
function get(args...; kwargs...)
local resp
s = sprint() do io
resp = Downloads.request(args...; kwargs..., output=io, throw=false)
end
s, resp
end
👀 Reading hidden code
"<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width\"><meta charset=\"utf-8\"><title>Turtles – showcase</title>\n<meta name=\"description\" content='🐢 A couple of cool artworks made with simple Julia code'>\n<meta property=\"og:article:tag\" content='turtle'>\n<meta proper" ⋯ 4848 bytes ⋯ "pluto-insertion-spot-preload\">\n</head><body class=\"no-MαθJax\"> <div style=\"min-height:100vh;display:flex\"> <pluto-editor class=\"fullscreen loading\"> <progress style=\"filter:grayscale()\" class=\"delete-me-when-live statefile-fetch-progress\" max=\"100\"></progress> </pluto-editor> </div> </body></html>"
"https"
"https://featured.plutojl.org/basic/turtles-art.html"
200
"HTTP/2 200"
"accept-ranges"
"bytes"
"access-control-allow-origin"
"*"
"age"
"0"
"cache-control"
"public,max-age=0,must-revalidate"
"cache-status"
"\"Netlify Edge\"; fwd=miss"
"content-length"
"5451"
get(turtles)
👀 Reading hidden code
import JSON
👀 Reading hidden code
find_root_json (generic function with 1 method)
function find_root_json(start_url)
url = URIs.URI(start_url)
path_parts = split(url.path, "/")
for i in eachindex(path_parts)
newpath = join([path_parts[begin:i]..., "pluto_export.json"], "/")
newurl = URIs.URI(url; path=newpath)
htmlpath_relative = join(path_parts[i+1:end], "/")
data, resp = get(string(newurl))
if resp.status ∈ 200:299
data_parsed = JSON.parse(data)
nbs = data_parsed["notebooks"]
matches_html = filter(nbs) do (_jl, nbdata)
lowercase(nbdata["html_path"]) == lowercase(htmlpath_relative)
end
jlpath_relative = only(keys(matches_html))
notebook_data = only(values(matches_html))
return (
json_url=newurl,
json_data=data_parsed,
htmlpath_relative,
jlpath_relative,
notebook_data,
)
end
end
error("Not found. Are you sure that this website is generated with PlutoSliderServer or PlutoPages?")
end
👀 Reading hidden code
URI("https://featured.plutojl.org/pluto_export.json")
"pluto_version"
"0.20.8"
"format_version"
"1"
"julia_version"
"1.11.5"
"collections"
"binder_url"
"https://mybinder.org/v2/gh/fonsp/pluto-on-binder/v0.20.8"
"slider_server_url"
"https://fonsi.armada.silentech.gr"
"title"
"Featured Notebooks"
"description"
"These notebooks from the Julia community show off what you can do with Pluto. Give it a try, you might learn something new!"
"notebooks"
"language/Structure and language.jl"
"web/Interactivity with HTML.jl"
"plot/Ozone repair.jl"
"computational-thinking/images.jl"
"plot/Plots.jl.jl"
"plot/heatmap.jl"
"basic/turtles-art.html"
"basic/turtles-art.jl"
"desired_hash"
"qXkR_XEZST13fdBL4qVTbuB1vr6AVsdtGQg_N9wl6u4"
"statefile_path"
"basic/turtles-art.plutostate"
"frontmatter"
"license_url"
"https://github.com/JuliaPluto/featured/blob/2a6a9664e5428b37abe4957c1dca0994f4a8b7fd/LICENSES/Unlicense"
"author"
"image"
"https://github.com/JuliaRegistries/General/assets/6933510/9a925232-6a75-47e7-9ab9-f384bc389602"
"order"
"5.1"
"title"
"Turtles – showcase"
"date"
"2024-08-10"
"hash"
"qXkR_XEZST13fdBL4qVTbuB1vr6AVsdtGQg_N9wl6u4"
"id"
"basic/turtles-art.jl"
"html_path"
"basic/turtles-art.html"
"current_hash"
"qXkR_XEZST13fdBL4qVTbuB1vr6AVsdtGQg_N9wl6u4"
"notebookfile_path"
"basic/turtles-art.jl"
frj = find_root_json(turtles)
👀 Reading hidden code
{"license_url":"https://github.com/JuliaPluto/featured/blob/2a6a9664e5428b37abe4957c1dca0994f4a8b7fd/LICENSES/Unlicense","author":[{"name":"Pluto.jl","url":"https://github.com/JuliaPluto"}],"image":"https://github.com/JuliaRegistries/General/assets/6933510/9a925232-6a75-47e7-9ab9-f384bc389602","order":"5.1","title":"Turtles – showcase","date":"2024-08-10","tags":["turtle","basic"],"description":"🐢 A couple of cool artworks made with simple Julia code","license":"Unlicense"}
frj.notebook_data["frontmatter"] |> JSON.json |> Text
👀 Reading hidden code
"https://featured.plutojl.org/basic/turtles-art.html"
turtles = "https://featured.plutojl.org/basic/turtles-art.html"
👀 Reading hidden code
"https://featured.plutojl.org/basic/turtles-art.html"
start_url = turtles
👀 Reading hidden code
URI("https://featured.plutojl.org/basic/turtles-art.html")
url = URIs.URI(start_url)
👀 Reading hidden code
"/basic/turtles-art.html"
url.path
👀 Reading hidden code
""
"basic"
"turtles-art.html"
split(url.path, "/")
👀 Reading hidden code
embed_pluto_notebook_from_index (generic function with 1 method)
function embed_pluto_notebook_from_index(just_an_html_path::String)
result = find_root_json(turtles)
Markdown.MD([
Markdown.Paragraph("Use this instead:")
Markdown.Code("julia", "embed_pluto_notebook_from_index(\n\t$(repr(string(result.json_url))),\n)")
])
end
👀 Reading hidden code
embed_pluto_notebook_from_index (generic function with 2 methods)
function embed_pluto_notebook_from_index(
root_site,
)
end
👀 Reading hidden code
Use this instead:
embed_pluto_notebook_from_index(
"https://featured.plutojl.org/pluto_export.json",
)
embed_pluto_notebook_from_index(
"https://featured.plutojl.org/basic/Basic%20mathematics.jl"
)
👀 Reading hidden code
# embed_pluto_notebook(;
# notebook_id="a9823594-1137-11f0-1703-6550d1b2018d"
# )
👀 Reading hidden code
And here is a live Pluto notebook:
👀 Reading hidden code
Here is a featured notebook!
👀 Reading hidden code
syntax: incomplete: premature end of input
this suckz 💣
function fancyu
👀 Reading hidden code