Skip to content

San7o/tiny-rss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny-rss

Flexible RSS 2.0 feed generator from org files for your blog, with support for filters and multiple feeds for different categories.

Getting started

To generate a feed item from an heading, you can add the properties TITLE, RSS, DATE, AUTHOR, LINK and CATEGORY to the heading, like in the below example. Note that only the RSS property is required to generate the feed item. If no title is specified, It will default to the title of the heading. Other unspecified properties will be set to nil.

* My blog post!
  :PROPERTIES:
  :RSS: t
  :DATE: 22 Feb 2025 14:45:30 PST
  :CATEGORY: Tech
  :AUTHOR: Richard Stallman
  :LINK: myblog.com/my-blog.html
  :END:
  My beautiful blog here...

To generate the RSS file[s], call tiny-rss-generate with at least the arguments input-directory and output-directory, representing respectively the input directory where the org files are fetched, and the output directory where the .rss files will be generated. If the output directory does not exist, It will be created. Additional options are documented later.

(require 'tiny-rss)
(tiny-rss-generate
 :input-directory "/my/org/files"
 :output-directory "/output/dir/here")

tiny-rss will generate a different .rss feed for each specified category, and aggregate all the rss items with the same category in the same category file. Each feed filename follows the convention feed$CATEGORY.rss. Each item will contain the properties specified in the header and all the content under that header, converted in html.

Advanced Usage

Category Info

The user can specify metadata information about each category. Those information include a title, a link and a description. Each .rss file will contain those three fileds which are fetched by clients, so you may be interested in setting them.

To specify information about certain categories, you can pass a list of category information to tiny-rss-generate via category-info like this:

(tiny-rss-generate
 :input-directory "~/projects/tiny-rss/examples"
 :output-directory "~/projects/tiny-rss/output"
 :category-info '((:category "Blog"
                             :title "RSS for my blog"
                             :link "my-website.com"
                             :description "My RSS feeds")
                  (:category "Tech"
                             :title "MyTech"
                             :link "tech-website.com"
                             :description "RSS for Tech news")))

Note that if you don’t specify a category name, or you set it to nil, the information will refer to the default category (or no category, which is the same thing). Any unspecified info will be set to nil by default.

Filters

You can specify a filter for your feeds. A filter is a function that takes an RSS item and returns either t or nil specifying if this RSS item should be included in the output or not, respectively. An item is a list with the form (TITLE DATE CATEGORY AUTHOR LINK CONTENT).

For example, this is the simplest filter you can write, which accepts everything:

(defun tiny-rss-filter-accept (item)
  t)

To register the filter, pass the the :filter argument to the function tiny-rss-generate like so:

(tiny-rss-generate
 :input-directory "~/projects/tiny-rss/examples"
 :output-directory "~/projects/tiny-rss/output"
 :filter 'tiny-rss-filter-accept)

If you don’t specify a filter, this is the default one. Another filter already provided accepts only the posts written after a certain date:

(defun tiny-rss-filter-after-date (item)
  "Accepts only the dates past the date set in the variable
 =tiny-rss-filter-after-date= which should follow the format
 YYYYMMDD. The date in the rss properties is expected to follow
 rfc822 format."
(let* ((parsed (tiny-rss-parse-rfc822-timestamp (nth 1 item)))
       (day (nth 1 parsed))
       (month (nth 2 parsed))
       (year (nth 3 parsed)))
  (setq month (tiny-rss-rfc822-month-to-number month))
  (if (string> (concat year month day) tiny-rss-filter-after-date)
  t nil)))

It is easy to imagine how you could use this to filter just the posts of the last month, for example.

Enforce rfc822

The RSS 2.0 date format follows RFC822’s conventions, a full date looks like Sat, 07 Sep 2002 00:00:01 GMT. This in not enforced by default, however you can assert that the feeds follow the convention by specifying enforce-rfc822 t in the arguments to tiny-rss-generate:

(tiny-rss-generate
 :input-directory "~/projects/tiny-rss/examples"
 :output-directory "~/projects/tiny-rss/output"
 :enforce-rfc822 t)

Motivation

I was looking for an RSS feed generator for my org-generated online diary https://san7o.github.io/giovanni-diary/. This website is not the usual blog, It resembles more a wiki, with many files spreaded across multiple directories. Some of those files are considered “blog posts”, while some others are considered as glue to those posts, to give a more general context and for effective indexing.

For those reasons, I needed a really flexible RSS feed generator that would generate feeds only for the files I wanted, which may be anywhere in the directory tree. Furthermore, I may want to send the feed for only a particular section within the same file (because there is a lot of framing around the actual “posts”). Just to be clear, with “post” I mean a decently long text section about some topic that I want to share (therefore, I want a feed to be generated).

Existing solutions like https://github.com/emacsmirror/ox-rss do not provide the flexibility that I wanted, at least not with some thinkering. It would take less time to write my own than to thinker with those packages, or so I thought.

So here we are, this was my first ever mini-coding project in emacs lisp, it took me one day of coding and I will put additional hours in the following days to finish the last details and document everything. The simplicity of the program is simply amazing.

Further work

The RSS generator works well, however It can be improved in many ways. Here are some ideas:

  • improve the documentation to get ready for MELPA.

License

Everything is GPL-3.0. Note that the name has nothing to do with Tiny Tiny RSS, which is a web-based rss client. I did’t know about this before starting my project.

About

Flexible RSS 2.0 feeds generator from org files for your blog, with support for fitlers and multiple feeds for different categories.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors