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
4 changes: 3 additions & 1 deletion configs/feed.preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const root = resolve(import.meta.dirname, "..");

export default defineConfig({
root: resolve(root, "renderer"),
optimizeDeps: { entries: ["feed-preview.html"], exclude: ["svelte/elements"] },
plugins: [
svelte({ configFile: resolve(root, "configs/svelte.config.js") }),
{
Expand Down Expand Up @@ -58,7 +59,8 @@ export default defineConfig({
let result: unknown;
switch (method) {
case "version": result = version; break;
case "getState": result = feed.getState(args[0] as FeedQuery); break;
case "getState": result = feed.getState(args[0] as FeedQuery, (args[1] ?? undefined) as string | undefined); break;
case "getRows": result = feed.getRows(args[0] as string[]); break;
case "getItem": result = feed.getItem(args[0] as string); break;
case "resolveSource": result = await feed.resolveSource(args[0] as FeedSourceInput); break;
case "discardSource": result = feed.discardSource(args[0] as string); break;
Expand Down
19 changes: 11 additions & 8 deletions configs/feed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ test("entries and read state survive refreshes and reopening the workspace; canc
assert.equal(service.getState({ read: "unread" }).total, 1);
assert.equal(service.getState({ keyword: "LANGUAGE" }).total, 2);
assert.equal(service.itemURL(item.id), item.url);
assert.throws(() => service.getState({ offset: -1 }));
assert.throws(() => service.getState({ order: "unknown" }));
assert.throws(() => service.getState({ read: "some" }));
session.close();
const reopened = openWorkspace(folder, undefined, { loadFeed: request => loaderOf(entries)(request) });
Expand Down Expand Up @@ -629,13 +629,13 @@ test("a result that arrives after its source was paused, cancelled or readdresse
}
});

test("concurrent refreshes share a request and results are paginated", async t => {
test("concurrent refreshes share a request and results are available in batches", async t => {
const { entries: [template] } = await parseFeed(rss, "https://example.org/feed");
let calls = 0;
const { service } = fixture(t, async request => {
calls++;
await new Promise(resolve => setTimeout(resolve, 10));
return fetched(Array.from({ length: 55 }, (_, i) => ({ ...template, externalId: `paper-${i}`, url: `https://example.org/papers/${i}` })), { url: request.url });
return fetched(Array.from({ length: 135 }, (_, i) => ({ ...template, externalId: `paper-${i}`, url: `https://example.org/papers/${i}` })), { url: request.url });
});
let notices = 0;
t.after(watchFeed(() => notices++));
Expand All @@ -644,9 +644,12 @@ test("concurrent refreshes share a request and results are paginated", async t =
await Promise.all([service.refresh(id), service.refresh(id)]);
assert.equal(calls, 2);
assert.ok(notices >= 2, "views are told when a refresh starts and when it ends");
assert.equal(service.getState({}).items.length, 50);
assert.equal(service.getState({ offset: 50 }).items.length, 5);
assert.equal(service.getState({}).total, 55);
const result = service.getState({});
assert.equal(result.total, 135);
assert.equal(result.ids.length, 135);
assert.ok(result.items.length < result.ids.length);
const tail = result.ids.slice(result.items.length);
assert.deepEqual(service.getRows(tail).map(row => row.id), tail);
});

test("a few sources are fetched at a time, and those waiting their turn already count as refreshing", async t => {
Expand Down Expand Up @@ -759,9 +762,9 @@ test("items are filtered by read state and followed keywords, ordered either way
// Undated items stay at the end in both directions.
assert.deepEqual(titles({ order: "oldest" }), ["Diffusion models", "Retrieval", "Agents", "A long abstract", "Undated note"]);
assert.deepEqual(titles({ sourceId: b, order: "oldest" }), ["Retrieval", "A long abstract"]);
// Lists carry an excerpt; the reader gets the whole text.
// Only the reader gets the full text.
const long = service.getState({}).items[0];
assert.equal(long.summary.length, 400);
assert.equal(Object.hasOwn(long, "summary"), false);
assert.equal(service.getItem(long.id).summary.length, 1000);

assert.deepEqual(titles({ followed: true }), [], "nothing is followed yet");
Expand Down
21 changes: 11 additions & 10 deletions docs/Feed实现说明.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Feed 用于追踪论文和实验室博客,完成“添加来源 → 自动抓

## 使用方式

进入工作区后,点击侧边栏的订阅图标打开 Feed。页面分三栏:左侧是来源,中间是条目列表,右侧阅读。窗口变窄时来源栏收进下拉框,更窄时列表和阅读区轮流显示。
进入工作区后,点击侧边栏的订阅图标打开 Feed。左边是来源,中间是条目列表,右边是阅读区。拖动分隔条可以调整来源栏和列表的宽度。窗口变窄时,来源栏收进工具栏的选择框。再窄时,打开条目后切到阅读区,可返回列表。

点击“添加来源”,选择添加方式并保存,保存时会立即抓取并校验来源。名称可以留空,此时使用来源自带的标题。
点击订阅工具栏或总览的“添加来源”,在对话框内选择添加方式并保存。保存时会立即抓取并校验来源。名称可以留空,此时使用来源自带的标题。

| 添加方式 | 抓取方式 | 每次导入范围 |
| --- | --- | --- |
Expand All @@ -29,17 +29,17 @@ Feed 用于追踪论文和实验室博客,完成“添加来源 → 自动抓
| 已暂停 | 不抓取,恢复后立即补抓 | 仍出现在“全部内容”和未读数中 |
| 已取消 | 不抓取 | 保留在“已取消”分组下,不计入“全部内容”和未读数;恢复订阅或再次添加同一地址会接续原来的历史 |

列表可以按来源查看,按已读或未读筛选,按发布时间正序或倒序排列,并搜索标题和摘要。“关注关键词”保存在工作区中,标题或摘要包含任一关键词的条目集中显示在该视图。未提供发布时间的条目标注“未提供时间”,在两种排序下都排在最后。
列表可按来源、阅读状态、发布时间排序方向或标题与摘要的搜索词查看。列表滚动时按需读取可见行,滚动条反映全部结果。来源、阅读状态、排序方向和栏宽随订阅标签页保存。“关注关键词”保存在工作区中,匹配任一关键词的条目集中显示。未提供发布时间的条目在两种排序下都排在最后。条目发布时间和来源上次刷新时间按设置中的时区显示,格式为 `yyyy-MM-dd HH:mm`。

打开条目会标为已读,可以改回未读,也可以把某个来源或全部来源标为已读。阅读区显示来源提供的正文(含图片和链接);来源只给摘要时会注明。可以调整正文字号、切换上一篇和下一篇、在浏览器中打开原文,再次打开同一条目时回到上次的阅读位置。
打开条目会标为已读,当前条目在筛选条件不变时仍留在列表中。连续使用方向键浏览时,停在某一条才打开正文。来源右键菜单和标签栏的更多菜单可刷新、编辑、暂停或取消订阅,也可以确认将某个来源或全部来源标为已读。条目右键菜单可更改阅读状态、打开原文、复制链接或加入文献库。阅读区沿用编辑器的正文字号,显示来源提供的正文并标明仅摘要的条目。工具栏可切换前后篇,再次打开同一条目时恢复阅读位置。

“加入文献库”为条目创建文献页,条目显示“已入库”并可直接打开该页。来源提供了 PDF 地址时,入库后会在后台下载 PDF,挂到文献的“附件”上,详见[加入文献库](#加入文献库)。
“加入文献库”为条目创建文献页,条目显示“已入库”并可直接打开该页。文献移入回收站、恢复或永久删除时,订阅只更新关联条目的标记、菜单和阅读区状态。来源提供了 PDF 地址时,入库后会在后台下载 PDF,挂到文献的“附件”上,详见[加入文献库](#加入文献库)。

### 来源即页面

订阅源是一种页面类型,来源名称就是页面标题,订阅地址、状态、刷新间隔和刷新结果都是它的属性:

- 订阅源页面和其他页面一样出现在知识库的列表和搜索中,类型筛选里有“订阅源”。在标签页里打开它,显示订阅视图并选中这个来源,不显示编辑器。正文不能写内容。
- 订阅源页面和其他页面一样出现在知识库的列表和搜索中,类型筛选里有“订阅源”。在标签页里打开它,来源名称和反向链接显示在上方,订阅列表固定在该来源。属性栏和页面操作仍可使用,标签栏的更多菜单也包含订阅操作。正文不能写内容。
- 删除来源就是把页面移进回收站:它不再刷新,它和它的条目也不在 Feed 中显示。从回收站恢复后,照原来的设置继续。
- 永久删除来源页面时,它的条目一并删除;已经加入文献库的文献不受影响。
- 订阅地址在所有没被永久删除的来源之间唯一,回收站里的也算。重新添加一个“已取消”来源的地址,会恢复那个来源。
Expand Down Expand Up @@ -74,9 +74,9 @@ flowchart TD
| [FeedView.svelte](../renderer/components/Feed/FeedView.svelte) | 来源栏、列表筛选、阅读区、刷新和阅读状态操作 |
| [SourceForm.svelte](../renderer/components/Feed/SourceForm.svelte) | 来源表单、博客预设、arXiv 查询条件和刷新设置 |
| [content.ts](../renderer/components/Feed/content.ts) | 把来源的 HTML 转成可安全显示的节点 |
| [labels.ts](../renderer/components/Feed/labels.ts) | 时间、间隔和来源状态的文字 |
| [labels.ts](../renderer/components/Feed/labels.ts) | 订阅时间和刷新间隔的显示,时间格式复用 [shared/content/time.ts](../shared/content/time.ts) |
| [shared/utils/feed.ts](../shared/utils/feed.ts) | URL 校验、原文地址规范化和 arXiv 地址生成 |
| [shared/types/feed.ts](../shared/types/feed.ts) | 前后端共享的数据结构和 `FeedAPI` 接口 |
| [shared/types/feed.ts](../shared/types/feed.ts) 和 [shared/feed/ipc.ts](../shared/feed/ipc.ts) | 前后端共享的数据结构与 `FeedAPI` 接口 |
| [main/feed/ipc.ts](../main/feed/ipc.ts) | 注册桌面端接口:校验参数后调用订阅服务 |
| [main/feed/service.ts](../main/feed/service.ts) | 来源管理、刷新排队、条目归并、查询、阅读状态、入库和 PDF 下载 |
| [main/feed/schedule.ts](../main/feed/schedule.ts) | 按来源的状态和刷新间隔维护它在定时表里的那一行 |
Expand Down Expand Up @@ -251,7 +251,8 @@ flowchart TD

| API | 作用 |
| --- | --- |
| `getState(query)` | 返回来源列表、当前页条目、匹配总数、未读总数和关注关键词 |
| `getState(query, around?)` | 返回匹配的完整排序 ID、锚点附近的一批行、来源及聚合未读数、匹配总数和关注关键词 |
| `getRows(ids)` | 读取指定 ID 的列表行,供订阅和总览按需补读 |
| `getItem(id)` | 返回单个条目的完整内容、阅读位置和文献状态 |
| `resolveSource(input)` | 解析订阅地址,返回本次会话的一次性凭据 |
| `saveSource(resolution)` | 保存解析后的来源和刷新间隔,返回来源 ID |
Expand All @@ -264,7 +265,7 @@ flowchart TD
| `importItem(id, replace?)` | 加入文献库,返回文献页 ID 和本次是否需要自动下载 PDF |
| `fetchPDF(id)` | 为已入库的条目下载 PDF,成功时返回文献页 ID 和附件 ID,供界面挂上 |
| `openItem(id)` | 从数据库读取原文地址,校验后调用系统浏览器 |
| `onChanged(listener)` | 订阅 `feed:changed` 通知。后台刷新、PDF 下载和在别处对来源页面的修改通过它让页面重新读取 |
| `onChanged(listener)` | 订阅 `feed:changed` 通知。后台刷新、PDF 下载和订阅源页面变化通过它通知订阅读取最新数据。文献的回收、恢复和永久删除通过页面变化通知更新已读取的关联条目 |

## 测试

Expand Down
89 changes: 87 additions & 2 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,93 @@
"label": "Interface language",
"hint": "Used for startup, errors and confirmations."
},
"feed": {
"sources": "Sources",
"noSources": "No sources",
"items": "Feed items",
"noItems": "No items",
"count": "{{count}} items",
"count_one": "{{count}} item",
"reader": "Article reader",
"all": "All items",
"followed": "Followed keywords",
"cancelledSources": "Cancelled sources",
"search": "Search titles or summaries",
"readFilter": "Read status",
"allReadStates": "All",
"unread": "Unread",
"read": "Read",
"newest": "Newest first",
"oldest": "Oldest first",
"refreshAll": "Refresh all",
"refreshing": "Refreshing",
"addSource": "Add source",
"sourceWidth": "Source pane width",
"listWidth": "Item list width",
"refresh": "Refresh",
"editSource": "Edit source",
"pause": "Pause fetching",
"resume": "Resume fetching",
"cancel": "Cancel subscription",
"resubscribe": "Resume subscription",
"markAllRead": "Mark all as read",
"paused": "Paused",
"cancelled": "Subscription cancelled",
"refreshFailed": "Refresh failed",
"lastRefreshed": "Last refreshed {{time}}",
"neverRefreshed": "Never refreshed",
"refreshInterval": "Every {{interval}}",
"manualRefresh": "Manual refresh",
"minutes": "{{count}} minutes",
"minutes_one": "{{count}} minute",
"minutes_other": "{{count}} minutes",
"hours": "{{count}} hours",
"hours_one": "{{count}} hour",
"hours_other": "{{count}} hours",
"addKeyword": "Add keyword",
"removeKeyword": "Remove keyword {{word}}",
"noTime": "No date provided",
"inLibrary": "In library",
"markRead": "Mark as read",
"markUnread": "Mark as unread",
"openOriginal": "Open original",
"copyLink": "Copy link",
"importPaper": "Add to paper library",
"importing": "Adding to paper library",
"openPaper": "Open paper page",
"retryPDF": "Fetch PDF again",
"fetchingPDF": "Fetching PDF",
"previous": "Previous article",
"next": "Next article",
"back": "Back to list",
"summaryOnly": "Summary only",
"sourceName": "Name",
"sourceMethod": "Add by",
"urlMethod": "Feed or website address",
"arxivMethod": "arXiv categories and keywords",
"address": "Feed address",
"discoverAddress": "Enter a website’s home page to find the feed it provides.",
"arxivCategories": "Categories",
"arxivKeyword": "Keyword or phrase",
"arxivCategoriesRule": "Separate categories with commas to match any of them.",
"arxivKeywordRule": "Keywords match full phrases in titles or summaries.",
"autoRefresh": "Automatic refresh",
"interval": "Refresh interval",
"validateAndSave": "Validate and save",
"saving": "Saving…",
"exampleName": "Example: AI / machine learning (large language model)"
},
"overview": {
"recent": "Recently opened",
"todo": "To do",
"unread": "Unread feeds",
"noRecent": "No recently opened pages",
"noTodo": "No tasks",
"noUnread": "No unread feed items",
"missingStatus": "Status property not found",
"chooseStatus": "Choose status property",
"chooseDate": "Choose date property"
},
"dialog": {
"close": "Close",
"cancel": "Cancel",
Expand Down Expand Up @@ -415,7 +502,6 @@
"trashView": "Recycle Bin",
"pinnedView": "Pinned Pages",
"calendarView": "Research Calendar",
"overviewView": "My Garden",
"feedView": "Feed Activity",
"targetDeleted": "Target has been deleted"
},
Expand Down Expand Up @@ -598,7 +684,6 @@
"removeItem": "Remove {{name}}",
"json": "JSON value",
"hour": "Hour",
"hourValue": "{{hour}}:00",
"year": "Four-digit year",
"addTag": "Add tag…",
"createTag": "Create tag {{name}}",
Expand Down
Loading
Loading