2022-05-09 00:11:58 +00:00
|
|
|
import hashlib
|
2020-04-22 11:30:33 +00:00
|
|
|
import json
|
2019-03-26 09:50:28 +00:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import shutil
|
2022-05-09 00:11:58 +00:00
|
|
|
import subprocess
|
|
|
|
|
2020-06-30 18:22:07 +00:00
|
|
|
import util
|
2020-03-30 08:25:29 +00:00
|
|
|
|
2020-02-18 14:19:44 +00:00
|
|
|
|
2019-03-26 09:50:28 +00:00
|
|
|
def build_website(args):
|
2022-03-22 16:39:58 +00:00
|
|
|
logging.info("Building website")
|
2020-06-30 18:22:07 +00:00
|
|
|
env = util.init_jinja2_env(args)
|
2020-02-18 14:19:44 +00:00
|
|
|
|
2019-03-26 09:50:28 +00:00
|
|
|
shutil.copytree(
|
|
|
|
args.website_dir,
|
|
|
|
args.output_dir,
|
|
|
|
ignore=shutil.ignore_patterns(
|
2022-03-22 16:39:58 +00:00
|
|
|
"*.md",
|
|
|
|
"*.sh",
|
|
|
|
"*.css",
|
|
|
|
"*.json",
|
|
|
|
"js/*.js",
|
|
|
|
"build",
|
|
|
|
"docs",
|
|
|
|
"public",
|
|
|
|
"node_modules",
|
|
|
|
"src",
|
|
|
|
"templates",
|
|
|
|
"locale",
|
|
|
|
".gitkeep",
|
|
|
|
),
|
2019-03-26 09:50:28 +00:00
|
|
|
)
|
2020-11-28 06:20:06 +00:00
|
|
|
|
|
|
|
# This file can be requested to check for available ClickHouse releases.
|
|
|
|
shutil.copy2(
|
2022-03-22 16:39:58 +00:00
|
|
|
os.path.join(args.src_dir, "utils", "list-versions", "version_date.tsv"),
|
|
|
|
os.path.join(args.output_dir, "data", "version_date.tsv"),
|
|
|
|
)
|
2020-11-28 06:20:06 +00:00
|
|
|
|
2021-10-12 20:09:26 +00:00
|
|
|
# This file can be requested to install ClickHouse.
|
|
|
|
shutil.copy2(
|
2022-03-22 16:39:58 +00:00
|
|
|
os.path.join(args.src_dir, "docs", "_includes", "install", "universal.sh"),
|
|
|
|
os.path.join(args.output_dir, "data", "install.sh"),
|
|
|
|
)
|
2021-10-12 20:09:26 +00:00
|
|
|
|
2020-02-18 14:19:44 +00:00
|
|
|
for root, _, filenames in os.walk(args.output_dir):
|
|
|
|
for filename in filenames:
|
2022-03-22 16:39:58 +00:00
|
|
|
if filename == "main.html":
|
2020-03-22 12:12:53 +00:00
|
|
|
continue
|
|
|
|
|
2020-02-18 14:19:44 +00:00
|
|
|
path = os.path.join(root, filename)
|
2022-03-22 16:39:58 +00:00
|
|
|
if not filename.endswith(".html"):
|
2020-02-18 14:19:44 +00:00
|
|
|
continue
|
2022-03-22 16:39:58 +00:00
|
|
|
logging.info("Processing %s", path)
|
|
|
|
with open(path, "rb") as f:
|
|
|
|
content = f.read().decode("utf-8")
|
2020-02-18 14:19:44 +00:00
|
|
|
|
|
|
|
template = env.from_string(content)
|
|
|
|
content = template.render(args.__dict__)
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
with open(path, "wb") as f:
|
|
|
|
f.write(content.encode("utf-8"))
|