mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 23:28:26 +02:00
Fix feed formatting so it passes w3c validation
Feeds generated by Funkwhale do not pass validation with the [w3c validator](https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fpodcast.midline.pl%2Fapi%2Fv1%2Fchannels%2FMidline%2Frss). This commit addresses the problems identified during validation: 1. The `isPermalink` is not recognized -> changed it to `isPermaLink` (capital "L") 2. `itunes:summary` and `itunes:subtitle` are 256 characters after truncating, but the maximum is 255. The truncating function trims the text to 255 chars, but then adds `…`, so the text is one character too long 3. The tags within `itunes:keywords` are now separated with commas instead of spaces (https://validator.w3.org/feed/docs/warning/InvalidKeywords.html)
This commit is contained in:
parent
4252ae3444
commit
3a83290cc0
5 changed files with 12 additions and 8 deletions
|
@ -818,7 +818,7 @@ def rss_serialize_item(upload):
|
|||
data = {
|
||||
"title": [{"value": upload.track.title}],
|
||||
"itunes:title": [{"value": upload.track.title}],
|
||||
"guid": [{"cdata_value": str(upload.uuid), "isPermalink": "false"}],
|
||||
"guid": [{"cdata_value": str(upload.uuid), "isPermaLink": "false"}],
|
||||
"pubDate": [{"value": rfc822_date(upload.creation_date)}],
|
||||
"itunes:duration": [{"value": rss_duration(upload.duration)}],
|
||||
"itunes:explicit": [{"value": "no"}],
|
||||
|
@ -841,7 +841,7 @@ def rss_serialize_item(upload):
|
|||
],
|
||||
}
|
||||
if upload.track.description:
|
||||
data["itunes:subtitle"] = [{"value": upload.track.description.truncate(255)}]
|
||||
data["itunes:subtitle"] = [{"value": upload.track.description.truncate(254)}]
|
||||
data["itunes:summary"] = [{"cdata_value": upload.track.description.rendered}]
|
||||
data["description"] = [{"value": upload.track.description.as_plain_text}]
|
||||
|
||||
|
@ -853,7 +853,7 @@ def rss_serialize_item(upload):
|
|||
tagged_items = getattr(upload.track, "_prefetched_tagged_items", [])
|
||||
if tagged_items:
|
||||
data["itunes:keywords"] = [
|
||||
{"value": " ".join([ti.tag.name for ti in tagged_items])}
|
||||
{"value": ",".join([ti.tag.name for ti in tagged_items])}
|
||||
]
|
||||
|
||||
return data
|
||||
|
@ -903,7 +903,7 @@ def rss_serialize_channel(channel):
|
|||
data["itunes:category"] = [node]
|
||||
|
||||
if channel.artist.description:
|
||||
data["itunes:subtitle"] = [{"value": channel.artist.description.truncate(255)}]
|
||||
data["itunes:subtitle"] = [{"value": channel.artist.description.truncate(254)}]
|
||||
data["itunes:summary"] = [{"cdata_value": channel.artist.description.rendered}]
|
||||
data["description"] = [{"value": channel.artist.description.as_plain_text}]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue