After fiddling a bit, we added an Atom feed to the Hiso of the Day page. It is important to record how we did this because we tend to forget things... Our past looks extremely foggy to us. Why do we need a feed for this unpopular personal website? No, we don't need it, but Silver requested the feature. We had zero idea about feed.

Step 0

Whine about having zero knowledge about feed, while googling around.

One may use the RSS standard or the Atom standard. We went with Atom, because Silver asked us to implement RSS feed. The key document is RFC 4287. For our site the basic example in Sec. 1.1 suffices.

Step 1

We just need to find a way to generate an analogous XML file from data we have. We already wrote a php class to access the hiso database. It has a method that returns id, date and title of the latest hiso picture. Currently we just made a php file that interpolated the info into an XML skeleton. After linking to this php file on the hotd page, we were all set. This was the php-generated XML file on 2016-10-24.

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Hiso of the Day Feed</title>
    <link href="https://www.tujion.com/" />
    <id>https://www.tujion.com,2016-01-26:ahotd</id>
    <updated>2016-10-22T00:00:00Z</updated>
    <author>
    <name>Tujion</name>
    </author>

    <entry>
    <title>Hiso of the Day Feed</title>
    <link href="https://www.tujion.com/ahotd.html" />
    <id>https://www.tujion.com,2016-01-26:hiso-2016-10-22</id>
    <updated>2016-10-22T00:00:00Z</updated>
    <summary>The Shin'en Parody</summary>
    </entry>
</feed>

On 2016-10-25 we added an extra line to the header of the hotd page so that browsers know that the hotd page has a feed.

<link rel="alternate" type="application/atom+xml" title="Hiso of the Day" href="ahotd-feed.php" />

Remarks:

How do we generate an id for the <id> tag?

We don't know. We just adopted this algorithm: domain+a fixed date+some unique identifier for the picture. That fixed date was intended to be the date on which we hold our domain. Yet that was not true. We acquired this domain later. This means we messed up.

Dates should be in a certain format as prescribed in RFC 4287.

We didn't record the exact hour/minute/second when we published hiso pictures. Thus we put in all zeros. What else can we do?

We made the change from relative to absolute just awhile ago. (shy) We hope Silver's bookmark is OK. It is possible for a feed to exist out of context. Thus absolute URI is the way to go.

PHP actually messed us up.

It generated two empty lines before getting to the XML proper. Because of this, Firefox complained and refused to show the feed. We used require_once to load an external PHP file. Is this causing the problem? We vaguely remember that one should omit the trailing ?> thing if there is no more output intended. We should not have the ?> in the included file? This is just too messy. We currently wrap ob_start() and ob_end_clean() around whatever PHP code there is before reaching the XML part. More precisely, ob_start() is actually right after the namespace declaration which is required to be the first thing in a PHP file if it exists.

Then we also encountered the problem of wanting an <a> element in an html file to be styled as normal text.

We used Font-awesome's RSS icon, wrapped it in an <a> element and it changed colour. We googled for the following CSS solution. We assigned this blend-with-text class to the <a> element.

.blend-with-text{
    text-decoration:none;
    color:inherit!important;
}

inherit is a bit tricky. It has very very low precedence in CSS. For more details see this MDN article. This is our first time to use !important and we think this is justified.