Javier Pacheco

Home | Blog | About Me |

Attempt to test RSS feeds

Hello.

This post, is about more like a testing, because, I'm trying to add RSS feeds into this "web-page", so basically this is a test, and see if when I build the webpage is going to work… or not. So, this is the preview and read this post to see what I'm trying to do.

Rss Feeds.

First, what is rss feeds? This is what wikipedia have in their page:

RSS (RDF Site Summary or Really Simple Syndication) is a web feed that allows users and applications to access updates to websites in a standardized, computer-readable format. Subscribing to RSS feeds can allow a user to keep track of many different websites in a single news aggregator, which constantly monitor sites for new content, removing the need for the user to manually check them. News aggregators (or "RSS readers") can be built into a browser, installed on a desktop computer, or installed on a mobile device.

Well whit that read, what I'm going to do is to export a file with the .xml extension, and stored in my host codeberg pages, well that is the goal, but I'm not sure about it.

Packages needed:

These are the packages that we need to use to make the rss file:

  • ox-publish.
  • ox-rss.
  • webfeeder.
  • esxml.

and these need to be in the build-site.el script:

;; Check and install dependencies
(dolist (package '(htmlize ox-rss webfeeder esxml))
  (unless (package-installed-p package)
    (package-install package)))

;; Load publishing system
(require 'ox-publish)
(require 'ox-rss)
(require 'webfeeder)
(require 'esxml)

Functions to use:

Now declare some functions to parse in the public folder that we create for save the exported html files.

;;; build RSS feed

(defun dw/rss-extract-date (html-file)
  "Extract the post date from an HTML file."
  (with-temp-buffer
    (insert-file-contents html-file)
    (let* ((dom (libxml-parse-html-region (point-min) (point-max)))
           (date-string (dom-text (car (dom-by-class dom "date"))))
           (parsed-date (parse-time-string date-string))
           (day (nth 3 parsed-date))
           (month (nth 4 parsed-date))
           (year (nth 5 parsed-date)))
      ;; NOTE: Hardcoding this at 8am for now
      (encode-time 0 0 8 day month year))))

(setq webfeeder-date-function #'dw/rss-extract-date)

(webfeeder-build "rss.xml"
                 "./public"
                 "https://jpacheco.codeberg.page/"
                 (mapcar (lambda (file) (concat "posts/" file))
                         (let ((default-directory (expand-file-name "./public/posts/")))
                           (directory-files-recursively "./" ".*\\.html$")))
                 :builder 'webfeeder-make-rss
                 :title "Javier Pacheco's Blog"
                 :description "Posts, information and resources from Javier Pacheco"
                 :author "Javier Pacheco")

Testing.

Well, this post ends here, now in a few minutes this post is going to be uploaded, and I'll see if rss feeds generator actually works whit the functions and commands above.

Date: 2023-12-26 Tue 14:21

Emacs 29.3 (Org mode 9.6.15)