[feat] Allow configuration of title-less items in RSS feeds #391
Labels
No labels
approved, awaiting change
bug
cannot reproduce
configuration
documentation
duplicate
enhancement
extremely low priority
feature request
Fix it yourself
help wanted
invalid
mastodon_api
needs change/feedback
needs docs
needs tests
not a bug
not our bug
planned
pleroma_api
privacy
question
static_fe
triage
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
AkkomaGang/akkoma#391
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The idea
Add a configuration key for a boolean value
:parse_sourcewith a default value offalseunderconfig :pleroma, :feed, :post_title. An example description for the key is shown below.Modify the function
Pleroma.Formatter.truncate/3to accept zero as the value forPleroma.Config.get([:feed, :post_title, :max_length]). Currently, this function will raise an exception ifmax_lengthis less thanString.length(omission). Ifmax_lengthis less than the length of theomissionstring, just useString.slice(text, 0, max_length)(without adding theomission) as the truncated text.Modify the logic in
Pleroma.Web.Feed.FeedView.activity_title/2to test if and only if the opts parameter has%{parse_source: true}and the activity has non-nil values atactivity.data["source"]["mediaType"]andactivity.data["source"]["content"]. If so, do not use the HTML content for the activity to produce the title. Instead, parse the title from the "source" "content", according to rules for each content type, ignoring the:max_lengthconfiguration value (see below for the rules).Notes
If the :parse_source option is set, and the rules set forth below fail to parse out an authored title, the :max_length option will be used as before to render a plaintext title sub-element and a description sub-element that contains HTML encoded from the original full
activity.data["source"]["content"].If the :parse_source option is set, no title is parsed, and :max_length is zero, the feed item/entry will be rendered without a title sub-element.
If the :parse_source option is set, and the rules below parse out an authored title, the description sub-element of the feed item/entry will contain HTML encoded from a slice of the
activity.data["source"]["content"]beginning at an offset just beyond the end of the parsed title. In this way, the description sub-element will not repeat the title that was parsed out.In all cases, including under the current behavior, the title sub-element's value should be a single line of plain text, trimmed of leading and trailing whitespace, without links or emojis. If no title is produced, the feed item/entry will be rendered without a title sub-element.
Example :parse_source in description.exs
Parsing title from "text/html" content
The title is the content of an initial
h1orh2element in the content, ornilif this is not satisfied.Parsing title from "text/plain" content
The title is a leading single line of text, separated from the description by two newlines or
nilif is not satisfied. This is the same logic that separates the headers of a plaintext email from its body.Parsing title from "text/bbcode" content
The title is the content of a leading
[b]element, separated from the description by two newlines, ornilif is not satisfied.Parsing title from "text/markdown" content
The title is the content of a leading
#or##(h1 or h2) element, separated from the description by two newlines, ornilif is not satisfied.Parsing title from "text/x.misskeymarkdown" content
The title is the content of a leading
**(bold) element, separated from the description by two newlines, ornilif is not satisfied. (Not sure if the Pleroma implementation of x.misskeymarkdown supports atitleelement, which could be used in place of**).The reasoning
Admins configuring a server should be able to choose between:
Truncating titles for all items in RSS feeds from the HTML-encoded description (i.e. from
activity.data["content"]). This is the current behavior (:max_lengthgreater than zero and:parse_sourcefalse).Making all items in RSS feeds title-less. (
:max_lengthequal to zero and:parse_sourcefalse). Rationales for this are explored in Why Mastodon should have title-less feeds and Common features that a "document" should support.Letting post authors specify a title for individual posts by following rules according to the content type listed above, and parsing (not truncating) titles from
activity.data["source"]["content"](:parse_sourceequal to true). This extends the expressiveness and intentions of author's posts.Titles in other ActivityPub aware server applications:
titleelements for RSS feed item.Have you searched for this feature request?
[feat] Allow configuration of title-less feedsto [feat] Allow configuration of title-less items in RSS feeds