diff --git a/api/server.py b/api/server.py index 4ba1b0a..3455571 100644 --- a/api/server.py +++ b/api/server.py @@ -464,6 +464,24 @@ def download_single_pdf(arxiv_id: str): except subprocess.TimeoutExpired: return {"ok": False, "arxiv_id": arxiv_id, "status": "timeout"} +# ─── Routes: Translated PDFs ──────────────────────────── +TRANSLATED_DIR = PAPERS_DIR / "translated" + +@app.get("/api/translated/{arxiv_id}") +def check_translation(arxiv_id: str): + """Check if translation exists for a paper""" + fn = f"{arxiv_id}.pdf" + return {"arxiv_id": arxiv_id, "exists": (TRANSLATED_DIR / fn).exists()} + +@app.get("/papers/translated/{arxiv_id}.pdf") +def serve_translated(arxiv_id: str): + """Serve translated PDF from cache""" + fp = TRANSLATED_DIR / f"{arxiv_id}.pdf" + if not fp.exists(): + raise HTTPException(status_code=404, detail="Translation not found") + return FileResponse(fp, media_type="application/pdf", + headers={"Content-Disposition": "inline"}) + # ─── Health ───────────────────────────────────────────── @app.get("/api/health") def health(): diff --git a/papers/translated/Attention_Is_All_You_Need_CN.pdf b/papers/translated/Attention_Is_All_You_Need_CN.pdf new file mode 100644 index 0000000..9ca9a65 Binary files /dev/null and b/papers/translated/Attention_Is_All_You_Need_CN.pdf differ diff --git a/requirements.txt b/requirements.txt index d71dac4..a4ff6e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ pydantic>=2.10 python-multipart>=0.0.19 aiofiles>=24.0 tqdm>=4.66 -PyMuPDF>=1.24 +fpdf2>=2.7 diff --git a/static/app.js b/static/app.js index 94f0592..bff1666 100644 --- a/static/app.js +++ b/static/app.js @@ -151,6 +151,7 @@ function renderPaper(p) { const links = []; if (pdfUrl) links.push(``); else if (p.arxiv) links.push(`📋 arXiv`); + if (p.arxiv) links.push(`📖 译文`); return `
${p.year||'—'}
${p.title}
${p.authors||''}${p.venue?`${p.venue}`:''}${tags}
diff --git a/static/index.html b/static/index.html index 90ee027..b687345 100644 --- a/static/index.html +++ b/static/index.html @@ -183,6 +183,7 @@ function renderPaper(p) { const links = []; if (pdfUrl) links.push(``); else if (p.arxiv) links.push(`📋 arXiv`); + if (p.arxiv) links.push(`📖 译文`); return `
${p.year||'—'}
${p.title}
${p.authors||''}${p.venue?`${p.venue}`:''}${tags}