# Momentry API Demo Pages ## 頁面分類 Momentry Portal 提供四個 API 示範頁面,涵蓋查詢、展示、操作、應用四大類別: | 頁面 | Template Name | 用途 | |------|---------------|------| | 查詢 | `API Demo - 查詢` | 檔案查詢、身份查詢、處理狀態、遷移歷史、語義搜尋 | | 展示 | `API Demo - 展示` | 檔案詳情儀表板、身份視覺化、片段展示、分類結果 | | 操作 | `API Demo - 操作` | 檔案註冊、身份綁定、處理觸發、身份合併、處理器重試 | | 應用 | `API Demo - 應用` | 完整工作流程、身份追蹤、遷移示範、批次處理、語義搜尋工作流 | ## 設定步驟 ### 1. 確認 Theme 檔案已部署 以下檔案位於 `/Users/accusys/wordpress/web/wp-content/themes/momentry/`: ``` page-api-demo-query.php # 查詢頁面 page-api-demo-display.php # 展示頁面 page-api-demo-operation.php # 操作頁面 page-api-demo-application.php # 應用頁面 style.css # 已更新共用樣式 ``` ### 2. 在 WordPress 建立頁面 1. 進入 WordPress 後台 (`http://localhost/wp-admin`) 2. 點擊 **Pages > Add New** 3. 建立以下四個頁面: | 頁面標題 | URL Slug | Template | |----------|----------|----------| | API Demo - 查詢 | `api-demo-query` | API Demo - 查詢 | | API Demo - 展示 | `api-demo-display` | API Demo - 展示 | | API Demo - 操作 | `api-demo-operation` | API Demo - 操作 | | API Demo - 應用 | `api-demo-application` | API Demo - 應用 | 4. 建立時,在右側 **Page Attributes** 選擇對應的 **Template** 5. 點擊 **Publish** ### 3. 啟動 Momentry Playground Server API 示範頁面需要連線到 Momentry Playground API server (port 3003): ```bash cargo run --bin momentry_playground -- server --host 0.0.0.0 --port 3003 ``` ### 4. 訪問示範頁面 - 查詢: `http://localhost/api-demo-query/` - 展示: `http://localhost/api-demo-display/` - 操作: `http://localhost/api-demo-operation/` - 應用: `http://localhost/api-demo-application/` ## API 端點說明 ### 查詢類 API | 端點 | 方法 | 說明 | |------|------|------| | `/api/v1/files/:uuid` | GET | 查詢檔案詳細資訊 | | `/api/v1/files` | GET | 查詢檔案列表 | | `/api/v1/identities/:uuid` | GET | 查詢身份資訊 | | `/api/v1/jobs/:uuid/status` | GET | 查詢處理狀態 | | `/api/v1/files/:uuid/history` | GET | 查詢遷移歷史 | | `/api/v1/search` | POST | 語義搜尋 | ### 操作類 API | 端點 | 方法 | 說明 | |------|------|------| | `/api/v1/register` | POST | 註冊檔案 | | `/api/v1/identities/bind` | POST | 綁定身份 | | `/api/v1/files/:uuid/process` | POST | 觸發處理 | | `/api/v1/identities/merge` | POST | 合併身份 | | `/api/v1/jobs/:uuid/retry` | POST | 重試處理器 | ## 工作流程示範 ### 完整工作流程 (應用頁面) 1. **註冊檔案**: 輸入影片路徑,呼叫 `/register` 2. **查詢處理狀態**: 定期檢查 `/jobs/:uuid/status` 直到完成 3. **查詢檢測結果**: 取得身份和片段資訊 4. **搜尋身份**: 展示檔案中檢測到的身份列表 ### 檔案遷移示範 (應用頁面) 1. **原始註冊**: 註冊原始路徑的檔案 2. **模擬移動**: 使用新路徑重新註冊,系統產生新的 file_uuid 3. **查詢歷史**: 透過 `/files/:uuid/history` 查看遷移鏈 ### 批次處理 (應用頁面) 1. 輸入多個檔案路徑 (每行一個) 2. 批次呼叫 `/register` 3. 顯示進度條和每個檔案的註冊結果 ## 注意事項 - API base URL 預設為 `http://localhost:3003/api/v1` - 如需更改,請修改各頁面的 `const API_BASE = '...'` 設定 - 確保 Playground server 已啟動且 CORS 設定允許來自 WordPress 的請求 - 部分 API 端點可能需要實作後才能正常使用