From f8a62b80684a46da177358b6074b625b7781c8fa Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 24 Aug 2026 18:54:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(wiki-url):=20=E6=96=B0=E5=A2=9E=20wiki=20?= =?UTF-8?q?=E9=A0=81=E7=B5=95=E5=B0=8D=E7=B6=B2=E5=9D=80=E5=AD=90=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=EF=BC=8C=E4=BE=9B=E8=B7=A8=E5=AD=98=E5=8F=96=E5=BA=AB?= =?UTF-8?q?=E9=80=A3=E7=B5=90=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5 (1M context) --- tools/gitea.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/gitea.sh b/tools/gitea.sh index 2f1363d..cb0e8eb 100755 --- a/tools/gitea.sh +++ b/tools/gitea.sh @@ -138,6 +138,22 @@ import json,sys,base64 d=json.load(sys.stdin) sys.stdout.write(base64.b64decode(d.get("content_base64","")).decode("utf-8")) ' ;; + wiki-url) + # 印出 wiki 頁的絕對網址,取自 API 回應的 html_url,不自行組路徑。 + # 跨存取庫連結(例如 LOG 頁連到 PLAN 頁,而兩者的 JSC_WIKI_REPO_{TYPE} 不同) + # 只有絕對網址會通:[[頁名]] 與 markdown 相對連結都只在同一個 wiki 內解析。 + or="${1:?owner/repo required}"; page="${2:?page required}" + if ! out=$(req GET "/repos/$or/wiki/page/$page" 2>/dev/null); then + echo "wiki page not found: $page" >&2; exit 4 + fi + url=$(printf '%s' "$out" | python3 -c ' +import json,sys +sys.stdout.write(json.load(sys.stdin).get("html_url") or "") +') + if [ -z "$url" ]; then + echo "wiki page has no html_url: $page" >&2; exit 5 + fi + printf '%s\n' "$url" ;; wiki-put) or="${1:?owner/repo required}"; page="${2:?page required}"; file="${3:?content file required}" tmp=$(mktemp)