alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

use-feeds.txt (4421B) [raw]


      1 # RSS/Atom feeds; what are they and why you should care
      2 
      3 _Published: February 9, 2021_
      4 
      5 I've always wanted this site to be an homage to tech that I enjoy
      6 using, and recently, that's included old-school RSS/Atom feeds.
      7 However, up until now, I had only been a feed consumer and had
      8 never produced my own.  So, this past weekend I decided to hunker
      9 down and read enough of the spec to generate one for this site.
     10 
     11 But let's back up -- what is a feed? Why should you care?
     12 
     13 A feed is simply a standardized listing of items a source (blog,
     14 vlog, newspaper, etc) has generated recently.  Users then consume
     15 multiple feeds to get centralized notifications on new content.
     16 Think "following" on social media, but generalized for any content
     17 accessible on the web.
     18 
     19 The most important feature of a feed is that it has been
     20 standardized and is not controlled by any individual corporation.
     21 This ensures that users are not only free from vendor lock-in, but
     22 it also allows for an increasingly diverse set of clients and
     23 sources.
     24 
     25 For example, there are clients ranging from FOSS text only terminal
     26 clients like [`newsboat(1)`](https://newsboat.org) to commercial apps
     27 like [Feedly](https://feedly.com). And despite being drastically
     28 different UI's, their purpose is the same: allow you to subscribe
     29 to any number of feeds, and centralize your notifications.
     30 
     31 The idea is simple, but it's transformed the way I interact with
     32 the web.  It saves me time in not browsing the infinite scroll that
     33 has become social media, and it allows me to stay up to date with
     34 smaller blogs that don't post frequently (cough, like yours truly,
     35 cough).
     36 
     37 Consider a new blog post on this site.  Without a feed, you'd have
     38 to periodically check my `blog(7)` for updates or hear about it
     39 through some other link aggregation or social media site
     40 (Hackernews, Reddit, etc).  Adding a feed allows those who want to
     41 follow to get notifications, without checking other locations or
     42 having to waste time checking back periodically.
     43 
     44 So if you haven't tried a feed reader ever, go find one that suits
     45 your fancy and give it a try!  In an era where user upvoted content
     46 reigns king (Reddit, Facebook, etc), it's really empowering as a
     47 user to decide what you see updates for and to be able to check
     48 them on your own time.  And if you're a publisher of any content,
     49 consider creating a feed for others to follow.  I'll certainly
     50 appreciate it!
     51 
     52 It's never too late to take control of your digital habits, and
     53 using a feed reader is a good place to start.
     54 
     55 ## Implementation
     56 
     57 If you read this far, I thought you might also be interested in
     58 hearing not only the what and the why but also the how.
     59 
     60 Due to the recent migration to using `mdoc(7)` as the markup for this
     61 site (detailed in [my-old-man(7)](/blog/my-old-man.html)), I knew that
     62 finding an off-the-shelf feed generator would be unlikely.
     63 Plus, with my general desire to keep the site build-able by base
     64 OpenBSD, I figured it was as good an excuse as any to read the
     65 spec and generate it myself.
     66 
     67 I ended up choosing Atom over RSS mostly based on some online
     68 opinions that it is a stricter standard, but I can't say much to
     69 back that up.  What I can say is that after the initial confusion
     70 of how to escape the embedded HTML in the XML feed, it was pretty
     71 smooth sailing.
     72 
     73 The full implementation is in
     74 [genatom.sh](https://git.sr.ht/~akarle/alexkarle.com/tree/5c1fd5edca840e3ec2f8a80b8fed763d30cfa11a/item/bin/genatom.sh)
     75 and basically boils down to:
     76 
     77 1. `grep(1)` call through the blog.7 file to get a list of entries
     78    and their dates
     79 2. Print the header of the XML (with newest date from 1.)
     80 3. For each item in entries, add the XML entry along with the
     81    content as generated by `mandoc(1)` with the `-O` fragment option.
     82    This ensures the "notification" has the full post -- users
     83    never even need to visit the site!
     84 4. End by printing the footer of the XML
     85 
     86 And that's it!  The only real trick was to use
     87 [CDATA sections](https://en.wikipedia.org/wiki/CDATA) around the entry
     88 content in the XML to escape the HTML tags.
     89 
     90 And of course, like everything else in this blog, it rebuilds on
     91 `git-push` via a call to `make(1)`.
     92 
     93 ## See Also
     94 
     95 - [My Atom feed](https://alexkarle.com/atom.xml)
     96 - [Wiki page on Atom](https://en.wikipedia.org/wiki/Atom_(Web_standard%29)
     97 - [Atom RFC](https://tools.ietf.org/html/rfc4287)
     98 - [Related advocacy](https://atthis.link/blog/2021/rss.html)
     99 
    100 [Back to blog](/blog)