Improve Atom feed XML formatting

This commit is contained in:
silverpill 2023-01-25 22:09:27 +00:00
parent f52a55a387
commit 780b165a8b

View file

@ -27,13 +27,13 @@ fn make_entry(
title += "..."; title += "...";
}; };
format!( format!(
"<entry>\ r#"<entry>
<id>{url}</id>\ <id>{url}</id>
<title>{title}</title>\ <title>{title}</title>
<updated>{updated_at}</updated>\ <updated>{updated_at}</updated>
<author><name>{author}</name></author>\ <author><name>{author}</name></author>
<content type=\"html\">{content}</content>\ <content type="html">{content}</content>
</entry>", </entry>"#,
url=object_id, url=object_id,
title=title, title=title,
updated_at=post.created_at.to_rfc3339(), updated_at=post.created_at.to_rfc3339(),
@ -64,14 +64,14 @@ pub fn make_feed(
format!( format!(
r#"<?xml version="1.0" encoding="utf-8"?> r#"<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"> <feed xmlns="http://www.w3.org/2005/Atom">
<id>{url}</id> <id>{url}</id>
<title>{title}</title> <title>{title}</title>
<updated>{updated_at}</updated> <updated>{updated_at}</updated>
{entries} {entries}
</feed>"#, </feed>"#,
url=actor_url, url=actor_url,
title=feed_title, title=feed_title,
updated_at=feed_updated_at.to_rfc3339(), updated_at=feed_updated_at.to_rfc3339(),
entries=entries.join(""), entries=entries.join("\n"),
) )
} }