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

Function normalizeCitationSource

deployments/desktop/static/desktop.js:4178–4202  ·  view source on GitHub ↗
(source, index = 0)

Source from the content-addressed store, hash-verified

4176 }
4177
4178 function normalizeCitationSource(source, index = 0) {
4179 const metadata = source?.metadata || {};
4180 const citationIndex = Number(source?.index || index + 1);
4181 const nodeType = source?.node_type || source?.type || "";
4182 const sourceType = source?.source_type || "";
4183 const sourceId = source?.source_id || "";
4184 const rawMeta = source?.meta || [sourceType, sourceId].filter(Boolean).join(" · ") || ui().chat.sourceDefault;
4185 const meta = state.locale === "en"
4186 ? String(rawMeta).replaceAll("精读报告", "Reading report").replaceAll("论文推荐", "Paper recommendation").replaceAll("手动导入", "Manual import").replaceAll("参考文献", "Reference")
4187 : rawMeta;
4188 const title = String(source?.title || source?.node_id || ui().chat.sourceTitle(citationIndex)).replace(/^Wiki:\s*/i, "").replace(/^Q\d+[\s:-]*/i, "");
4189 return {
4190 index: citationIndex,
4191 node_id: source?.node_id || source?.id || "",
4192 node_type: nodeType,
4193 title: localizeWikiText(title),
4194 meta: localizeWikiText(meta),
4195 snippet: localizeWikiText(source?.snippet || source?.excerpt || source?.body || ""),
4196 source_type: sourceType,
4197 source_id: sourceId,
4198 anchor: source?.anchor || "",
4199 url: source?.url || metadata.url || metadata.abs_url || metadata.pdf_url || "",
4200 metadata
4201 };
4202 }
4203
4204 function normalizeCitations(data) {
4205 const raw = Array.isArray(data?.citations) && data.citations.length ? data.citations : data?.sources;

Callers 2

normalizeCitationsFunction · 0.85
renderChatSourcesFunction · 0.85

Calls 2

uiFunction · 0.85
localizeWikiTextFunction · 0.85

Tested by

no test coverage detected