diff --git a/.ci/generate_redirects.jl b/.ci/generate_redirects.jl index 674c31a169ba574..b96b0bf8e560300 100644 --- a/.ci/generate_redirects.jl +++ b/.ci/generate_redirects.jl @@ -27,20 +27,52 @@ function package_path(args...) joinpath("webroot", "packages", "redirect_to_repo", args...) end +function style_block(backgroundcolor, color) + """ + + """ +end + function create_redirect_page(; name, path) repo = get_repo(path) host = get_host(repo) + jlname = name * ".jl" should_redirect = known_host(host) meta_redirection = should_redirect ? """""" : "" message = if should_redirect - """Redirecting to $name...

Click the link below if you are not redirected automatically to the registered repository for the Julia package $name

$repo""" + """Redirecting to $jlname...

Click the link below if you are not redirected automatically to the registered repository for the Julia package $jlname

$repo""" else - """Click the link below to go to the registered repository for the Julia package $name

$repo""" + """Click the link below to go to the registered repository for the Julia package $jlname

$repo""" end title = if should_redirect - "Redirecting to $name..." + "Redirecting to $jlname..." else - "Confirm redirect to $name" + "Confirm redirect to $jlname" end open(package_path(name * ".html"), "w") do io @@ -52,32 +84,7 @@ function create_redirect_page(; name, path) $title $meta_redirection - + $(style_block("#f8e9ff", "#9558B2"))
@@ -89,6 +96,52 @@ function create_redirect_page(; name, path) end end +function create_404_page() + open(joinpath("webroot", "404.html"), "w") do io + write(io, """ + + + + + + Page not found + $(style_block("#ffcbc8", "#CB3C33")) + + +
+

No page exists here.

Redirection pages for registered Julia packages follow the format packages/redirect_to_repo/SomePackage.

+
+ + + + + """) + end + return +end + function main() cd(joinpath(@__DIR__, "..")) do mkpath(package_path()) @@ -96,6 +149,7 @@ function main() for (; name, path) in packages_info create_redirect_page(; name, path) end + create_404_page() end end diff --git a/.github/workflows/redirects_page.yml b/.github/workflows/redirects_page.yml index 200058913fc1bac..443ce698d761ef7 100644 --- a/.github/workflows/redirects_page.yml +++ b/.github/workflows/redirects_page.yml @@ -9,6 +9,9 @@ on: - master paths: - '**/Package.toml' # avoids redeploys on version or compat changes + - '.github/workflows/redirects_page.yml' + - '.ci/generate_redirects.jl' + jobs: build-and-deploy: