Refactor code editor out of main UI + PubMed FTP PDF + login token fix
- Move code editor to standalone page; remove from main index/app mode switcher - Add diff-active tab highlight and diff bar CSS to styles - Add markdown table styles for chat messages - PubMed: try NCBI FTP link before Unpaywall for PDF download - Login: also persist token to localStorage for cross-tab auth - Update skills state and config Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+9
-14
@@ -317,6 +317,13 @@ export const pubmedFulltextTool = {
|
||||
}
|
||||
|
||||
if (args?.format === 'pdf') {
|
||||
// Extract FTP PDF link directly from OA API XML (most reliable source)
|
||||
let ftpPdfUrl = '';
|
||||
const ftpMatch = oaXml.match(/href="(ftp:\/\/[^"]+\.pdf)"/i);
|
||||
if (ftpMatch) {
|
||||
ftpPdfUrl = ftpMatch[1].replace('ftp://ftp.ncbi.nlm.nih.gov/', 'https://ftp.ncbi.nlm.nih.gov/');
|
||||
}
|
||||
|
||||
// PDF mode: get DOI via single PMC esummary call, then Unpaywall
|
||||
const apiKey = getPubMedApiKey();
|
||||
const sumParams = new URLSearchParams({ db: 'pmc', id: numericId, retmode: 'json' });
|
||||
@@ -336,19 +343,7 @@ export const pubmedFulltextTool = {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
if (!pdfUrl) {
|
||||
return {
|
||||
success: false,
|
||||
error: [
|
||||
`No downloadable PDF found for ${pmcid}${doi ? ` (DOI: ${doi})` : ''}.`,
|
||||
`The article is OA but the PDF is not accessible via Unpaywall.`,
|
||||
`Try format "text" to get the plain-text version instead.`,
|
||||
doi ? `Publisher page: https://doi.org/${doi}` : '',
|
||||
].filter(Boolean).join('\n'),
|
||||
};
|
||||
}
|
||||
|
||||
// Download PDF — try Unpaywall URL first, then Europe PMC as fallback
|
||||
// Download PDF — try NCBI FTP first, then Unpaywall, then Europe PMC
|
||||
const workspaceDir = getWorkspacePath(args);
|
||||
const pdfDir = path.join(workspaceDir, 'pubmed');
|
||||
fs.mkdirSync(pdfDir, { recursive: true });
|
||||
@@ -358,7 +353,7 @@ export const pubmedFulltextTool = {
|
||||
: path.join(pdfDir, `${pmcid}.pdf`);
|
||||
|
||||
const europePmcUrl = `https://europepmc.org/api/getPdf?pmcid=${pmcid}`;
|
||||
const urlsToTry = [pdfUrl, europePmcUrl].filter(Boolean);
|
||||
const urlsToTry = [ftpPdfUrl, pdfUrl, europePmcUrl].filter(Boolean);
|
||||
|
||||
let pdfBuf: Buffer | null = null;
|
||||
let usedUrl = '';
|
||||
|
||||
Reference in New Issue
Block a user