Skip to content

Commit

Permalink
Merge pull request #9 from JuliaPluto/import-from-plutopages
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Jul 12, 2024
2 parents 9e66e80 + 7011848 commit ea8a913
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/Manifest.toml
.DS_Store

/src/_site
/src/_cache
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Malt = "36869731-bdee-424d-aa32-cab38c994e3b"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
MarkdownLiteral = "736d6165-7244-6769-4267-6b50796e6954"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand All @@ -33,8 +34,10 @@ CommonMark = "0.8"
Gumbo = "0.8"
HypertextLiteral = "0.9"
InteractiveUtils = "1"
JSON = "0.21"
LiveServer = "1.2"
Logging = "1"
Malt = "1"
Markdown = "1"
MarkdownLiteral = "0.1"
Pkg = "1"
Expand Down
38 changes: 37 additions & 1 deletion src/PlutoPages.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
module PlutoPages

# import all the things that the notebook needs
import BetterFileWatching,
CommonMark,
Gumbo,
HypertextLiteral,
InteractiveUtils,
JSON,
LiveServer,
Logging,
Malt,
Markdown,
MarkdownLiteral,
Pkg,
Pluto,
PlutoHooks,
PlutoLinks,
PlutoSliderServer,
PlutoUI,
ProgressLogging,
RelocatableFolders,
SHA,
ThreadsX,
Unicode,
YAML









import Pluto
using RelocatableFolders
import LiveServer
Expand Down Expand Up @@ -28,7 +61,7 @@ function run_plutopages_notebook(;
)
run_with_replacements(
PlutoPages_notebook_path,
plutopages_replacements(; input_dir, output_dir, cache_dir);
plutopages_replacements(; input_dir, output_dir, cache_dir, ap=Base.active_project(), lp=LOAD_PATH);
kwargs...
)
end
Expand All @@ -37,11 +70,14 @@ function plutopages_replacements(;
input_dir::String,
output_dir::String,
cache_dir::String,
ap::String,
lp::Vector{String},
)
Dict(
:input_dir => input_dir,
:output_dir => output_dir,
:cache_dir => cache_dir,
:override_ap_lp => (ap, lp),
)
end

Expand Down
69 changes: 51 additions & 18 deletions src/notebook.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### A Pluto.jl notebook ###
# v0.19.40
# v0.19.43

using Markdown
using InteractiveUtils
Expand All @@ -14,30 +14,61 @@ macro bind(def, element)
end
end

# ╔═╡ b8024c95-6a63-4409-9c75-9bad6b301a92
# ╔═╡ 658b1b24-a7b2-47ab-ba53-b570dfeb8bfa
begin
# When the PlutoPages.jl package runs this notebook, it will override this variable.
# Instead of `nothing`, the value will be a Tuple{String,Vector{String}} containg `(Base.activate_project(), LOAD_PATH)`.
#
# But if you're reading this, then no override happened, because you are developing this notebook yourself. In this case, the project environment of PlutoPages should have been activated.
const override_ap_lp = nothing

# import Pkg here to help the dependency sorting algorithm
import Pkg
Pkg.activate(dirname(@__DIR__))
end

# ╔═╡ b8024c95-6a63-4409-9c75-9bad6b301a92
begin
# when the `override_ap_lp` cell gets overriden, the `import Pkg` disappears, here's the fix
eval(:(import Pkg))

if override_ap_lp === nothing
Pkg.activate(dirname(@__DIR__))
else
ap, lp = override_ap_lp
Pkg.activate(ap)
copy!(LOAD_PATH, lp)
end

import PlutoPages
end

# ╔═╡ 87023138-83f8-4ba7-a05e-444714d0b0d1
begin
# to make all the Pkg stuff work, all imports have to come from the PlutoPages package! like so:

# NOT:
# import PlutoSliderServer

import PlutoSliderServer
import Pluto
using MarkdownLiteral
# YES:
import PlutoPages.PlutoSliderServer
import PlutoPages.Pluto
using PlutoPages.MarkdownLiteral
end

# ╔═╡ d4cfce05-bae4-49ae-b26d-ce27171a3853
using PlutoUI
using PlutoPages.PlutoUI

# ╔═╡ ce840b47-8406-48e6-abfb-1b00daab28dd
using HypertextLiteral
using PlutoPages.HypertextLiteral

# ╔═╡ 7c53c1e3-6ccf-4804-8bc3-09126036608e
using PlutoHooks
using PlutoPages.PlutoHooks

# ╔═╡ 725cb996-68ac-4736-95ee-0a9754867bf3
using BetterFileWatching
using PlutoPages.BetterFileWatching

# ╔═╡ 9d996c55-0e37-4ae9-a6a2-8c8761e8c6db
using PlutoLinks
using PlutoPages.PlutoLinks

# ╔═╡ c5a0b072-7f49-4c0c-855e-773cfc03d308
TableOfContents(include_definitions=true)
Expand All @@ -46,13 +77,13 @@ TableOfContents(include_definitions=true)
import Logging

# ╔═╡ 66c97351-2294-4ac2-a93a-f334aaee8f92
import Gumbo
import PlutoPages.Gumbo

# ╔═╡ bcbda2d2-90a5-43e6-8400-d5472578f86a
import ProgressLogging
import PlutoPages.ProgressLogging

# ╔═╡ cd576da6-59ae-4d1b-b812-1a35023b6875
import ThreadsX
import PlutoPages.ThreadsX

# ╔═╡ 86471faf-af03-4f35-8b95-c4011ceaf7c3
function progressmap_generic(mapfn, f, itr; kwargs...)
Expand Down Expand Up @@ -133,10 +164,10 @@ md"""
"""

# ╔═╡ f4a4b741-8028-4626-9187-0b6a52f062b6
import CommonMark
import PlutoPages.CommonMark

# ╔═╡ 535efb29-73bd-4e65-8bbc-18b72ae8fe1f
import YAML
import PlutoPages.YAML

# ╔═╡ 90f0c676-b33f-441c-8ea6-d59c44a11547
s_example = raw"""
Expand Down Expand Up @@ -474,7 +505,7 @@ md"""
"""

# ╔═╡ c3a495c1-3e1f-42a1-ac08-8dc0b9175fe9
# import Deno_jll
# import PlutoPages.Deno_jll

# ╔═╡ 3b2d1919-41d9-4bba-9774-c8497bba5003
# dev_server_port = 4507
Expand Down Expand Up @@ -600,7 +631,7 @@ md"""
"""

# ╔═╡ 834294ff-9441-4e71-b5c0-edaf32d860ee
import JSON
import PlutoPages.JSON

# ╔═╡ eef54261-767a-4ce4-b549-0b1828379f7e
SafeString(x) = String(x)
Expand Down Expand Up @@ -977,7 +1008,9 @@ begin
end

# ╔═╡ Cell order:
# ╠═658b1b24-a7b2-47ab-ba53-b570dfeb8bfa
# ╠═b8024c95-6a63-4409-9c75-9bad6b301a92
# ╠═87023138-83f8-4ba7-a05e-444714d0b0d1
# ╠═c5a0b072-7f49-4c0c-855e-773cfc03d308
# ╠═d4cfce05-bae4-49ae-b26d-ce27171a3853
# ╠═644552c6-4e32-4caf-90ef-bee259977094
Expand Down

0 comments on commit ea8a913

Please sign in to comment.