MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / renderWikiRelations

Function renderWikiRelations

deployments/desktop/static/desktop.js:3945–3981  ·  view source on GitHub ↗
(nodeId)

Source from the content-addressed store, hash-verified

3943 }
3944
3945 function renderWikiRelations(nodeId) {
3946 const current = graphNodesById()[nodeId];
3947 const semanticPapers = current?.related_papers || [];
3948 const allRelated = semanticPapers.length
3949 ? semanticPapers.map((node) => ({ node, edge: { relation: ui().wiki.relatedPapers, weight: Number(node.score || 1) || 1 } }))
3950 : nodeId ? relatedWikiNodes(nodeId) : [];
3951 const paperRelated = allRelated.filter(({ node }) => graphType(node) === "paper");
3952 const related = [
3953 ...paperRelated,
3954 ...allRelated.filter(({ node }) => graphType(node) !== "paper")
3955 ].slice(0, 4);
3956 if (!related.length) {
3957 const fallbackNodes = state.wikiGraph?.nodes?.length ? state.wikiGraph.nodes.slice(0, 10) : state.wikiNodes.slice(0, 10);
3958 renderWikiResultNodes(fallbackNodes.filter((node) => graphId(node) !== nodeId), fallbackNodes.length ? ui().wiki.graphNodes : ui().wiki.itemCount(0));
3959 return;
3960 }
3961
3962 $("wikiResults").className = "result-list";
3963 $("wikiResults").innerHTML = related.map(({ node, edge }) => `
3964 <button class="result-item relationship-row" data-node-id="${escapeHtml(graphId(node))}" data-node-title="${escapeHtml(rawGraphTitle(node))}" data-node-body="${escapeHtml(rawGraphBody(node))}" type="button">
3965 <h3>${escapeHtml(graphTitle(node))} <span class="status-chip">${escapeHtml(graphTypeLabel(node))}</span></h3>
3966 <p>${escapeHtml(graphBody(node) || ui().wiki.noSummary)}</p>
3967 <div class="evidence-meta">
3968 <span>${escapeHtml(relationLabel(edge.relation))}</span>
3969 <span>${Math.round(graphWeight(edge) * 100)}%</span>
3970 ${node.file_path ? `<span>${escapeHtml(node.file_path)}</span>` : ""}
3971 </div>
3972 </button>
3973 `).join("");
3974 $("wikiEvidenceSummary").textContent = ui().wiki.relationCount(related.length);
3975 renderWikiTags([
3976 current ? graphTypeLabel(current) : "",
3977 ...(String(current?.keywords || "").split(/[,\s]+/)),
3978 ...related.map(({ edge }) => relationLabel(edge.relation)),
3979 ...related.map(({ node }) => graphTypeLabel(node))
3980 ]);
3981 }
3982
3983 function renderWikiEntryHtml(body) {
3984 const content = String(body || "").trim();

Callers 2

applyLocaleFunction · 0.85
setWikiEntryFunction · 0.85

Calls 15

graphNodesByIdFunction · 0.85
uiFunction · 0.85
relatedWikiNodesFunction · 0.85
graphTypeFunction · 0.85
renderWikiResultNodesFunction · 0.85
graphIdFunction · 0.85
rawGraphTitleFunction · 0.85
rawGraphBodyFunction · 0.85
graphTitleFunction · 0.85
graphTypeLabelFunction · 0.85
graphBodyFunction · 0.85
relationLabelFunction · 0.85

Tested by

no test coverage detected