Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display banner from Pluto.__init__, not during precompile #2628

Merged
merged 4 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a compat entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compat entry added (needs at least Scratch 1.1 due to the underscore used in the key banner_shown)

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