Skip to content

Commit

Permalink
docs: add redirects for common old pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Feb 3, 2023
1 parent 6e83fc4 commit c9087f2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/blog/ibis-version-4.0.0-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Let’s talk about some of the new changes 4.0 brings for Ibis users.

## Backends

Ibis 4.0 brings [Polars](https://ibis-project.org/backends/Polars/), [Snowflake](https://ibis-project.org/backends/Snowflake/), and [Trino](https://ibis-project.org/4.0.0/backends/Trino/) into an already-impressive stock of supported backends.
Ibis 4.0 brings [Polars](https://ibis-project.org/backends/Polars/), [Snowflake](https://ibis-project.org/backends/Snowflake/), and [Trino](https://ibis-project.org/backends/Trino/) into an already-impressive stock of supported backends.
The [Polars](https://www.pola.rs/) backend adds another way for users to work locally with DataFrames.
The [Snowflake](https://www.snowflake.com/en/) and [Trino](https://trino.io/) backends add a free and familiar python API to popular data warehouses.

Expand Down
53 changes: 53 additions & 0 deletions gen_redirects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import pathlib

import mkdocs_gen_files

HTML_TEMPLATE = """
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
<link rel="canonical" href="{url}">
<meta name="robots" content="noindex">
<script>var anchor=window.location.hash.substr(1);location.href="{url}"+(anchor?"#"+anchor:"")</script>
<meta http-equiv="refresh" content="0; url={url}">
</head>
<body>
Redirecting...
</body>
</html>
"""

# Versions for templated redirects
VERSIONS = ["latest", "dev", "4.1.0", "4.0.0", "3.2.0", "3.1.0"]

# Templated redirects
TEMPLATED_REDIRECTS = {
"/docs/{version}/": "/",
"/docs/{version}/install/": "/install/",
"/docs/{version}/docs/": "/docs/",
"/docs/{version}/backends/": "/backends/",
}

# Untemplated redirects
REDIRECTS = {}

# Fill in templates
REDIRECTS.update(
{
old.format(version=version): new
for version in VERSIONS
for old, new in TEMPLATED_REDIRECTS.items()
}
)

# Write all redirect files
for old, new in REDIRECTS.items():
if old.endswith("/"):
old = old + "index.html"

html = HTML_TEMPLATE.format(url=new)

with mkdocs_gen_files.open(pathlib.Path(old.lstrip("/")), "w") as f:
f.write(html)
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ plugins:
- gen-files:
scripts:
- gen_matrix.py
- gen_redirects.py
- macros
- mkdocstrings:
enable_inventory: true
Expand Down

0 comments on commit c9087f2

Please sign in to comment.