gutenberg
gutenberg copied to clipboard
WIP: RSS Block: Improve handling of feed items with empty titles.
What?
This PR handles RSS feed items with empty titles by taking the first 𝒙 characters from the post excerpt and "moving them across" to become the feed item's title. The effect is inspired by https://github.com/scripting/titlelessFeedsHowto
Why?
It was highlighted by Dave Winer's post about how RSS feed readers can display a consistent view of items that may or may not have titles without resorting to adding "(No Title)" placeholder text.
http://scripting.com/2022/12/08.html#a152840
He also created this example implementation https://github.com/scripting/titlelessFeedsHowto
Matt then reached out to the team about seeing whether we could implement this idea in wordpress
How?
using a new titleLength
property and a regex based filter in the render method. I used characters rather than words because I think it's good for titles to have a somewhat consistent length, which is better measured with characters.
Testing Instructions
- Insert an RSS feed block
- Configure it to subscribe to a feed where some items are missing titles. e.g.
http://scripting.com/rss.xml
- It should have a settings slider to select the maximum title length
- If a feed item has no title, it should use the first
titleLength
characters followed by an ellipsis. The characters/words used for the title should be removed from the post excerpt so that no words are duplicated or repeated between the title and excerpt. - The title should be trimmed to the nearest word boundary, if a period character is present, it should be used as the end of the title.
- The effect should be achieved in both the editor and the live site.
Note that this will also truncate author's titles to titleLength
characters which I've set to default to 75
.
Screenshots or screencast
Before
After
The title "Mastodon and RSS, as precedents" is author specified, the others are taken from the excerpt.
https://user-images.githubusercontent.com/22446385/208328437-c0a5b034-3c10-45da-ba8c-f470fc6774fa.mov
Code was written by @davemart-in originally, who's is going on holiday leave. I will handle feedback etc.
Size Change: -1.73 kB (0%)
Total Size: 1.32 MB
Filename | Size | Change | |
---|---|---|---|
build/block-editor/index.min.js |
182 kB | +179 B (0%) | |
build/block-editor/style-rtl.css |
14.7 kB | +25 B (0%) | |
build/block-editor/style.css |
14.7 kB | +24 B (0%) | |
build/block-library/blocks/page-list/editor-rtl.css |
376 B | +13 B (+4%) | |
build/block-library/blocks/page-list/editor.css |
376 B | +13 B (+4%) | |
build/block-library/blocks/table/style-rtl.css |
651 B | +15 B (+2%) | |
build/block-library/blocks/table/style.css |
650 B | +15 B (+2%) | |
build/block-library/blocks/table/theme-rtl.css |
157 B | -27 B (-15%) | 👏 |
build/block-library/blocks/table/theme.css |
157 B | -27 B (-15%) | 👏 |
build/block-library/editor-rtl.css |
11.7 kB | +8 B (0%) | |
build/block-library/editor.css |
11.7 kB | +10 B (0%) | |
build/block-library/index.min.js |
197 kB | +177 B (0%) | |
build/block-library/style-rtl.css |
12.4 kB | +18 B (0%) | |
build/block-library/style.css |
12.4 kB | +19 B (0%) | |
build/block-library/theme-rtl.css |
698 B | -18 B (-3%) | |
build/block-library/theme.css |
703 B | -18 B (-2%) | |
build/data/index.min.js |
8.16 kB | +19 B (0%) | |
build/edit-site/index.min.js |
64.8 kB | +1.19 kB (+2%) | |
build/edit-site/style-rtl.css |
9.06 kB | +23 B (0%) | |
build/edit-site/style.css |
9.06 kB | +23 B (0%) | |
build/element/index.min.js |
4.93 kB | +211 B (+4%) | |
build/nux/index.min.js |
0 B | -2.07 kB (removed) | 🏆 |
build/nux/style-rtl.css |
0 B | -775 B (removed) | 🏆 |
build/nux/style.css |
0 B | -771 B (removed) | 🏆 |
ℹ️ View Unchanged
Filename | Size |
---|---|
build/a11y/index.min.js |
993 B |
build/annotations/index.min.js |
2.78 kB |
build/api-fetch/index.min.js |
2.27 kB |
build/autop/index.min.js |
2.15 kB |
build/blob/index.min.js |
487 B |
build/block-directory/index.min.js |
7.16 kB |
build/block-directory/style-rtl.css |
1.04 kB |
build/block-directory/style.css |
1.04 kB |
build/block-editor/content-rtl.css |
2.71 kB |
build/block-editor/content.css |
2.71 kB |
build/block-editor/default-editor-styles-rtl.css |
403 B |
build/block-editor/default-editor-styles.css |
403 B |
build/block-library/blocks/archives/editor-rtl.css |
61 B |
build/block-library/blocks/archives/editor.css |
60 B |
build/block-library/blocks/archives/style-rtl.css |
90 B |
build/block-library/blocks/archives/style.css |
90 B |
build/block-library/blocks/audio/editor-rtl.css |
150 B |
build/block-library/blocks/audio/editor.css |
150 B |
build/block-library/blocks/audio/style-rtl.css |
122 B |
build/block-library/blocks/audio/style.css |
122 B |
build/block-library/blocks/audio/theme-rtl.css |
138 B |
build/block-library/blocks/audio/theme.css |
138 B |
build/block-library/blocks/avatar/editor-rtl.css |
116 B |
build/block-library/blocks/avatar/editor.css |
116 B |
build/block-library/blocks/avatar/style-rtl.css |
84 B |
build/block-library/blocks/avatar/style.css |
84 B |
build/block-library/blocks/block/editor-rtl.css |
305 B |
build/block-library/blocks/block/editor.css |
305 B |
build/block-library/blocks/button/editor-rtl.css |
485 B |
build/block-library/blocks/button/editor.css |
485 B |
build/block-library/blocks/button/style-rtl.css |
532 B |
build/block-library/blocks/button/style.css |
532 B |
build/block-library/blocks/buttons/editor-rtl.css |
337 B |
build/block-library/blocks/buttons/editor.css |
337 B |
build/block-library/blocks/buttons/style-rtl.css |
332 B |
build/block-library/blocks/buttons/style.css |
332 B |
build/block-library/blocks/calendar/style-rtl.css |
239 B |
build/block-library/blocks/calendar/style.css |
239 B |
build/block-library/blocks/categories/editor-rtl.css |
84 B |
build/block-library/blocks/categories/editor.css |
83 B |
build/block-library/blocks/categories/style-rtl.css |
100 B |
build/block-library/blocks/categories/style.css |
100 B |
build/block-library/blocks/code/editor-rtl.css |
53 B |
build/block-library/blocks/code/editor.css |
53 B |
build/block-library/blocks/code/style-rtl.css |
121 B |
build/block-library/blocks/code/style.css |
121 B |
build/block-library/blocks/code/theme-rtl.css |
124 B |
build/block-library/blocks/code/theme.css |
124 B |
build/block-library/blocks/columns/editor-rtl.css |
108 B |
build/block-library/blocks/columns/editor.css |
108 B |
build/block-library/blocks/columns/style-rtl.css |
406 B |
build/block-library/blocks/columns/style.css |
406 B |
build/block-library/blocks/comment-author-avatar/editor-rtl.css |
125 B |
build/block-library/blocks/comment-author-avatar/editor.css |
125 B |
build/block-library/blocks/comment-content/style-rtl.css |
92 B |
build/block-library/blocks/comment-content/style.css |
92 B |
build/block-library/blocks/comment-template/style-rtl.css |
199 B |
build/block-library/blocks/comment-template/style.css |
198 B |
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css |
123 B |
build/block-library/blocks/comments-pagination-numbers/editor.css |
121 B |
build/block-library/blocks/comments-pagination/editor-rtl.css |
222 B |
build/block-library/blocks/comments-pagination/editor.css |
209 B |
build/block-library/blocks/comments-pagination/style-rtl.css |
235 B |
build/block-library/blocks/comments-pagination/style.css |
231 B |
build/block-library/blocks/comments-title/editor-rtl.css |
75 B |
build/block-library/blocks/comments-title/editor.css |
75 B |
build/block-library/blocks/comments/editor-rtl.css |
840 B |
build/block-library/blocks/comments/editor.css |
839 B |
build/block-library/blocks/comments/style-rtl.css |
637 B |
build/block-library/blocks/comments/style.css |
636 B |
build/block-library/blocks/cover/editor-rtl.css |
612 B |
build/block-library/blocks/cover/editor.css |
613 B |
build/block-library/blocks/cover/style-rtl.css |
1.57 kB |
build/block-library/blocks/cover/style.css |
1.56 kB |
build/block-library/blocks/embed/editor-rtl.css |
293 B |
build/block-library/blocks/embed/editor.css |
293 B |
build/block-library/blocks/embed/style-rtl.css |
410 B |
build/block-library/blocks/embed/style.css |
410 B |
build/block-library/blocks/embed/theme-rtl.css |
138 B |
build/block-library/blocks/embed/theme.css |
138 B |
build/block-library/blocks/file/editor-rtl.css |
300 B |
build/block-library/blocks/file/editor.css |
300 B |
build/block-library/blocks/file/style-rtl.css |
253 B |
build/block-library/blocks/file/style.css |
254 B |
build/block-library/blocks/file/view.min.js |
353 B |
build/block-library/blocks/freeform/editor-rtl.css |
2.44 kB |
build/block-library/blocks/freeform/editor.css |
2.44 kB |
build/block-library/blocks/gallery/editor-rtl.css |
984 B |
build/block-library/blocks/gallery/editor.css |
988 B |
build/block-library/blocks/gallery/style-rtl.css |
1.55 kB |
build/block-library/blocks/gallery/style.css |
1.55 kB |
build/block-library/blocks/gallery/theme-rtl.css |
122 B |
build/block-library/blocks/gallery/theme.css |
122 B |
build/block-library/blocks/group/editor-rtl.css |
654 B |
build/block-library/blocks/group/editor.css |
654 B |
build/block-library/blocks/group/style-rtl.css |
57 B |
build/block-library/blocks/group/style.css |
57 B |
build/block-library/blocks/group/theme-rtl.css |
78 B |
build/block-library/blocks/group/theme.css |
78 B |
build/block-library/blocks/heading/style-rtl.css |
76 B |
build/block-library/blocks/heading/style.css |
76 B |
build/block-library/blocks/html/editor-rtl.css |
332 B |
build/block-library/blocks/html/editor.css |
333 B |
build/block-library/blocks/image/editor-rtl.css |
829 B |
build/block-library/blocks/image/editor.css |
828 B |
build/block-library/blocks/image/style-rtl.css |
627 B |
build/block-library/blocks/image/style.css |
630 B |
build/block-library/blocks/image/theme-rtl.css |
137 B |
build/block-library/blocks/image/theme.css |
137 B |
build/block-library/blocks/latest-comments/style-rtl.css |
298 B |
build/block-library/blocks/latest-comments/style.css |
298 B |
build/block-library/blocks/latest-posts/editor-rtl.css |
213 B |
build/block-library/blocks/latest-posts/editor.css |
212 B |
build/block-library/blocks/latest-posts/style-rtl.css |
478 B |
build/block-library/blocks/latest-posts/style.css |
478 B |
build/block-library/blocks/list/style-rtl.css |
88 B |
build/block-library/blocks/list/style.css |
88 B |
build/block-library/blocks/media-text/editor-rtl.css |
266 B |
build/block-library/blocks/media-text/editor.css |
263 B |
build/block-library/blocks/media-text/style-rtl.css |
507 B |
build/block-library/blocks/media-text/style.css |
505 B |
build/block-library/blocks/more/editor-rtl.css |
431 B |
build/block-library/blocks/more/editor.css |
431 B |
build/block-library/blocks/navigation-link/editor-rtl.css |
716 B |
build/block-library/blocks/navigation-link/editor.css |
715 B |
build/block-library/blocks/navigation-link/style-rtl.css |
115 B |
build/block-library/blocks/navigation-link/style.css |
115 B |
build/block-library/blocks/navigation-submenu/editor-rtl.css |
299 B |
build/block-library/blocks/navigation-submenu/editor.css |
299 B |
build/block-library/blocks/navigation/editor-rtl.css |
2.15 kB |
build/block-library/blocks/navigation/editor.css |
2.16 kB |
build/block-library/blocks/navigation/style-rtl.css |
2.23 kB |
build/block-library/blocks/navigation/style.css |
2.21 kB |
build/block-library/blocks/navigation/view-modal.min.js |
2.81 kB |
build/block-library/blocks/navigation/view.min.js |
447 B |
build/block-library/blocks/nextpage/editor-rtl.css |
395 B |
build/block-library/blocks/nextpage/editor.css |
395 B |
build/block-library/blocks/page-list/style-rtl.css |
175 B |
build/block-library/blocks/page-list/style.css |
175 B |
build/block-library/blocks/paragraph/editor-rtl.css |
174 B |
build/block-library/blocks/paragraph/editor.css |
174 B |
build/block-library/blocks/paragraph/style-rtl.css |
279 B |
build/block-library/blocks/paragraph/style.css |
281 B |
build/block-library/blocks/post-author/style-rtl.css |
175 B |
build/block-library/blocks/post-author/style.css |
176 B |
build/block-library/blocks/post-comments-form/editor-rtl.css |
96 B |
build/block-library/blocks/post-comments-form/editor.css |
96 B |
build/block-library/blocks/post-comments-form/style-rtl.css |
501 B |
build/block-library/blocks/post-comments-form/style.css |
501 B |
build/block-library/blocks/post-date/style-rtl.css |
61 B |
build/block-library/blocks/post-date/style.css |
61 B |
build/block-library/blocks/post-excerpt/editor-rtl.css |
73 B |
build/block-library/blocks/post-excerpt/editor.css |
73 B |
build/block-library/blocks/post-excerpt/style-rtl.css |
69 B |
build/block-library/blocks/post-excerpt/style.css |
69 B |
build/block-library/blocks/post-featured-image/editor-rtl.css |
586 B |
build/block-library/blocks/post-featured-image/editor.css |
584 B |
build/block-library/blocks/post-featured-image/style-rtl.css |
318 B |
build/block-library/blocks/post-featured-image/style.css |
318 B |
build/block-library/blocks/post-navigation-link/style-rtl.css |
153 B |
build/block-library/blocks/post-navigation-link/style.css |
153 B |
build/block-library/blocks/post-template/editor-rtl.css |
99 B |
build/block-library/blocks/post-template/editor.css |
98 B |
build/block-library/blocks/post-template/style-rtl.css |
282 B |
build/block-library/blocks/post-template/style.css |
282 B |
build/block-library/blocks/post-terms/style-rtl.css |
96 B |
build/block-library/blocks/post-terms/style.css |
96 B |
build/block-library/blocks/post-title/style-rtl.css |
100 B |
build/block-library/blocks/post-title/style.css |
100 B |
build/block-library/blocks/preformatted/style-rtl.css |
103 B |
build/block-library/blocks/preformatted/style.css |
103 B |
build/block-library/blocks/pullquote/editor-rtl.css |
135 B |
build/block-library/blocks/pullquote/editor.css |
135 B |
build/block-library/blocks/pullquote/style-rtl.css |
326 B |
build/block-library/blocks/pullquote/style.css |
325 B |
build/block-library/blocks/pullquote/theme-rtl.css |
167 B |
build/block-library/blocks/pullquote/theme.css |
167 B |
build/block-library/blocks/query-pagination-numbers/editor-rtl.css |
122 B |
build/block-library/blocks/query-pagination-numbers/editor.css |
121 B |
build/block-library/blocks/query-pagination/editor-rtl.css |
221 B |
build/block-library/blocks/query-pagination/editor.css |
211 B |
build/block-library/blocks/query-pagination/style-rtl.css |
288 B |
build/block-library/blocks/query-pagination/style.css |
284 B |
build/block-library/blocks/query-title/style-rtl.css |
63 B |
build/block-library/blocks/query-title/style.css |
63 B |
build/block-library/blocks/query/editor-rtl.css |
440 B |
build/block-library/blocks/query/editor.css |
440 B |
build/block-library/blocks/quote/style-rtl.css |
213 B |
build/block-library/blocks/quote/style.css |
213 B |
build/block-library/blocks/quote/theme-rtl.css |
223 B |
build/block-library/blocks/quote/theme.css |
226 B |
build/block-library/blocks/read-more/style-rtl.css |
132 B |
build/block-library/blocks/read-more/style.css |
132 B |
build/block-library/blocks/rss/editor-rtl.css |
202 B |
build/block-library/blocks/rss/editor.css |
204 B |
build/block-library/blocks/rss/style-rtl.css |
289 B |
build/block-library/blocks/rss/style.css |
288 B |
build/block-library/blocks/search/editor-rtl.css |
165 B |
build/block-library/blocks/search/editor.css |
165 B |
build/block-library/blocks/search/style-rtl.css |
409 B |
build/block-library/blocks/search/style.css |
406 B |
build/block-library/blocks/search/theme-rtl.css |
114 B |
build/block-library/blocks/search/theme.css |
114 B |
build/block-library/blocks/separator/editor-rtl.css |
146 B |
build/block-library/blocks/separator/editor.css |
146 B |
build/block-library/blocks/separator/style-rtl.css |
234 B |
build/block-library/blocks/separator/style.css |
234 B |
build/block-library/blocks/separator/theme-rtl.css |
194 B |
build/block-library/blocks/separator/theme.css |
194 B |
build/block-library/blocks/shortcode/editor-rtl.css |
474 B |
build/block-library/blocks/shortcode/editor.css |
474 B |
build/block-library/blocks/site-logo/editor-rtl.css |
490 B |
build/block-library/blocks/site-logo/editor.css |
490 B |
build/block-library/blocks/site-logo/style-rtl.css |
203 B |
build/block-library/blocks/site-logo/style.css |
203 B |
build/block-library/blocks/site-tagline/editor-rtl.css |
86 B |
build/block-library/blocks/site-tagline/editor.css |
86 B |
build/block-library/blocks/site-title/editor-rtl.css |
116 B |
build/block-library/blocks/site-title/editor.css |
116 B |
build/block-library/blocks/site-title/style-rtl.css |
57 B |
build/block-library/blocks/site-title/style.css |
57 B |
build/block-library/blocks/social-link/editor-rtl.css |
184 B |
build/block-library/blocks/social-link/editor.css |
184 B |
build/block-library/blocks/social-links/editor-rtl.css |
674 B |
build/block-library/blocks/social-links/editor.css |
673 B |
build/block-library/blocks/social-links/style-rtl.css |
1.4 kB |
build/block-library/blocks/social-links/style.css |
1.39 kB |
build/block-library/blocks/spacer/editor-rtl.css |
332 B |
build/block-library/blocks/spacer/editor.css |
332 B |
build/block-library/blocks/spacer/style-rtl.css |
48 B |
build/block-library/blocks/spacer/style.css |
48 B |
build/block-library/blocks/table/editor-rtl.css |
457 B |
build/block-library/blocks/table/editor.css |
457 B |
build/block-library/blocks/tag-cloud/style-rtl.css |
251 B |
build/block-library/blocks/tag-cloud/style.css |
253 B |
build/block-library/blocks/template-part/editor-rtl.css |
404 B |
build/block-library/blocks/template-part/editor.css |
404 B |
build/block-library/blocks/template-part/theme-rtl.css |
101 B |
build/block-library/blocks/template-part/theme.css |
101 B |
build/block-library/blocks/text-columns/editor-rtl.css |
95 B |
build/block-library/blocks/text-columns/editor.css |
95 B |
build/block-library/blocks/text-columns/style-rtl.css |
166 B |
build/block-library/blocks/text-columns/style.css |
166 B |
build/block-library/blocks/verse/style-rtl.css |
87 B |
build/block-library/blocks/verse/style.css |
87 B |
build/block-library/blocks/video/editor-rtl.css |
691 B |
build/block-library/blocks/video/editor.css |
694 B |
build/block-library/blocks/video/style-rtl.css |
179 B |
build/block-library/blocks/video/style.css |
179 B |
build/block-library/blocks/video/theme-rtl.css |
139 B |
build/block-library/blocks/video/theme.css |
139 B |
build/block-library/classic-rtl.css |
162 B |
build/block-library/classic.css |
162 B |
build/block-library/common-rtl.css |
1.05 kB |
build/block-library/common.css |
1.05 kB |
build/block-library/editor-elements-rtl.css |
75 B |
build/block-library/editor-elements.css |
75 B |
build/block-library/elements-rtl.css |
54 B |
build/block-library/elements.css |
54 B |
build/block-library/reset-rtl.css |
478 B |
build/block-library/reset.css |
478 B |
build/block-serialization-default-parser/index.min.js |
1.13 kB |
build/block-serialization-spec-parser/index.min.js |
2.83 kB |
build/blocks/index.min.js |
50.4 kB |
build/components/index.min.js |
204 kB |
build/components/style-rtl.css |
11.6 kB |
build/components/style.css |
11.6 kB |
build/compose/index.min.js |
12.3 kB |
build/core-data/index.min.js |
15.9 kB |
build/customize-widgets/index.min.js |
11.7 kB |
build/customize-widgets/style-rtl.css |
1.41 kB |
build/customize-widgets/style.css |
1.41 kB |
build/data-controls/index.min.js |
663 B |
build/date/index.min.js |
32.1 kB |
build/deprecated/index.min.js |
518 B |
build/dom-ready/index.min.js |
336 B |
build/dom/index.min.js |
4.71 kB |
build/edit-navigation/index.min.js |
16.2 kB |
build/edit-navigation/style-rtl.css |
4.11 kB |
build/edit-navigation/style.css |
4.12 kB |
build/edit-post/classic-rtl.css |
571 B |
build/edit-post/classic.css |
571 B |
build/edit-post/index.min.js |
34.7 kB |
build/edit-post/style-rtl.css |
7.45 kB |
build/edit-post/style.css |
7.44 kB |
build/edit-widgets/index.min.js |
16.8 kB |
build/edit-widgets/style-rtl.css |
4.46 kB |
build/edit-widgets/style.css |
4.46 kB |
build/editor/index.min.js |
44.1 kB |
build/editor/style-rtl.css |
3.69 kB |
build/editor/style.css |
3.68 kB |
build/escape-html/index.min.js |
548 B |
build/experiments/index.min.js |
882 B |
build/format-library/index.min.js |
7.2 kB |
build/format-library/style-rtl.css |
598 B |
build/format-library/style.css |
597 B |
build/hooks/index.min.js |
1.66 kB |
build/html-entities/index.min.js |
454 B |
build/i18n/index.min.js |
3.79 kB |
build/is-shallow-equal/index.min.js |
535 B |
build/keyboard-shortcuts/index.min.js |
1.79 kB |
build/keycodes/index.min.js |
1.86 kB |
build/list-reusable-blocks/index.min.js |
2.13 kB |
build/list-reusable-blocks/style-rtl.css |
865 B |
build/list-reusable-blocks/style.css |
865 B |
build/media-utils/index.min.js |
2.94 kB |
build/notices/index.min.js |
977 B |
build/plugins/index.min.js |
1.95 kB |
build/preferences-persistence/index.min.js |
2.23 kB |
build/preferences/index.min.js |
1.35 kB |
build/primitives/index.min.js |
960 B |
build/priority-queue/index.min.js |
1.59 kB |
build/react-i18n/index.min.js |
702 B |
build/react-refresh-entry/index.min.js |
8.44 kB |
build/react-refresh-runtime/index.min.js |
7.31 kB |
build/redux-routine/index.min.js |
2.75 kB |
build/reusable-blocks/index.min.js |
2.26 kB |
build/reusable-blocks/style-rtl.css |
283 B |
build/reusable-blocks/style.css |
283 B |
build/rich-text/index.min.js |
10.7 kB |
build/server-side-render/index.min.js |
2.09 kB |
build/shortcode/index.min.js |
1.52 kB |
build/style-engine/index.min.js |
1.53 kB |
build/token-list/index.min.js |
650 B |
build/url/index.min.js |
3.7 kB |
build/vendors/inert-polyfill.min.js |
2.48 kB |
build/vendors/react-dom.min.js |
41.8 kB |
build/vendors/react.min.js |
4.02 kB |
build/viewport/index.min.js |
1.09 kB |
build/warning/index.min.js |
280 B |
build/widgets/index.min.js |
7.27 kB |
build/widgets/style-rtl.css |
1.21 kB |
build/widgets/style.css |
1.21 kB |
build/wordcount/index.min.js |
1.06 kB |
I have another commit to push to this smoothing out how abbreviating the title is handled in different circumstances. I just requested contributor access in the slack channel.
This is great! I love it. Most important is that we're working collaboratively to make feeds work better.
There's no doubt it could be improved beyond this, which I think may be what @roo2 is getting at in the followup post. If there's a period followed by a space in the text before you hit the end of the simulated title, you can stop there instead of pulling up more characters.
We added this to the demo in a second release.
I think perhaps eventually it will make sense to not make the title a div rather make it a span, so the text flows more naturally. Still bolden the title, but just wrap the descriptive text next to it. This saves a little vertical space for titled items, but it also bends toward the title-less items which imho will become more common. Adding the blank line there interferes with the intent of the writer.
Anyway all this is meant to be constructive. I love what you all are doing -- and I think there will be more opportunities to clear up how feeds work on the web. ;-)
- I updated to include the suggestion to truncate the title if there is a period followed by a space. (nice, this works even better 👍)
- Also handles truncating real titles differently, if a generated title is truncated there is no punctuation added so the sentence flows as the author wrote it. But if a user specified title gets truncated to
titleLength
, we can add an indicator[…]
which is the same indicator that we use when the excerpt gets truncated.
@scripting Thank you for contributing to WordPress and RSS in general! and we're glad to "steal" your idea ;)
For the idea of using a span for the title, I think that's potentially a useful option to add in the future. The feed's appearance can be customized in the block editor so there are a few variations that the block supports already.
Thanks!
I'm so happy to see you do this. We're in a moment where we might be able to straighten out this huge problem with the web, that limits how we can integrate systems that support short and long posts. We've been divided since Twitter gave up on their RSS feeds, a long time ago. Mastodon required some convincing to stick to no titles, rather than give in. And WordPress stepping up to make this transition means we have more reasons for other feed displayers to do so. So this is totally a win for RSS, and I see that as a win for me because my product is interop. I made that switch a long time ago. I make products too but interop comes first.
I probably will have other ideas, and I hope you all are ready to listen. ;-)
handles RSS feed items with empty titles by taking the first 𝒙 characters from the post
Hmm, why? WordPress has had support for "empty titles" since... 2003 I believe. Why should this feature be removed now, even if only in feeds? This can probably be seen as a regression.
Frankly I see the "removal of empty titles in feeds" as a plugin material. That way it won't be forced on everybody and only people that dislike the feature can disable it.
In addition I think there may be some security related regressions in the code, missing escaping, etc. Also not sure why the new trim_to_word_boundary()
function is needed. Seems inferior to the existing wp_trim_words()
that can properly handle different languages?
@azaozz
Hmm, why? WordPress has had support for "empty titles" since... 2003 I believe. Why should this feature be removed now, even if only in feeds? This can probably be seen as a regression.
The reasoning is best explained in http://scripting.com/2022/12/08.html#a152840. When a title's empty the text "(empty title)" just looks like an error message. we can make the feed much more attractive and scan-able if we fill in the title from the start of the post content.
In addition I think there may be some security related regressions in the code, missing escaping, etc.
👀‼️
Also not sure why the new trim_to_word_boundary() function is needed.
I added trim_to_word_boundary
so that I could specify the title length in characters instead of words, this allows the titles to keep a consistent length. I think that if we specify it in words, it is hard to make the titles all the same length. This is less important for the excerpt.
However one down side of specifying title length in characters is that it might be confusing as it's inconsistent with how we specify the excerpt length.
I think you could make a case for either I'm happy to change it back to words just to simplify things.
When a title's empty the text "(empty title)" just looks like an error message.
That's incorrect :) WordPress has a feature that lets posts be published without titles. In that case the "(empty title)" string (the exact text depends on the WP locale) is shown to logged-in users in wp-admin to signify the fact. It should not be present on the front-end/for not logged-in users. This feature has existed for many many years and was somewhat popular with bloggers.
Test for yourself, try publishing few posts without titles and check the feed. This is what I get on my test site:
(Posts list table in wp-admin)
(Front-end. The "post no title-*" text is the content of the posts.)
<item>
<title></title>
<link>http://localhost:8889/2023/01/31/78/</link>
<comments>http://localhost:8889/2023/01/31/78/#respond</comments>
<dc:creator><![CDATA[admin]]></dc:creator>
<pubDate>Tue, 31 Jan 2023 19:29:46 +0000</pubDate>
<category><![CDATA[Uncategorized]]></category>
<guid isPermaLink="false">http://localhost:8889/?p=78</guid>
<description><![CDATA[post no title-3]]></description>
<content:encoded><![CDATA[
<p>post no title-3</p>
]]></content:encoded>
<wfw:commentRss>http://localhost:8889/2023/01/31/78/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
</item>
<item>
<title></title>
<link>http://localhost:8889/2023/01/31/76/</link>
<comments>http://localhost:8889/2023/01/31/76/#respond</comments>
<dc:creator><![CDATA[admin]]></dc:creator>
<pubDate>Tue, 31 Jan 2023 19:29:28 +0000</pubDate>
<category><![CDATA[Uncategorized]]></category>
<guid isPermaLink="false">http://localhost:8889/?p=76</guid>
<description><![CDATA[post no title-2]]></description>
<content:encoded><![CDATA[
<p>post no title-2</p>
]]></content:encoded>
<wfw:commentRss>http://localhost:8889/2023/01/31/76/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
</item>
(RSS feed.)
As you can see the "(empty title)"
string is only shown in wp-admin and not on the front-end or in the feed. I'm not sure where you're seeing it but the code there seems to be "doing-it-wrong". This is what should be fixed.
we can make the feed much more attractive and scan-able if we fill in the title from the start of the post content.
Not so sure about that. Has been tried few times in the past and always rejected. The main reason is that displaying a small part of the content may get pretty confusing for the site visitors in some cases.
I agree with the author of the post you linked above:
But I don't do that. And it shows up in my feed without a title, because the item does not have a title. And that's not up to anyone but me, the author of the feed. .... they repeat the first bits of the post. Again, why? The human read them once, why put the same words they just read on the screen again? That seems quite wrong to me. #
Also, why would you want to remove the "No-Titles" feature from WordPress? The content author has chosen to make a post without a title, why should WordPress disallow that?
Hi! I only skimmed the diff and the comments, so apologies if I'm overstepping. But: it looks like this PR is making many assumptions on the kind of text that it will treat.
// Match to the first period followed by a space.
@mcsf -- i'm sure there will be bugs, but even then it won't be more broken than it is now.
when problems show up, let's understand what happened and either change the algorithm or find a workaround.
the fact is no writer ever put [no title] in their feed, for good reason, it's the kind of thing only a programmer thinks is important. to writers it's bs. it's criticism, it's the software not minding its own business.
when problems show up, let's understand what happened and either change the algorithm or find a workaround.
Well, yes, that is what the PR review process is all about. The question isn't hypothetical: I'd like to know if this solution is equipped to trim an excerpt like:
中国史に於ける貴族とは、魏晋南北朝時代から唐末期(220年 - 907年)にまで存在した血統を基幹として政治的権力を占有した存在を指す。後漢の豪族を前身とし、魏において施行された九品官人法により貴族層が形成された。北朝ではこれに鮮卑や匈奴といった北族遊牧民系統の族長層が加わり、その系譜を汲む隋・唐でもこの両方の系統の貴族が社会の支配層の主要部を形成した。中国史学では、貴族が社会の主導権を握っていた体制を貴族制と呼ぶ。
the fact is no writer ever put [no title] in their feed, for good reason, it's the kind of thing only a programmer thinks is important. to writers it's bs. it's criticism, it's the software not minding its own business.
The fact that I raised this flag doesn't imply that I oppose the PR. I agree with the goal, [no title]
is awful.
@mcsf -- gotcha. sorry about challenging you on that.
i guess we'd have to find someone who can read that language and explain how the algorithm botched the display.
the fact is no writer ever put [no title] in their feed
I agree with the goal,
[no title]
is awful.
@scripting @mcsf yes, I agree too! Lets fix that.
Think that I've misunderstood the purpose of this PR. I thought it was about how WordPress treats posts with empty titles, but now realizing it Is to prevent other software (or themes/plugins/widgets) from adding [no title]
or other random string when displaying WordPress feeds.
In that case I think the proposed solution here perhaps goes against the findings in the article that became the catalyst for this PR. The article seems to be defending the author's right to publish posts without titles:
But I don't do that. And it shows up in my feed without a title, because the item does not have a title. And that's not up to anyone but me, the author of the feed.
See: http://scripting.com/2022/12/08/141610.html#a141629.
So instead of forcing titles in the feed when the author doesn't want them, maybe look for a solution that would prevent other software from adding random strings in empty titles? Think there were few UTF-8 characters reserved for such purposes, like U+FFFE and U+FFFF? Could that be a viable solution?
If not, seems there's no way around forcing titles against the author's will. Then using the first few words from the description (i.e. the post_excerpt) may be the lesser evil. However automatically splitting words can be very confusing and sometimes very damaging. In rare cases parts or words can be interpreted as obscene or ethnic slurs or other extremely insulting words or phrases. Imagine a busy site displaying something like that in its sidebar...
This doesn't end there. In extreme cases a site with such content may be blacklisted and it may take a long time to "clear its name". For that reason I think that the proposed solution in this PR is not appropriate. Words should not be split and the existing WordPress functions should be used instead.