Skip to content

Commit

Permalink
Include slider_server_url and binder_url setting in pluto_export.json (
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Oct 30, 2023
1 parent 14801ed commit 60c11b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/IndexJSON.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ function json_data(
# c === nothing ? nothing : [
# v for (k,v) in sort(pairs(c); by=((k,v)) -> parse(Int, k))
# ],
binder_url=settings.Export.offer_binder ?
something(settings.Export.binder_url, Pluto.default_binder_url) :
nothing,
slider_server_url=somethingornothing(
settings.Export.slider_server_url,
settings.SliderServer.enabled ? "." : nothing,
),
)
end

Expand All @@ -76,4 +83,8 @@ function generate_index_json(
end
result = json_data(sessions; settings, start_dir, config_data)
JSON.json(result)
end
end

somethingornothing() = nothing
somethingornothing(x::Nothing, y...) = somethingornothing(y...)
somethingornothing(x::Any, y...) = x
6 changes: 6 additions & 0 deletions test/static export.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ make_test_dir() =
@test second_runtime < 1.0

@test occursin("slider_server_url = undefined", read("a.html", String))

jsonstr = read("pluto_export.json", String)
json = JSON.parse(jsonstr)
@test json["slider_server_url"] === nothing
end


Expand Down Expand Up @@ -167,6 +171,7 @@ end
Export_cache_dir=cache_dir,
Export_baked_state=false,
Export_create_pluto_featured_index=fancy,
Export_slider_server_url="krat",
)

@test sort(list_files_recursive()) == sort([
Expand All @@ -193,6 +198,7 @@ end
@test occursin("</html>", htmlstr)
@test occursin("pluto_export.json", htmlstr)
end
@test json["slider_server_url"] == "krat"

nbs = ["subdir/c.plutojl", "b.pluto.jl", "a.jl"]
for (i, p) in enumerate(nbs)
Expand Down

0 comments on commit 60c11b3

Please sign in to comment.