imbajin commented on code in PR #496:
URL: https://github.com/apache/hugegraph-doc/pull/496#discussion_r4099846140
##########
scripts/update_oink.py:
##########
@@ -0,0 +1,141 @@
+#!/usr/bin/env python3
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0.
+
+"""Explicit, review-gated OINK upgrades using the existing site validators."""
+import argparse
+import hashlib
+import json
+import os
+from pathlib import Path
+import subprocess
+import sys
+import tempfile
+
+from oink_module import MODULE, VERSION, command, download_locked,
locked_version
+
+ROOT = Path(__file__).resolve().parents[1]
+BASELINE = ROOT / "scripts/oink-overrides.json"
+WATCH = ("assets/js/sidebar-state.js", "assets/js/sidebar-nav.js",
+ "assets/js/docs-shell.js", "assets/js/search.js",
"assets/js/search-engine.js",
+ "assets/js/surface-coordinator.js", "assets/js/command-palette.js")
+
+
+def run(args, *, cwd=ROOT, env=None):
+ print("+ " + " ".join(map(str, args)), flush=True)
+ subprocess.run(list(map(str, args)), cwd=cwd, env=env, check=True)
+
+
+def snapshot(root, upstream):
+ paths = set(WATCH)
+ # Project SCSS depends on upstream selectors even without a same-name
override.
+ paths.update(str(p.relative_to(upstream)) for p in (upstream /
"assets/scss").rglob("*.scss"))
+ for folder in ("layouts", "assets", "i18n"):
Review Comment:
Addressed in 7477493fee on #496. The override inventory includes data/.
Tests cover a matching local/upstream data file, nonmatching paths, and
removal. The actual v1.1.0 fingerprint inventory still matches, so no baseline
was blindly accepted.
##########
assets/js/kapa-adapter.js:
##########
@@ -133,13 +134,23 @@
}
}
+ function settle(error) {
+ if (!operation) return;
+ var current = operation;
+ operation = null;
+ current.signal.removeEventListener('abort', current.abort);
+ if (error) current.reject(error);
+ else current.resolve();
+ }
+
function openWidget(query, submit) {
invokeKapa(windowObject, 'setSourceGroupIDs', [config.sourceGroupId]);
invokeKapa(windowObject, 'open', {
mode: 'ai',
query: query,
submit: submit,
});
+ settle();
Review Comment:
Addressed in 7477493fee on #496. Both widget API calls are guarded. A
synchronous failure clears the failed script, reports the error,
rejects/settles the activation and releases its abort listener. Tests cover
both calls on first load and ready reopen, followed by a successful retry.
##########
.goal-task/oink-1.1-guide/handoff.md:
##########
@@ -0,0 +1,29 @@
+# Handoff: OINK 1.1 与 Ask AI 建站入门指南
+
+## 来源会话
+- 原始会话 ID: `01a0c9c0-a17b-7e60-8014-b312f6997484`
+- 原始任务名: 写作:OINK 1.1 与 Ask AI 建站入门
+- 原始工作区: `~/.codex/worktrees/d61b/hugegraph-doc`
+- 会话状态: 文章初稿与 8 张配图均已就绪并通过自主核验,因宿主机 Codex 达到使用上限而交接。
+
+## 产物清单
+1. **文章主体**: `oink-1.1-website-guide.md`
+ - 面向没有建站经验、但会写代码/Markdown 的开发者。
+ - 介绍 Hugo + OINK 1.1 + 可选 Ask AI(Kapa)的文档网站体系。
+ - 包含市面文档库对比(Docsy 单独对比表,已剔除 Notion/语雀)。
+ - 遵循 `writing-human` 规范(无套话口号,基于 HugeGraph 实际升级经验)。
+2. **配图及 Prompt 记录**: `oink-1.1-illustrations/`
+ - `01-build.png`: 构建与部署机制
+ - `02-language-version.png`: 多语言与多版本
+ - `03-maintenance.png`: 维护与定制边界
+ - `04-ai.png`: Ask AI / Kapa 接入机制
+ - `05-overview.png`: Markdown 到静态网站全景
+ - `06-features.png`: 交互功能(目录、本地搜索、代码标签页、步骤、图表)
+ - `07-publishing.png`: 多形态发布(网页、打印、RSS、llms.txt)
+ - `08-optional-ai.png`: 本地搜索与可选 Ask AI 接入区分
+ - `final-prompts.md`, `general-prompts.md`, `prompts.md`: 绘图 Prompt 记录
+
+## 接力后续工作建议
+- 根据主线需要,决定是否将该文章排版并整合入网站正式路由(如 `content/cn/docs/...` 或博客/社区板块)。
+- 校验图片相对路径与网站静态资源目录映射。
+- 最终合入 PR 前,从分支中清理 `.goal-task/oink-1.1-guide`。
Review Comment:
Removed the temporary handoff commit from the PR branch history; current
head is 7477493fee. No .goal-task files remain tracked. All 16 original files
were preserved byte-for-byte locally, with a local backup ref; no guide or
generated illustrations are included in this PR.
##########
assets/js/kapa-adapter.js:
##########
@@ -306,119 +344,32 @@
var config = readConfig(documentObject);
if (!config) return null;
var controller = createController(windowObject, documentObject, config);
- var root = documentObject.getElementById('td-shell-search');
- var input = root && root.querySelector('.td-shell-search__input');
- var list = root && root.querySelector('.td-shell-search__list');
- var syncing = false;
-
- function bind(button) {
+ documentObject.querySelectorAll('[data-hg-ask-ai]').forEach(function
(button) {
if (button.dataset.hgAiBound !== undefined) return;
button.dataset.hgAiBound = '';
button.addEventListener('click', function () {
- controller.activate(
- button.dataset.hgAiQuery || '',
- button.dataset.hgAiSubmit === 'true',
- button,
- );
+ controller.activate('', false, button);
});
- }
- documentObject.querySelectorAll('[data-hg-ask-ai]').forEach(bind);
-
- if (!input || !list) return controller;
+ });
- // Keep the OINK palette untouched: only intercept Enter when local search
- // is empty and the site-owned Ask AI tail is the available follow-up.
- input.addEventListener('keydown', function (event) {
- if (event.isComposing || event.keyCode === 229 || event.key !== 'Enter')
return;
- var empty = list.querySelector('.td-shell-search__empty');
- var localRow =
list.querySelector('.td-shell-search__item:not(.hg-ai-search-tail__button)');
- var tailButton = list.querySelector('[data-hg-ai-search-tail]
[data-hg-ask-ai]');
- if (!empty || localRow || !tailButton) return;
- event.preventDefault();
- event.stopImmediatePropagation();
- controller.activate(input.value, true, tailButton);
- }, true);
-
- function syncTail() {
- syncing = false;
- if (!root || !input || !list || root.hidden) return;
- var old = list.querySelector('[data-hg-ai-search-tail]');
- var query = trimmedQuery(input.value);
- if (!query || query.charAt(0) === '>') {
- if (old) old.remove();
- return;
- }
- var choiceLabel = root.dataset.tdTChoice || '';
- if (
- choiceLabel &&
- Array.prototype.some.call(
- list.querySelectorAll('.td-shell-search__group-label'),
- function (label) { return label.textContent.trim() === choiceLabel;
},
- )
- ) {
- if (old) old.remove();
- return;
- }
- var loading = root.dataset.tdTLoading || '';
- if (
- loading &&
- Array.prototype.some.call(
- list.querySelectorAll('.td-shell-search__empty'),
- function (node) { return node.textContent.trim() === loading; },
- )
- ) {
- if (old) old.remove();
- return;
- }
- var empty = list.querySelector('.td-shell-search__empty');
- if (empty && config.labels.noResults) empty.textContent =
config.labels.noResults;
- var oldButton = old && old.querySelector('[data-hg-ask-ai]');
- if (oldButton && oldButton.dataset.hgAiQuery === query) return;
- if (old) old.remove();
-
- var group = documentObject.createElement('div');
- group.className = 'td-shell-search__group hg-ai-search-tail';
- group.dataset.hgAiSearchTail = '';
- group.setAttribute('role', 'group');
- var label = documentObject.createElement('div');
- label.className = 'td-shell-search__group-label';
- label.textContent = config.labels.ask;
- var row = documentObject.createElement('button');
- row.type = 'button';
- row.className = 'td-shell-search__item hg-ai-search-tail__button';
- row.dataset.hgAskAi = '';
- row.dataset.hgAiQuery = query;
- row.dataset.hgAiSubmit = 'true';
- var icon = documentObject.createElement('i');
- icon.className =
- 'fa-solid fa-wand-magic-sparkles td-shell-search__item-icon';
- icon.setAttribute('aria-hidden', 'true');
- var meta = documentObject.createElement('span');
- meta.className = 'td-shell-search__item-meta';
- var title = documentObject.createElement('span');
- title.className = 'td-shell-search__item-title';
- title.textContent = config.labels.ask + ': “' + query + '”';
- var detail = documentObject.createElement('span');
- detail.className = 'td-shell-search__item-ref';
- detail.textContent = config.historical ? config.labels.latest + '.' : '';
- meta.appendChild(title);
- meta.appendChild(detail);
- row.appendChild(icon);
- row.appendChild(meta);
- group.appendChild(label);
- group.appendChild(row);
- list.appendChild(group);
- bind(row);
- }
-
- if (list) {
- new MutationObserver(function () {
- if (syncing) return;
- syncing = true;
- windowObject.requestAnimationFrame(syncTail);
- }).observe(list, { childList: true, subtree: true });
- input.addEventListener('input', syncTail);
- syncTail();
+ var palette = windowObject.OinkCommandPalette;
+ if (palette && typeof palette.registerSearchTail === 'function') {
+ palette.registerSearchTail({
+ id: 'hugegraph-ai',
+ rows: function (context) {
+ return [{
+ id: 'ask',
+ title: config.labels.ask + ': “' + context.query + '”',
+ description: config.historical ? config.labels.latest + '.' : '',
+ icon: 'fa-solid fa-wand-magic-sparkles',
+ }];
+ },
+ activate: function (_, context) {
+ // Search options are ephemeral and become hidden on handoff.
+ var trigger = documentObject.querySelector('.hg-ask-ai-launcher');
+ return controller.activate(context.query, true, trigger, context);
Review Comment:
Addressed in 7477493fee on #496. A stale row is re-rendered and activated
through the pinned palette instance API, refreshing both the query and
cancellation context. This also prevents the delayed render from cancelling the
new consent dialog. A real OINK browser regression fails on the previous
artifact and passes on the fix, including a wait beyond the debounce interval.
##########
assets/js/hugegraph-shell.js:
##########
@@ -32,245 +31,59 @@
}
}
- function setTreeExpanded(button, expanded, documentObject) {
- var target = documentObject.getElementById(
- button.getAttribute('aria-controls'),
- );
- if (!target) return;
- button.setAttribute('aria-expanded', expanded ? 'true' : 'false');
- target.classList.toggle('td-is-open', expanded);
- var label = expanded
- ? button.dataset.tdLabelCollapse
- : button.dataset.tdLabelExpand;
- if (label) button.setAttribute('aria-label', label);
- }
-
function initTreePersistence(windowObject, documentObject, config) {
- var buttons = Array.prototype.slice.call(
-
documentObject.querySelectorAll('[data-td-shell-tree-toggle][aria-controls]'),
- );
- if (!buttons.length) return;
- var storage = safeStorage(windowObject);
- var key =
- 'oink.sidebar.v2.' +
- String(config.version || 'latest') +
- '.' +
- String(config.locale || 'en');
- var valid = new Set(
- buttons.map(function (button) {
+ var sidebar = windowObject.OinkSidebar;
+ if (!sidebar) return;
+ return sidebar.ready.then(function () {
+ var buttons = Array.prototype.slice.call(documentObject.querySelectorAll(
+ '#td-shell-sidebar [data-td-shell-tree-toggle][aria-controls]',
Review Comment:
Addressed in 7477493fee on #496. Aside disclosures now participate in
restore/persistence. Preferences migrate to v3: legacy v2 retains main-tree
choices and keeps the theme default for previously unrecorded aside state; a v3
empty set still records explicit collapse. Unit tests cover migration and
reload, alongside the browser persistence regression.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]