Coder Social home page Coder Social logo

webfeeder's Introduction

Emacs Webfeeder

Webfeeder is an Emacs library to generate RSS and Atom feeds from HTML files.

Other webfeed generators have been written for Emacs, but either they are tied to other projects like blog generators, or they only work on Org files like ox-rss. Since Webfeeder generates webfeeds from HTML files, it is more general.

The various elements of the HTML input are parsed with customizable functions. For instance, Webfeeder offers two functions to parse the title: webfeeder-title-libxml (using libxml if your Emacs is linked against it) and the less reliable webfeeder-title-default. Feel free to write you own function and bind webfeeder-title-function before generating the feeds.

The generated feeds should be valid on https://validator.w3.org/feed/. If not, it’s a bug, please report.

The full list of customizable functions is documented in webfeeder-html-files-to-items.

Installation

Get the package, either from Guix or ELPA:

M-x package-install RET webfeeder RET

Or clone / download this repository and modify your load-path.

(add-to-list 'load-path (expand-file-name "/path/to/this-package/" user-emacs-directory))

Load the package with

(require 'webfeeder)

It’s recommended to have an Emacs built against libxml, although basic support without libxml is also provided.

Usage

  • Build an Atom feed:
(webfeeder-build
 "atom.xml"
 "./public"
 "https://example.org/"
 '("post1.html" "post2.html" "post3.html")
 :title "My homepage"
 :description "A collection of articles in Atom")
  • To build an RSS feed, use the RSS builder:
(webfeeder-build
 "rss.xml"
 "./public"
 "https://example.org/"
 '("post1.html" "post2.html" "post3.html")
 :title "My homepage"
 :description "A collection of articles in RSS"
 :builder 'webfeeder-make-rss)
  • Use a custom title query function:
(defun my-title-query (html-file)
  "Return the title from the \"title\" class in the HTML file."
  (with-temp-buffer
    (insert-file-contents html-file)
    (let* ((dom (libxml-parse-html-region (point-min) (point-max)))
           (title (dom-text (car (dom-by-class dom "title")))))
      (if (string= "" title)
          nil
        title))))

(let ((webfeeder-title-function 'my-title-query))
  (webfeeder-build
   ; ...))
  • Limit the feed to 20 articles:
(webfeeder-build
 ; ...
 :max-entries 20)
  • Filter some entries with a predicate
(defun item-author-is-Alice-p (item)
  (string= (webfeeder-item-author item) "Alice")

(webfeeder-build
 ; ...
 :predicate 'item-author-is-Alice-p)

See the documentation of webfeeder-build for more options.

webfeeder's People

Contributors

ambrevar avatar monnier avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.