Added user specific RSS and ATOM feeds and updated the EJS templates to

add them by default to the user's header section
This commit is contained in:
2025-07-30 01:28:23 +01:00
parent 72316094e4
commit 0cc319a702
8 changed files with 83 additions and 9 deletions

View File

@@ -3,7 +3,7 @@
<title><%= config.site_name %></title>
<link><%= config.site_url %></title>
<description><%= config.site_description %></description>
<updated><%= new Date() %></updated>
<updated><%= func.unix_time_to_atom_date(getUnixTime(new Date())) %></updated>
<id><%= config.site_url %></id>
<% for (let postID = posts.length-1; postID >= 0; postID--) { %>
<% if (posts[postID]["deleted"] != true) { %>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="<%= config.charset %>" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><%= config.site_name %></title>
<link><%= config.site_url %></title>
<description><%= config.site_description %></description>
<updated><%= func.unix_time_to_atom_date(getUnixTime(new Date())) %></updated>
<id><%= config.site_url %></id>
<% for (let postID = posts.length-1; postID >= 0; postID--) { %>
<% if (posts[postID]["userID"] == userID) { %>
<% if (posts[postID]["deleted"] != true) { %>
<entry>
<title><%= posts[postID]["title"] %></title>
<link><%= config.site_url %>/post/<%= postID %></link>
<summary><![CDATA[<%- converter.makeHtml(posts[postID]["content"]) %>]]></summary>
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
<pubDate><%# func.unix_time_to_atom_date(posts[postID]['pubdate']) %></pubDate>
<% for (let tag_index = 0; tag_index < posts[postID]['tags'].length; tag_index++) { %>
<category><![CDATA[<%= posts[postID]['tags'][tag_index] %>]]></category>
<% } %>
</entry>
<% } %>
<% } %>
<% } %>
</feed>

View File

@@ -5,10 +5,12 @@
<link><%= config.site_url %></title>
<description><%= config.site_description %></description>
<% for (let postID = posts.length-1; postID >= 0; postID--) { %>
<% if (posts[postID]["userID"] == userID) { %>
<% if (posts[postID]["deleted"] != true) { %>
<item>
<title><%= posts[postID]["title"] %></title>
<link><%= config.site_url %>/post/<%= postID %></link>
<description><![CDATA[<%= converter.makeHtml(posts[postID]["content"]) %>]]></description>
<description><![CDATA[<%- converter.makeHtml(posts[postID]["content"]) %>]]></description>
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
<pubDate><%= func.unix_time_to_rss_date(posts[postID]['pubdate']) %></pubDate>
<% for (let tag_index = 0; tag_index < posts[postID]['tags'].length; tag_index++) { %>
@@ -16,5 +18,7 @@
<% } %>
</item>
<% } %>
<% } %>
<% } %>
</channel>
</rss>