summaryrefslogtreecommitdiff
path: root/rss.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2024-03-04 13:42:04 +0100
committerpdp8 <pdp8@pdp8.info>2024-03-04 13:42:04 +0100
commit6b40f3b54efabb740e825ba3d94b5695c2b98ede (patch)
tree2e2fae35cae72f73878cd5295e0f183891e284dc /rss.rb
parent4bd4cb578ee4579eaa81efec4b478654fae8e236 (diff)
disallow AI bots in robots.txt, mail.rb title, valid rss
Diffstat (limited to 'rss.rb')
-rwxr-xr-xrss.rb37
1 files changed, 30 insertions, 7 deletions
diff --git a/rss.rb b/rss.rb
index 554d45c..eb163d4 100755
--- a/rss.rb
+++ b/rss.rb
@@ -1,43 +1,66 @@
#!/usr/bin/env ruby
require 'date'
+require 'json'
+
MEDIA = '/srv/media/'
+SOCIAL = '/srv/social/outbox/object/note/'
WWW = '/srv/www/pdp8-test/'
+
items = []
%w[music videos].each do |cat|
Dir[File.join(MEDIA, cat, '*')].each do |dir|
+ next unless File.basename(dir).match(/^\d/)
+
date = File.basename(dir).split('_')[0]
- updated = Date.parse(date) # .strftime('%Y-%m-%d')
+ updated = Date.parse(date)
items << {
title: File.basename(dir).split('_')[1..-1].join(' '),
link: File.join('https://pdp8.info', cat + '.html#' + date),
guid: File.join('https://pdp8.info', cat + '.html#' + date),
- description: File.read(File.join(dir, 'README')).chomp.sub(/^\n/, '').sub("\n\n", "\n"),
+ description: '<![CDATA[' + File.read(File.join(dir, 'README')).chomp.sub(/^\n/, '').sub("\n\n", "\n") + ']]>',
pubDate: updated.httpdate
- # 'dc:date' => updated.rfc3339
}
end
end
+
+# duplication of music/video posts?
+# Dir[File.join(SOCIAL, '*.json')].each do |json|
+# note = JSON.parse(File.read(json))
+# next unless note['attributedTo'] == 'https://social.pdp8.info/pdp8' and note['to'].include?('https://www.w3.org/ns/activitystreams#Public')
+#
+# # TODO: add enclosures for attachments
+# # tags
+# items << {
+# title: note['published'],
+# link: 'https://pdp8.info/social/create.html#' + note['published'],
+# guid: note['id'],
+# description: '<![CDATA[' + note['content'] + ']]>',
+# pubDate: Date.parse(note['published']).httpdate
+# }
+# end
+
date = Dir[File.join(MEDIA, 'pictures', '*.jpeg')].last.split('_')[0]
-updated = Date.parse(date) # .strftime('%Y%m%d')
+updated = Date.parse(date)
items << {
title: 'pictures',
link: 'https://pdp8.info/pictures.html',
guid: 'https://pdp8.info/pictures.html',
pubDate: updated.httpdate
- # 'dc:date' => updated.rfc3339
}
xml = ['<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>pdp8</title>
<link>https://pdp8.info</link>
<description>music, pictures and videos</description>
- <language>en</language>']
+ <language>en</language>
+ <atom:link href="https://pdp8.info/rss.xml" rel="self" type="application/rss+xml" /> ']
+
date = DateTime.now
xml << " <pubDate>#{date.httpdate}</pubDate>"
-# xml << " <dc:date>#{date.rfc3339}</dc:date>"
items.sort_by { |i| i['pubDate'] }.each do |item|
xml << ' <item>'