Site.Atom

Menu

The following Ruby code generates the Atom feed of my website. It is composed of three parts:

Org Mode is instructed to generate a site.atom file upon execution of this source block.

title       = "Adolfo Villafiorita's Homepage"
author      = "Adolfo Villafiorita"
description = "Homepage of Adolfo Villafiorita"
url         = "https://ict4g.net/adolfo"
email       = "adolfo.villafiorita@ict4g.net"

atom_filename = "site.atom"
atom_template = <<EOS
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title><%= title %></title>
  <link href="<%= url %>/site.atom" rel="self" type="application/rss+xml" />
  <link href="<%= url %>"/>
  <updated><%= DateTime.now.to_s %></updated>
  <author><name><%= author %></name></author>
  <id><%= url %></id>

  <%- pages.each do |page| -%>
  <entry>
    <title><%= page["TITLE"] %></title>
    <link href="<%= page[:url] %>"/>
    <id><%= page[:url] %></id>
    <updated><%= (DateTime.parse(page["DATE"]) || DateTime.now).to_s %></updated>
    <summary>
      <%= page["DESCRIPTION"] || page[:excerpt] %>
    </summary>
  </entry>
  <%- end -%>
</feed>
EOS

require 'erb'
load '_scripts/metadata.rb'

pages = Metadata::collect("notes/").select { |x| not ["notes/index.org", "notes/chronological.org"].include?(x[:filename]) }
renderer = ERB.new(atom_template, nil, "-")
content = renderer.result(binding)

Author: Adolfo Villafiorita

Last modified: 2020-08-05 Wed 11:27 (created on: 2020-03-11 Wed 00:00)

Published: 2020-08-05 Wed 20:53