Skip to content

Commit

Permalink
Display banner from Pluto.__init__, not during precompile
Browse files Browse the repository at this point in the history
Use the Scratch package to record if the banner has already been shown.

fixes #548
  • Loading branch information
mgkuhn committed Sep 6, 2023
1 parent 17d105b commit 9b9a73a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
RegistryInstances = "2792f1a3-b283-48e8-9a74-f99dce5104f3"
RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
Expand All @@ -43,6 +44,7 @@ PrecompileSignatures = "3"
PrecompileTools = "1"
RegistryInstances = "0.1"
RelocatableFolders = "0.1, 0.2, 0.3, 1"
Scratch = "1.1"
Tables = "1"
URIs = "1.3"
julia = "^1.6"
Expand Down
36 changes: 26 additions & 10 deletions src/Pluto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function project_relative_path(root, xs...)
end

import Pkg
import Scratch

include_dependency("../Project.toml")
const PLUTO_VERSION = VersionNumber(Pkg.TOML.parsefile(joinpath(ROOT_DIR, "Project.toml"))["version"])
Expand Down Expand Up @@ -99,16 +100,31 @@ export activate_notebook_environment

include("./precompile.jl")

if get(ENV, "JULIA_PLUTO_SHOW_BANNER", "1") != "0" && get(ENV, "CI", "πŸ„") != "true"
@info """\n
Welcome to Pluto $(PLUTO_VERSION_STR) 🎈
Start a notebook server using:
julia> Pluto.run()
Have a look at the FAQ:
https://github.com/fonsp/Pluto.jl/wiki
\n"""
function __init__()
# Print a welcome banner
if (get(ENV, "JULIA_PLUTO_SHOW_BANNER", "1") != "0" &&
get(ENV, "CI", "πŸ„") != "true" && isinteractive())
# Print the banner only once per version, if there isn't
# yet a file for this version in banner_shown scratch space.
# (Using the Pluto version as the filename enables later
# version-specific "what's new" messages.)
fn = joinpath(Scratch.@get_scratch!("banner_shown"), PLUTO_VERSION_STR)
if !isfile(fn)
@info """
Welcome to Pluto $(PLUTO_VERSION_STR) 🎈
Start a notebook server using:
julia> Pluto.run()
Have a look at the FAQ:
https://github.com/fonsp/Pluto.jl/wiki
"""
# create empty file to indicate that we've shown the banner
write(fn, "");
end
end
end

end

0 comments on commit 9b9a73a

Please sign in to comment.