Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/convert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ jobs:
- name: Install dependencies
run: pip install -r requirements.txt

- name: Install Calibre
run: |
sudo apt-get update
sudo apt-get install -y calibre fonts-noto-cjk

- name: Process content
run: python scripts/process.py
env:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

GitHub-hosted content shelf. Fork, upload, done.

> Fork this repo to get your own content platform on GitHub Pages. Upload PDFs or EPUBs (published as online books), Markdown documents (rendered directly), or ZIP archives (deployed as static sites). Zero server cost.
> Fork this repo to get your own content platform on GitHub Pages. Upload PDFs or EPUBs (converted into online books), Markdown documents (rendered directly), or ZIP archives (deployed as static sites). Zero server cost.

## Quick Start

Expand All @@ -17,14 +17,14 @@ GitHub-hosted content shelf. Fork, upload, done.

Your site is now live at `https://<your-username>.github.io/gitshelf/`

### 2. Add MinerU Token (for PDF conversion)
### 2. Add MinerU Token (for PDF and EPUB conversion)

1. Register at [mineru.net](https://mineru.net) (free during beta)
2. Copy your API token
3. In your fork, go to **Settings > Secrets and variables > Actions**
4. Click **New repository secret**, name it `MINERU_TOKEN`, paste the token

> Only needed if you want to upload PDFs. EPUB, Markdown, and ZIP uploads work without this.
> Needed for book uploads. EPUB files are converted to PDF first, then processed by the same MinerU pipeline as PDFs.

### 3. Password Protection (Optional)

Expand All @@ -41,7 +41,7 @@ Your site is now live at `https://<your-username>.github.io/gitshelf/`
([Create one here](https://github.com/settings/tokens/new?scopes=repo&description=GitShelf))
3. Upload a file:
- **`.pdf`** — Converted to a multi-chapter book via MinerU API
- **`.epub`** — Stored as-is and read directly in the browser with TOC navigation
- **`.epub`** — Converted to PDF with Calibre, then processed through the same chapter pipeline as PDFs
- **`.md`** — Rendered directly as a document
- **`.zip`** — Extracted as a static site (must contain `index.html`)
4. Wait for GitHub Actions to process (progress shown in Actions tab)
Expand All @@ -68,7 +68,7 @@ Your site is now live at `https://<your-username>.github.io/gitshelf/`
Upload content (browser → GitHub API → input/)
→ GitHub Actions runs scripts/process.py
→ .pdf: MinerU API → Markdown → Split chapters → docs/books/{id}/
→ .epub: Store original EPUB + extract TOC → docs/books/{id}/
→ .epub: Calibre → PDF → MinerU API → Markdown → Split chapters → docs/books/{id}/
→ .md: Copy to docs/articles/{id}/content.md
→ .zip: Extract to docs/sites/{id}/
→ Build manifest → GitHub Pages deploys
Expand All @@ -90,7 +90,7 @@ python -m unittest discover -s tests/scripts -v # Python pipeline tests

**What if MinerU stops being free?** Swap it by modifying `scripts/mineru_client.py`. Works with any PDF-to-Markdown tool.

**Can I edit converted chapters?** Yes for PDF-converted books. Edit `.md` files in `docs/books/<id>/chapters/` and commit. EPUB books are read from the original `book.epub`.
**Can I edit converted chapters?** Yes. Books uploaded as either PDF or EPUB end up as generated Markdown chapters in `docs/books/<id>/chapters/`, which you can edit and commit.

**Can I upload a static site?** Yes. Package it as a `.zip` with `index.html` at the root and upload through the admin panel.

Expand Down
12 changes: 6 additions & 6 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

基于 GitHub 的内容托管平台。Fork,上传,搞定。

> Fork 本仓库即可拥有自己的内容平台。上传 PDF 或 EPUB(发布为在线书籍)、Markdown 文档(直接渲染)、ZIP 压缩包(部署为静态站点),全部托管在 GitHub Pages 上。零服务器成本。
> Fork 本仓库即可拥有自己的内容平台。上传 PDF 或 EPUB(转换后发布为在线书籍)、Markdown 文档(直接渲染)、ZIP 压缩包(部署为静态站点),全部托管在 GitHub Pages 上。零服务器成本。

## 快速开始

Expand All @@ -17,14 +17,14 @@

站点已上线:`https://<your-username>.github.io/gitshelf/`

### 2. 添加 MinerU Token(用于 PDF 转换)
### 2. 添加 MinerU Token(用于 PDF 和 EPUB 转换)

1. 在 [mineru.net](https://mineru.net) 注册(测试期免费)
2. 复制 API Token
3. 在你的 Fork 中,进入 **Settings > Secrets and variables > Actions**
4. 点击 **New repository secret**,名称填 `MINERU_TOKEN`,粘贴 Token

> 仅上传 PDF 时需要。EPUB、Markdown 和 ZIP 上传无需此配置。
> 书籍上传都需要。EPUB 会先经由 Calibre 转成 PDF,再进入和 PDF 相同的 MinerU 处理流水线。

### 3. 密码保护(可选)

Expand All @@ -41,7 +41,7 @@
([点此创建](https://github.com/settings/tokens/new?scopes=repo&description=GitShelf))
3. 上传文件:
- **`.pdf`** — 通过 MinerU API 转换为多章节书籍
- **`.epub`** — 原样保存,并在浏览器中直接阅读,保留目录导航
- **`.epub`** — 先用 Calibre 转成 PDF,再复用和 PDF 相同的章节转换流程
- **`.md`** — 直接作为文档渲染展示
- **`.zip`** — 解压为静态站点(需包含 `index.html`)
4. 等待 GitHub Actions 处理完成
Expand All @@ -68,7 +68,7 @@
上传内容(浏览器 → GitHub API → input/)
→ GitHub Actions 运行 scripts/process.py
→ .pdf: MinerU API → Markdown → 拆分章节 → docs/books/{id}/
→ .epub: 保存原始 EPUB + 提取目录 → docs/books/{id}/
→ .epub: Calibre → PDF → MinerU API → Markdown → 拆分章节 → docs/books/{id}/
→ .md: 复制到 docs/articles/{id}/content.md
→ .zip: 解压到 docs/sites/{id}/
→ 构建 manifest → GitHub Pages 部署
Expand All @@ -90,7 +90,7 @@ python -m unittest discover -s tests/scripts -v # Python 流水线测试

**MinerU 收费了怎么办?** 修改 `scripts/mineru_client.py` 即可替换,兼容任何 PDF 转 Markdown 工具。

**可以手动编辑转换后的章节吗?** PDF 转换得到的书籍可以。编辑 `docs/books/<id>/chapters/` 下的 `.md` 文件并提交即可。EPUB 书籍则直接读取原始 `book.epub`。
**可以手动编辑转换后的章节吗?** 可以。无论上传的是 PDF 还是 EPUB,最终都会生成 `docs/books/<id>/chapters/` 下的 Markdown 章节文件,可以直接编辑并提交。

**可以上传静态站点吗?** 可以。将站点打包为 `.zip`(根目录需包含 `index.html`),通过管理面板上传即可。

Expand Down
9 changes: 0 additions & 9 deletions cli/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,9 @@ async function listRepoTree(repo, path, token) {

async function getCacheDeleteOps(repo, itemId, token) {
let pdfMd5;
let epubMd5;
try {
const f = await readJson(repo, `docs/books/${itemId}/meta.json`, token);
pdfMd5 = f.data?.pdf_md5;
epubMd5 = f.data?.epub_md5;
} catch { /* skip */ }
const ops = [];

Expand All @@ -189,13 +187,6 @@ async function getCacheDeleteOps(repo, itemId, token) {
.map((f) => ({ path: f.path, delete: true })));
}

if (epubMd5) {
const cacheFiles = await listRepoTree(repo, 'cache/epub', token);
ops.push(...cacheFiles
.filter((f) => f.name.startsWith(epubMd5))
.map((f) => ({ path: f.path, delete: true })));
}

return ops;
}

Expand Down
4 changes: 2 additions & 2 deletions cli/mcp-server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* GitShelf MCP Server
*
* GitShelf is a zero-cost GitHub Pages content platform. Upload PDFs or
* EPUBs (auto-converted to chapter books), Markdown (rendered as
* EPUBs (converted to PDF first, then into chapter books), Markdown (rendered as
* documents), or ZIP archives (deployed as static sites). Everything is
* processed by GitHub Actions and served from GitHub Pages.
*
Expand Down Expand Up @@ -42,7 +42,7 @@ const server = new McpServer(
version: '0.1.3',
},
{
instructions: 'GitShelf is a zero-cost GitHub Pages content platform. Upload PDFs or EPUBs (auto-converted to multi-chapter books with TOC and reader UI), Markdown files (rendered as documents), or ZIP archives (deployed as static sites). Everything is processed by GitHub Actions and served from GitHub Pages. Use these tools to browse, read, and manage GitShelf content.',
instructions: 'GitShelf is a zero-cost GitHub Pages content platform. Upload PDFs or EPUBs (EPUBs are converted to PDF first, then processed into multi-chapter books with TOC and reader UI), Markdown files (rendered as documents), or ZIP archives (deployed as static sites). Everything is processed by GitHub Actions and served from GitHub Pages. Use these tools to browse, read, and manage GitShelf content.',
},
);

Expand Down
Loading
Loading