mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 16:14:02 +00:00
help: Serve help center build without relative links for zulip.com.
We have a copy of help center with relative links disabled which is reserved for root domains without an organisation on the root domain. Ideally, we should have some logic to determine whether we are on such a root domain or not. For practical short term purposes, since this type of documentation is mainly useful for zulip.com, we add an exception for zulip.com.
This commit is contained in:
committed by
Tim Abbott
parent
246fbf6d29
commit
7db29f29de
@@ -29,7 +29,8 @@ location /static/ {
|
|||||||
|
|
||||||
# Serve help center generated by astro/starlight.
|
# Serve help center generated by astro/starlight.
|
||||||
location /help {
|
location /help {
|
||||||
alias /home/zulip/deployments/current/starlight_help/dist/;
|
alias $help_alias;
|
||||||
|
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_min_length 1000;
|
gzip_min_length 1000;
|
||||||
gzip_proxied expired no-cache no-store private auth;
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
@@ -46,7 +47,8 @@ location /help {
|
|||||||
# These files are hashed and thus immutable; cache them aggressively.
|
# These files are hashed and thus immutable; cache them aggressively.
|
||||||
# https://github.com/withastro/docs/blob/53603ad048e8aedbca1aed77bac8eb00dcada79d/src/content/docs/en/guides/integrations-guide/node.mdx?plain=1#L304
|
# https://github.com/withastro/docs/blob/53603ad048e8aedbca1aed77bac8eb00dcada79d/src/content/docs/en/guides/integrations-guide/node.mdx?plain=1#L304
|
||||||
location /help/_astro/ {
|
location /help/_astro/ {
|
||||||
alias /home/zulip/deployments/current/starlight_help/dist/_astro/;
|
set $help_cache_alias "${help_alias}_astro/";
|
||||||
|
alias $help_cache_alias;
|
||||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,4 +61,9 @@ http {
|
|||||||
|
|
||||||
include /etc/nginx/conf.d/*.conf;
|
include /etc/nginx/conf.d/*.conf;
|
||||||
include /etc/nginx/sites-enabled/*;
|
include /etc/nginx/sites-enabled/*;
|
||||||
|
|
||||||
|
map $host $help_alias {
|
||||||
|
zulip.com /home/zulip/deployments/current/starlight_help/dist_no_relative_links/;
|
||||||
|
default /home/zulip/deployments/current/starlight_help/dist/;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
1
starlight_help/.gitignore
vendored
1
starlight_help/.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
# build output
|
# build output
|
||||||
dist/
|
dist/
|
||||||
|
dist_no_relative_links/
|
||||||
# generated types
|
# generated types
|
||||||
.astro/
|
.astro/
|
||||||
|
|
||||||
|
@@ -26,6 +26,13 @@ parser.add_argument(
|
|||||||
dest="show_relative_links",
|
dest="show_relative_links",
|
||||||
help="Disable relative links when using NavigationSteps component. Typically only set to true in case of the help center being hosted on zulip.com.",
|
help="Disable relative links when using NavigationSteps component. Typically only set to true in case of the help center being hosted on zulip.com.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--out-dir",
|
||||||
|
action="store",
|
||||||
|
dest="out_dir",
|
||||||
|
help="Output directory for the final build.",
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@@ -34,8 +41,12 @@ def run() -> None:
|
|||||||
env["SUPPORT_EMAIL"] = parseaddr(settings.ZULIP_ADMINISTRATOR)[1]
|
env["SUPPORT_EMAIL"] = parseaddr(settings.ZULIP_ADMINISTRATOR)[1]
|
||||||
env["CORPORATE_ENABLED"] = str(settings.CORPORATE_ENABLED).lower()
|
env["CORPORATE_ENABLED"] = str(settings.CORPORATE_ENABLED).lower()
|
||||||
env["SHOW_RELATIVE_LINKS"] = str(args.show_relative_links).lower()
|
env["SHOW_RELATIVE_LINKS"] = str(args.show_relative_links).lower()
|
||||||
|
build_command = ["/usr/local/bin/corepack", "pnpm", "build"]
|
||||||
|
if args.out_dir:
|
||||||
|
build_command += ["--outDir", args.out_dir]
|
||||||
|
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
["/usr/local/bin/corepack", "pnpm", "build"],
|
build_command,
|
||||||
cwd="starlight_help",
|
cwd="starlight_help",
|
||||||
env=env,
|
env=env,
|
||||||
)
|
)
|
||||||
|
@@ -46,17 +46,20 @@ run(["./tools/setup/build_timezone_values"])
|
|||||||
# need them.
|
# need them.
|
||||||
if settings.CORPORATE_ENABLED:
|
if settings.CORPORATE_ENABLED:
|
||||||
run(["./tools/setup/generate_landing_page_images.py"])
|
run(["./tools/setup/generate_landing_page_images.py"])
|
||||||
# We ideally should be generating two builds for Zulip cloud
|
run(
|
||||||
# and serve a different one depending on whether the subdomain
|
[
|
||||||
# is same as the root domain or not.
|
"./tools/build-help-center",
|
||||||
run(["./tools/build-help-center", "--no-relative-links"])
|
"--no-relative-links",
|
||||||
else:
|
"--out-dir",
|
||||||
|
"./dist_no_relative_links",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
run(["./tools/build-help-center"])
|
run(["./tools/build-help-center"])
|
||||||
|
|
||||||
# Create webpack bundle
|
# Create webpack bundle
|
||||||
run(["./tools/webpack", "--quiet"])
|
run(["./tools/webpack", "--quiet"])
|
||||||
|
|
||||||
|
|
||||||
# Collect the files that we're going to serve; this creates prod-static/serve.
|
# Collect the files that we're going to serve; this creates prod-static/serve.
|
||||||
run(["./manage.py", "collectstatic", "-v0", "--noinput"])
|
run(["./manage.py", "collectstatic", "-v0", "--noinput"])
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user