vomebook commited on
Commit ·
e52d9cd
1
Parent(s): f03af42
fix(ui): restore original repository display and spoken names
Browse files
static/app.js
CHANGED
|
@@ -2862,7 +2862,7 @@ function updateSidebarExpandButton() {
|
|
| 2862 |
function updateSidebarHeader() {
|
| 2863 |
if (!DOM.sidebarTitle) return;
|
| 2864 |
const global = STATE.mode === "global";
|
| 2865 |
-
DOM.sidebarTitle.textContent = global ? "仓库列表" : (
|
| 2866 |
if (DOM.sidebarBackBtn) {
|
| 2867 |
if (global && document.activeElement === DOM.sidebarBackBtn) DOM.hamburgerBtn.focus({ preventScroll: true });
|
| 2868 |
DOM.sidebarBackBtn.hidden = global;
|
|
@@ -2978,9 +2978,9 @@ const ROUTER = {
|
|
| 2978 |
DOM.headerLogo.href = "https://huggingface.co/VoiceOfML";
|
| 2979 |
DOM.searchInput.placeholder = "搜索 VoiceOfML 数据仓库...";
|
| 2980 |
} else {
|
| 2981 |
-
DOM.headerTitle.textContent =
|
| 2982 |
DOM.headerLogo.href = "/";
|
| 2983 |
-
DOM.searchInput.placeholder = `搜索 ${
|
| 2984 |
}
|
| 2985 |
updateSidebarHeader();
|
| 2986 |
},
|
|
@@ -3137,7 +3137,7 @@ function renderRepoListItems(repos) {
|
|
| 3137 |
let html = "";
|
| 3138 |
for (const repo of repos) {
|
| 3139 |
const shortName = repo.name.split("/").pop();
|
| 3140 |
-
const label = escapeHTML(
|
| 3141 |
html += `<button type="button" class="repo-list-item" aria-label="打开仓库:${label}" data-repo="${escapeHTML(shortName)}"><svg aria-hidden="true" class="repo-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/></svg><span class="repo-name">${label}</span><span class="repo-count">${(repo.count || 0).toLocaleString()}</span></button>`;
|
| 3142 |
}
|
| 3143 |
DOM.sidebarContent.innerHTML = html;
|
|
@@ -3433,7 +3433,6 @@ function buildResultHTML(rec, idx) {
|
|
| 3433 |
const iconType = getFileIconType(rec.Extension);
|
| 3434 |
const titleHTML = highlightText(rec.File, STATE.query);
|
| 3435 |
const repoShort = escapeHTML((rec.Repo || "").split("/").pop());
|
| 3436 |
-
const repoLabel = escapeHTML(VoiceOfMLReader.repositoryLabel(rec.Repo));
|
| 3437 |
const sizeStr = formatSize(rec.Size);
|
| 3438 |
const recordLink = getRecordLink(rec);
|
| 3439 |
const recordPath = getRecordPath(rec);
|
|
@@ -3453,9 +3452,9 @@ function buildResultHTML(rec, idx) {
|
|
| 3453 |
<div class="result-file-icon" aria-hidden="true">${ICONS[iconType] || ICONS.file}</div>
|
| 3454 |
<div class="result-info">
|
| 3455 |
<div class="result-title">${titleHTML}${rec.Extension ? `<span style="opacity:0.5;font-size:12px">.${escapeHTML(rec.Extension)}</span>` : ""}</div>
|
| 3456 |
-
<div class="result-path"><span role="button" tabindex="0" class="path-folder" aria-label="筛选仓库路径:${
|
| 3457 |
<div class="result-meta">
|
| 3458 |
-
${STATE.mode === "global" ? `<button type="button" class="result-repo-tag" aria-label="打开仓库:${
|
| 3459 |
${sizeStr ? `<span class="result-size">${sizeStr}</span>` : ""}
|
| 3460 |
</div>
|
| 3461 |
</div>
|
|
@@ -4367,7 +4366,7 @@ async function renderFilters(routeId) {
|
|
| 4367 |
} catch (e) { }
|
| 4368 |
if (routeId && routeId !== routeRenderId) return;
|
| 4369 |
const repos = Array.isArray(STATE.repoList) ? STATE.repoList : [];
|
| 4370 |
-
renderCheckboxList(DOM.filterRepoList, repos.map(r => ({ key: r.name, label:
|
| 4371 |
} else {
|
| 4372 |
DOM.filterRepoSection.style.display = "none";
|
| 4373 |
}
|
|
|
|
| 2862 |
function updateSidebarHeader() {
|
| 2863 |
if (!DOM.sidebarTitle) return;
|
| 2864 |
const global = STATE.mode === "global";
|
| 2865 |
+
DOM.sidebarTitle.textContent = global ? "仓库列表" : (STATE.repo || "仓库");
|
| 2866 |
if (DOM.sidebarBackBtn) {
|
| 2867 |
if (global && document.activeElement === DOM.sidebarBackBtn) DOM.hamburgerBtn.focus({ preventScroll: true });
|
| 2868 |
DOM.sidebarBackBtn.hidden = global;
|
|
|
|
| 2978 |
DOM.headerLogo.href = "https://huggingface.co/VoiceOfML";
|
| 2979 |
DOM.searchInput.placeholder = "搜索 VoiceOfML 数据仓库...";
|
| 2980 |
} else {
|
| 2981 |
+
DOM.headerTitle.textContent = STATE.repo;
|
| 2982 |
DOM.headerLogo.href = "/";
|
| 2983 |
+
DOM.searchInput.placeholder = `搜索 ${STATE.repo}...`;
|
| 2984 |
}
|
| 2985 |
updateSidebarHeader();
|
| 2986 |
},
|
|
|
|
| 3137 |
let html = "";
|
| 3138 |
for (const repo of repos) {
|
| 3139 |
const shortName = repo.name.split("/").pop();
|
| 3140 |
+
const label = escapeHTML(shortName);
|
| 3141 |
html += `<button type="button" class="repo-list-item" aria-label="打开仓库:${label}" data-repo="${escapeHTML(shortName)}"><svg aria-hidden="true" class="repo-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/></svg><span class="repo-name">${label}</span><span class="repo-count">${(repo.count || 0).toLocaleString()}</span></button>`;
|
| 3142 |
}
|
| 3143 |
DOM.sidebarContent.innerHTML = html;
|
|
|
|
| 3433 |
const iconType = getFileIconType(rec.Extension);
|
| 3434 |
const titleHTML = highlightText(rec.File, STATE.query);
|
| 3435 |
const repoShort = escapeHTML((rec.Repo || "").split("/").pop());
|
|
|
|
| 3436 |
const sizeStr = formatSize(rec.Size);
|
| 3437 |
const recordLink = getRecordLink(rec);
|
| 3438 |
const recordPath = getRecordPath(rec);
|
|
|
|
| 3452 |
<div class="result-file-icon" aria-hidden="true">${ICONS[iconType] || ICONS.file}</div>
|
| 3453 |
<div class="result-info">
|
| 3454 |
<div class="result-title">${titleHTML}${rec.Extension ? `<span style="opacity:0.5;font-size:12px">.${escapeHTML(rec.Extension)}</span>` : ""}</div>
|
| 3455 |
+
<div class="result-path"><span role="button" tabindex="0" class="path-folder" aria-label="筛选仓库路径:${repoShort}" data-folder="" data-repo="${repoShort}">${repoShort}${repoSeparator}</span>${breadcrumb}</div>
|
| 3456 |
<div class="result-meta">
|
| 3457 |
+
${STATE.mode === "global" ? `<button type="button" class="result-repo-tag" aria-label="打开仓库:${repoShort}" data-repo="${repoShort}">${repoShort}</button>` : ""}
|
| 3458 |
${sizeStr ? `<span class="result-size">${sizeStr}</span>` : ""}
|
| 3459 |
</div>
|
| 3460 |
</div>
|
|
|
|
| 4366 |
} catch (e) { }
|
| 4367 |
if (routeId && routeId !== routeRenderId) return;
|
| 4368 |
const repos = Array.isArray(STATE.repoList) ? STATE.repoList : [];
|
| 4369 |
+
renderCheckboxList(DOM.filterRepoList, repos.map(r => ({ key: r.name, label: r.name.split("/").pop(), count: r.count })), STATE.filterRepos, (vals) => { STATE.filterRepos = vals; updateFilterCancelButtons(); scheduleFilterSearch(); });
|
| 4370 |
} else {
|
| 4371 |
DOM.filterRepoSection.style.display = "none";
|
| 4372 |
}
|
static/reader/core/reader-contract.js
CHANGED
|
@@ -518,26 +518,7 @@
|
|
| 518 |
return hash.toString(36).padStart(13, "0");
|
| 519 |
}
|
| 520 |
|
| 521 |
-
// Concise UI names from the datasets' Chinese README descriptions/link tables.
|
| 522 |
-
// Labels only: source IDs, matching, paths and routing keep their original keys.
|
| 523 |
-
const repositoryLabels = Object.freeze({
|
| 524 |
-
'A-Historical-Learning-Data': '推荐书单',
|
| 525 |
-
GPCREducation: '文革教材',
|
| 526 |
-
'Japanese-Materials': '日共资料',
|
| 527 |
-
'MLMRL-Hub': '待整理资料',
|
| 528 |
-
'MLMRL-Library': '重要书库',
|
| 529 |
-
Omnibus: '书纳百川',
|
| 530 |
-
SovMaterials: '苏联资料',
|
| 531 |
-
Teachers: '导师著作',
|
| 532 |
-
VOMEBOOK: '马列之声'
|
| 533 |
-
});
|
| 534 |
-
function repositoryLabel(value) {
|
| 535 |
-
const key = String(value || '').replace(/^VoiceOfML\//, '');
|
| 536 |
-
return Object.prototype.hasOwnProperty.call(repositoryLabels, key) ? repositoryLabels[key] : key.split('/').pop();
|
| 537 |
-
}
|
| 538 |
-
|
| 539 |
root.VoiceOfMLReader = Object.freeze({
|
| 540 |
-
repositoryLabel,
|
| 541 |
ReaderMode,
|
| 542 |
articleExtensions,
|
| 543 |
capability,
|
|
|
|
| 518 |
return hash.toString(36).padStart(13, "0");
|
| 519 |
}
|
| 520 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 521 |
root.VoiceOfMLReader = Object.freeze({
|
|
|
|
| 522 |
ReaderMode,
|
| 523 |
articleExtensions,
|
| 524 |
capability,
|
static/reader/core/reader-source.mjs
CHANGED
|
@@ -133,11 +133,10 @@ export function createReaderSource(readerContext) {
|
|
| 133 |
readerContext.folderNavigationTarget = new URL("/" + encodeURIComponent(data.repo), location.origin);
|
| 134 |
if (folder) readerContext.folderNavigationTarget.searchParams.set("folder_self", folder);
|
| 135 |
}
|
| 136 |
-
|
| 137 |
-
readerContext.readerPath.textContent = displayPath;
|
| 138 |
readerContext.readerPath.hidden = !value;
|
| 139 |
readerContext.readerPath.disabled = !readerContext.folderNavigationTarget;
|
| 140 |
-
readerContext.readerPath.setAttribute("aria-label", `筛选文件夹:${
|
| 141 |
}
|
| 142 |
|
| 143 |
function validSource(raw) {
|
|
|
|
| 133 |
readerContext.folderNavigationTarget = new URL("/" + encodeURIComponent(data.repo), location.origin);
|
| 134 |
if (folder) readerContext.folderNavigationTarget.searchParams.set("folder_self", folder);
|
| 135 |
}
|
| 136 |
+
readerContext.readerPath.textContent = value;
|
|
|
|
| 137 |
readerContext.readerPath.hidden = !value;
|
| 138 |
readerContext.readerPath.disabled = !readerContext.folderNavigationTarget;
|
| 139 |
+
readerContext.readerPath.setAttribute("aria-label", `筛选文件夹:${value}`);
|
| 140 |
}
|
| 141 |
|
| 142 |
function validSource(raw) {
|
tests/test_search_accessibility_browser.py
CHANGED
|
@@ -50,24 +50,24 @@ class SearchAccessibilityTests(unittest.TestCase):
|
|
| 50 |
self.assertTrue(self.page.locator('#current-result-position').is_hidden())
|
| 51 |
self.assertEqual(self.page.evaluate('document.activeElement.id'), 'edit-result-position')
|
| 52 |
|
| 53 |
-
def
|
| 54 |
-
expected =
|
| 55 |
-
'
|
| 56 |
-
'Omnibus':'书纳百川','SovMaterials':'苏联资料','Teachers':'导师著作','VOMEBOOK':'马列之声'}
|
| 57 |
observed = self.page.evaluate('''names=>{
|
| 58 |
routeRenderId++;
|
| 59 |
STATE.leftSidebarOpen=true;updateSidebarVisibility();
|
| 60 |
-
renderRepoListItems(
|
| 61 |
return Array.from(DOM.sidebarContent.querySelectorAll('.repo-list-item'),node=>
|
| 62 |
({id:node.dataset.repo,text:node.querySelector('.repo-name').textContent,label:node.getAttribute('aria-label')}));
|
| 63 |
}''', expected)
|
| 64 |
-
self.assertEqual(observed, [dict(id=key,text=
|
| 65 |
-
self.
|
| 66 |
self.page.evaluate("()=>{STATE.mode='global';const host=document.createElement('div');document.body.append(host);host.append(createResultRow({Repo:'VoiceOfML/Teachers',File:'book',Extension:'txt',Folder:[],Size:1},101))}")
|
| 67 |
row = self.page.locator('.result-item[data-index="101"]')
|
| 68 |
-
self.assertEqual(row.locator('.result-repo-tag').inner_text(), '
|
|
|
|
| 69 |
self.assertEqual(row.locator('.result-repo-tag').get_attribute('data-repo'), 'Teachers')
|
| 70 |
-
self.
|
| 71 |
|
| 72 |
def test_toolbar_actions_have_chinese_function_names_and_no_svg_noise(self):
|
| 73 |
self.assertIn(self.page.locator('#hamburger-btn').get_attribute('aria-label'), ['打开仓库导航','关闭仓库导航'])
|
|
|
|
| 50 |
self.assertTrue(self.page.locator('#current-result-position').is_hidden())
|
| 51 |
self.assertEqual(self.page.evaluate('document.activeElement.id'), 'edit-result-position')
|
| 52 |
|
| 53 |
+
def test_repository_display_and_accessible_names_keep_original_english_ids(self):
|
| 54 |
+
expected = ['A-Historical-Learning-Data', 'GPCREducation', 'Japanese-Materials',
|
| 55 |
+
'MLMRL-Hub', 'MLMRL-Library', 'Omnibus', 'SovMaterials', 'Teachers', 'VOMEBOOK']
|
|
|
|
| 56 |
observed = self.page.evaluate('''names=>{
|
| 57 |
routeRenderId++;
|
| 58 |
STATE.leftSidebarOpen=true;updateSidebarVisibility();
|
| 59 |
+
renderRepoListItems(names.map(name=>({name:'VoiceOfML/'+name,count:1})));
|
| 60 |
return Array.from(DOM.sidebarContent.querySelectorAll('.repo-list-item'),node=>
|
| 61 |
({id:node.dataset.repo,text:node.querySelector('.repo-name').textContent,label:node.getAttribute('aria-label')}));
|
| 62 |
}''', expected)
|
| 63 |
+
self.assertEqual(observed, [dict(id=key,text=key,label='打开仓库:'+key) for key in expected])
|
| 64 |
+
self.assertFalse(self.page.evaluate("'repositoryLabel' in VoiceOfMLReader"))
|
| 65 |
self.page.evaluate("()=>{STATE.mode='global';const host=document.createElement('div');document.body.append(host);host.append(createResultRow({Repo:'VoiceOfML/Teachers',File:'book',Extension:'txt',Folder:[],Size:1},101))}")
|
| 66 |
row = self.page.locator('.result-item[data-index="101"]')
|
| 67 |
+
self.assertEqual(row.locator('.result-repo-tag').inner_text(), 'Teachers')
|
| 68 |
+
self.assertEqual(row.locator('.result-repo-tag').get_attribute('aria-label'), '打开仓库:Teachers')
|
| 69 |
self.assertEqual(row.locator('.result-repo-tag').get_attribute('data-repo'), 'Teachers')
|
| 70 |
+
self.assertIn('Teachers', row.locator('.result-path').inner_text())
|
| 71 |
|
| 72 |
def test_toolbar_actions_have_chinese_function_names_and_no_svg_noise(self):
|
| 73 |
self.assertIn(self.page.locator('#hamburger-btn').get_attribute('aria-label'), ['打开仓库导航','关闭仓库导航'])
|