💾 Archived View for flume.space › genfeed.rb captured on 2022-04-28 at 18:23:18.
⬅️ Previous capture (2021-11-30)
-=-=-=-=-=-=-
require 'date' def entry(line) valid = (/=>.* (?<date>\d\d\d\d-\d\d-\d\d) (?<title>.*)/ =~ line) return date, title if valid end def genAtomEntry(line) (date, title) = entry line unless date.nil? or title.nil? '<entry>'\ '<updated>' + date + 'T12:00:00Z</updated>'\ '<title>' + title + '</title>'\ '<id>gemini://flume.space/gemlog/' + date + '.gmi</id>'\ '<link href="gemini://flume.space/gemlog/' + date + '.gmi" rel="alternate" />'\ "</entry>\n" end end def genAtomFeed(lines) '<?xml version="1.0" encoding="utf-8"?>'\ '<feed xmlns="http://www.w3.org/2005/Atom">'\ '<title>mpm\'s gemlog</title>'\ '<link rel="alternate" type="text/gemini" href="gemini://flume.space/" />'\ '<link rel="self" type="application/atom+xml" href="gemini://flume.space/atom.xml" />'\ '<generator uri="gemini://flume.space/genfeed.rb" version="1.0.0">genfeed.rb</generator>'\ '<id>gemini://flume.space/</id>'\ "<author><name>mpm</name></author>\n"\ '<updated>' + DateTime.now.to_s + "</updated>\n"\ + lines.map {|x| genAtomEntry x}.join("") + '</feed>' end File.open('atom.xml', 'w') do |f| f.write genAtomFeed(File.open('index.gmi', 'r').readlines) end