Skip to content

feat(core): add content_html and content_text fallbacks for all feed formats - #22852

Open
gosxrgxx wants to merge 3 commits into
DIYgod:masterfrom
gosxrgxx:core/item-content
Open

feat(core): add content_html and content_text fallbacks for all feed formats#22852
gosxrgxx wants to merge 3 commits into
DIYgod:masterfrom
gosxrgxx:core/item-content

Conversation

@gosxrgxx

Copy link
Copy Markdown
Contributor

Involved Issue / 该 PR 相关 Issue

Close #

Example for the Proposed Route(s) / 路由地址示例

NOROUTE

New RSS Route Checklist / 新 RSS 路由检查表

  • New Route / 新的路由
  • Anti-bot or rate limit / 反爬/频率限制
    • If yes, do your code reflect this sign? / 如果有, 是否有对应的措施?
  • Date and time / 日期和时间
    • Parsed / 可以解析
    • Correct time zone / 时区正确
  • New package added / 添加了新的包
  • Puppeteer

Note / 说明

Atom

Atom, like JSON Feed, supports content.text (via the type="text" attribute), but unlike JSON Feed, the Atom element (atom:entry) must not contain more than one content element.

Therefore, a condition was added for Atom where content with the type="text" attribute acts as a fallback if content.html is missing.

If content is empty, it must contain a link (item.link) to the content in the src attribute.

RSS

Also, content.html and content.text were added as fallbacks for RSS 2.0. This removes the need to include a description when creating new routes, allowing the use of clearer options like content.html and content.text. At the same time, this keeps backward compatibility with old routes.

JSON Feed

item.title must be rendered in content_html only if content.text is not provided, to prevent getting the text content in content_text and the title in content_html. Also, since item.title is text content, it must be a fallback for content_text instead of content_html.

@github-actions

Copy link
Copy Markdown
Contributor

Auto Review

This PR only touches core view files (no route scripts), so the route-metadata rules in AGENTS.md / pr_review_rules.md don't apply. Two concrete issues in the changed lines:

Consistency

  • lib/views/rss.tsx:41 vs lib/views/atom.tsx:23 and lib/views/json.ts:23: the fallback precedence is inverted between formats. RSS uses item.description || item.content?.html || item.content?.text, while Atom and JSON Feed use item.content?.html || item.description. For an item that sets both description and content.html with different values, the same feed renders different content depending on the requested format.
    • Fix: pick one order (e.g. item.content?.html || item.description everywhere, matching Atom/JSON) and apply it in rss.tsx too.

Correctness / middleware coverage

  • lib/views/* (all three files): the PR description states this "removes the need to include a description when creating new routes". However, all post-processing middleware operates on item.description only — lib/middleware/anti-hotlink.ts:147, and in lib/middleware/parameter.ts: mode=fulltext (:106, :325), filter*/filterout* (:202, :218, :247), opencc (:399) and the OpenAI options (:336, :359). A route that sets only content.html/content.text would therefore silently lose anti-hotlink rewriting, full-text mode, content filtering, opencc and AI summarization.
    • Fix: normalize content.html/content.text into item.description (or make the middleware read the same resolved value) once, before the middleware chain, instead of resolving the fallback separately in each view. That also removes the duplicated fallback logic flagged above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant