snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
57
zerver/views/development/help.py
Normal file
57
zerver/views/development/help.py
Normal file
@@ -0,0 +1,57 @@
|
||||
import os
|
||||
|
||||
import werkzeug
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
|
||||
def help_dev_mode_view(request: HttpRequest, subpath: str = "") -> HttpResponse:
|
||||
"""
|
||||
Dev only view that displays help information for setting up the
|
||||
help center dev server in the default `run-dev` mode where the
|
||||
help center server is not running. Also serves raw MDX content when
|
||||
`raw` query param is passed is passed.
|
||||
"""
|
||||
|
||||
def read_mdx_file(filename: str) -> HttpResponse:
|
||||
file_path = os.path.join(
|
||||
settings.DEPLOY_ROOT, "starlight_help", "src", "content", "docs", f"{filename}.mdx"
|
||||
)
|
||||
try:
|
||||
with open(file_path, encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
return HttpResponse(content, content_type="text/plain")
|
||||
except OSError:
|
||||
return HttpResponse("Error reading MDX file", status=500)
|
||||
|
||||
mdx_file_exists = False
|
||||
is_requesting_raw_file = request.GET.get("raw") == ""
|
||||
|
||||
if subpath:
|
||||
subpath = werkzeug.utils.secure_filename(subpath)
|
||||
raw_url = f"/help/{subpath}?raw"
|
||||
mdx_path = os.path.join(
|
||||
settings.DEPLOY_ROOT, "starlight_help", "src", "content", "docs", f"{subpath}.mdx"
|
||||
)
|
||||
mdx_file_exists = os.path.exists(mdx_path) and "/include/" not in mdx_path
|
||||
if mdx_file_exists and is_requesting_raw_file:
|
||||
return read_mdx_file(subpath)
|
||||
else:
|
||||
if request.path.endswith("/"):
|
||||
raw_url = "/help/?raw"
|
||||
else:
|
||||
raw_url = "/help?raw"
|
||||
mdx_file_exists = True
|
||||
if is_requesting_raw_file:
|
||||
return read_mdx_file("index")
|
||||
|
||||
return render(
|
||||
request,
|
||||
"zerver/development/dev_help.html",
|
||||
{
|
||||
"subpath": subpath,
|
||||
"mdx_file_exists": mdx_file_exists,
|
||||
"raw_url": raw_url,
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user