From 9b9a73a62d178b80cfc301363a4b908219452482 Mon Sep 17 00:00:00 2001 From: Markus Kuhn Date: Sat, 12 Aug 2023 19:59:20 +0100 Subject: [PATCH] Display banner from Pluto.__init__, not during precompile Use the Scratch package to record if the banner has already been shown. fixes #548 --- Project.toml | 2 ++ src/Pluto.jl | 36 ++++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Project.toml b/Project.toml index 7c7f655297..ffb77d4640 100644 --- a/Project.toml +++ b/Project.toml @@ -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" @@ -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" diff --git a/src/Pluto.jl b/src/Pluto.jl index 2cb0eee2ad..8898d058f2 100644 --- a/src/Pluto.jl +++ b/src/Pluto.jl @@ -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"]) @@ -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