diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 844ddc8..2c5ea67 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-gitea", - "version": "0.1.2", + "version": "0.1.3", "description": "Gitea API 工具、Wiki 讀寫與存取庫批次同步", "skills": "./skills", "author": { diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index 4657e0b..8363c08 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-gitea", - "version": "0.1.2", + "version": "0.1.3", "description": "Gitea API 工具、Wiki 讀寫與存取庫批次同步", "skills": "./skills" } diff --git a/README.md b/README.md index 4aba7df..8e68ee6 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ gitea.sh pr-comments / # 印出所有留言(issue gitea.sh pr-depend / / # 把 PR 掛上前置 PR 依賴;依賴未關閉前 Gitea 會阻擋合併 gitea.sh repo-set / [website] # 設定 repo 描述與網頁 +gitea.sh markdown # markdown 檔渲染成 HTML 片段(走 /markdown/raw) gitea.sh api [json-file] hash-id # 與 gitea.sh hash-id 相同 repo-sync.sh / [target-dir] # 同步單一存取庫;印出 cloned、updated、dirty {分支} 或 failed {原因} @@ -46,10 +47,46 @@ repo-sync.sh / [target-dir] # 同步單一存取庫;印 check-wiki-rules.sh # 驗證 wiki repo 解析與 hash fallback 規則 ``` +議題與 HTML 產出: + +``` +gitea-link.sh parse # 解析 wiki 或議題連結;不是這兩種就 exit 3(呼叫端據此中止) +issue.sh labels|label-ids|projects / +issue.sh title|body|labels-of / +issue.sh create / <body-file> [--labels <ids>] [--milestone <id>] +html-style.sh get|set|unset|list|layouts|styles # 種類對版型與風格的設定 +html-render.sh --markdown <檔案> --title <標題> --out <輸出檔> [--layout] [--style] [--subtitle] [--source-url] +``` + ## 參考資料 - `references/wiki-links.md`:寫 wiki 頁才需要的連結規則。同類型用 `[[顯示文字|頁名]]`(顯示文字在左),跨類型用 `wiki-url` 給的絕對網址。 +## HTML 範本 + +版型(`templates/html/layout/*.html`)決定內容怎麼排,風格(`templates/html/style/*.css`)決定看起來長怎樣。兩者自由搭配,六乘五共三十種。 + +| 版型 | 內容排法 | +| --- | --- | +| `report` | 左側目錄加章節內文,長文件用 | +| `slide` | 一個 `##` 一張投影片,鍵盤左右鍵翻頁 | +| `dashboard` | 每個 `##` 一張卡片並排 | +| `spec` | 表格表頭固定、程式碼區塊放大,API 文件用 | +| `timeline` | 每個 `##` 一個節點串成一條線 | +| `onepager` | 窄欄單頁,印出來剛好一頁 | + +| 風格 | 視覺 | +| --- | --- | +| `minimal` | 白底細線、無襯線,資訊密度優先 | +| `corporate` | 深藍主色、表頭反白,正式對外 | +| `dark` | 深底亮字 | +| `print` | 襯線字、A4 邊界,列印或轉 PDF | +| `vivid` | 高彩度、圓角卡片、漸層標題 | + +哪一種頁面套哪一組,由 `html-style.sh` 的設定決定:專案的 `./.jsc/html-styles` 優先,其次 `$JSC_HOME/html-styles.conf`,種類對不到就退 `DEFAULT`,再對不到才用內建的 `report`/`minimal`。設定的 key 是 `WIKI:{頁名前綴}`、`ISSUE:{標籤名}` 或 `DEFAULT`。 + +自訂範本:版型放進 `templates/html/layout/`,風格放進 `templates/html/style/`,檔案第一行寫一句繁中說明——那句話就是技能問使用者時顯示的選項說明。版型檔可用的佔位有 `{{TITLE}}`、`{{SUBTITLE}}`、`{{CONTENT}}`、`{{BASE}}`、`{{BASE_JS}}`、`{{STYLE}}`、`{{SOURCE}}`、`{{GENERATED}}`、`{{LAYOUT}}`、`{{STYLE_NAME}}`。 + ## Skills 目錄 呼叫方式:Claude / Antigravity `/jsc-gitea:{name}`;Codex `${name}`;Copilot / Kiro 描述需求自動觸發。 @@ -64,6 +101,18 @@ Gitea wiki 頁讀寫的統一入口:依頁面類型(QUESTION / PLAN / ANALYZ 存取庫批次同步:列出 owner → 使用者選擇 → 逐 repo(sub agent)呼叫 `tools/repo-sync.sh` clone 或更新;回報 `dirty {分支}` 的存取庫交給 `jsc-git:pr`,base 直接用腳本帶出來的那個分支。 +### `html-export` + +把一頁 wiki 或一筆議題輸出成單一 HTML 檔:解析連結 → 判斷種類 → 查該種類的版型與風格 → 用 Gitea 自己的 markdown 渲染出圖。CSS 與腳本全部內嵌,檔案拿到哪裡都打得開。**沒有連結就直接中止**,不猜存取庫、不猜頁名、不猜議題編號。 + +### `html-style` + +設定「哪一種 wiki 頁或議題,出 HTML 時用哪一種版型與風格」:六種版型與五種風格全部列給使用者選,再寫進專案的 `.jsc/html-styles` 或全域的 `$JSC_HOME/html-styles.conf`。`html-export` 讀的就是這份設定。 + +### `wiki-to-issue` + +把一頁 wiki 轉成同一個存取庫的議題:讀頁面 → sub agent 起草標題與正文(開頭附來源連結)→ 從既有標籤挑合適的 → 關聯專案看板 → 建立議題。標籤只從存取庫既有的挑,不自己發明;站台沒有看板 API 時據實回報請使用者手動拖,不假裝關聯成功。**沒有連結就直接中止**。 + <!-- JSC-SKILLS:END --> ## 環境變數 diff --git a/plugin.json b/plugin.json index 3c54f99..0b089b1 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-gitea", - "version": "0.1.2", + "version": "0.1.3", "description": "Gitea API 工具、Wiki 讀寫與存取庫批次同步", "skills": "./skills/" } diff --git a/tools/gitea.sh b/tools/gitea.sh index 45bf432..f311640 100755 --- a/tools/gitea.sh +++ b/tools/gitea.sh @@ -19,6 +19,7 @@ # gitea.sh pr-depend <owner>/<repo> <pr-index> <dep-owner>/<dep-repo> <dep-index> # 把 PR 掛上前置 PR 依賴;依賴未關閉前 Gitea 會阻擋合併 # gitea.sh repo-set <owner>/<repo> <description> [website] # 設定 repo 描述與網頁 +# gitea.sh markdown <file> # markdown 檔渲染成 HTML 片段(走 /markdown/raw) # gitea.sh api <METHOD> <path> [json-file] # 原始 API 呼叫(path 以 /repos/... 起始) # 環境變數: GITEA_HOST(例 https://gitea.jsc.idv.tw)、GITEA_TOKEN # GITEA_TOKEN 未設定,或請求遇 401/403 時,自動退回 tea CLI 的登入 token @@ -95,13 +96,16 @@ fi case "$GITEA_HOST" in http://*|https://*) HOST="$GITEA_HOST" ;; *) HOST="https://$GITEA_HOST" ;; esac API="${HOST%/}/api/v1" -req() { # METHOD path [json-file] -> body(HTTP >= 400 時 exit 4;401/403 以 tea token 重試一次) +req() { # METHOD path [body-file] -> body(HTTP >= 400 時 exit 4;401/403 以 tea token 重試一次) + # 送出的 Content-Type 由 REQ_CONTENT_TYPE 決定,預設 application/json; + # /markdown/raw 這種吃純文字的端點要先改成 text/plain 再呼叫。 method="$1"; path="$2"; body_file="${3:-}" + ctype="${REQ_CONTENT_TYPE:-application/json}" retried=0 while :; do if [ -n "$body_file" ]; then out=$(curl -sS -w '\n%{http_code}' -X "$method" \ - -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" \ + -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: $ctype" \ --data-binary "@$body_file" "$API$path") else out=$(curl -sS -w '\n%{http_code}' -X "$method" \ @@ -279,6 +283,15 @@ print(json.dumps(b)) fi rm -f "$tmp" echo "OK $or" ;; + markdown) + # markdown 檔 -> HTML 片段。走 /markdown/raw(吃純文字)而不是 /markdown: + # 後者在 Gitea 1.27 回 200 但內容是空的,看起來像成功,其實什麼都沒渲染。 + # 代價:raw 端點不吃 context,wiki 的 [[頁名]] 內部連結不會變成連結, + # 呼叫端要先把它換成絕對網址。 + file="${1:?markdown file}" + [ -f "$file" ] || { echo "找不到 markdown 檔: $file" >&2; exit 2; } + REQ_CONTENT_TYPE='text/plain' + req POST "/markdown/raw" "$file" ;; api) method="${1:?METHOD}"; path="${2:?path}"; body="${3:-}" req "$method" "$path" $body ;;