Skip to content

Instantly share code, notes, and snippets.

@gaby-de-wilde
Last active August 27, 2017 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gaby-de-wilde/341a0d1897e47b57af39fd0a2a06b718 to your computer and use it in GitHub Desktop.
Save gaby-de-wilde/341a0d1897e47b57af39fd0a2a06b718 to your computer and use it in GitHub Desktop.
Even Shorter Syndication [ESS] Node.js module

The module returns the ESS and has 2 arguments:

  1. The link to the RSS or Atom feed described.
  2. An array of objects formatted like this:
[  
  { pubDate: 1503674340000, title: "hello world"},  
  { pubDate: 1503674220000, title: "foo"        },  
  { pubDate: 1503674160000, title: "bar"        }  
]

install with:

npm i -S gist:341a0d1897e47b57af39fd0a2a06b718

About Even Shorter Syndication

ESS is a very compact description of an RSS or Atom site feed.

It is structured like this:

buildTime, feedUrl,  
minutesBeforeBuild, titleDumbChecksum,  
minutesBeforeBuild, titleDumbChecksum,  
minutesBeforeBuild, titleDumbChecksum,  
minutesBeforeBuild, titleDumbChecksum

Where:

buildTime          = The build time of the ESS in seconds (rounded down to be divisable by 60)  
feedUrl            = A link to the RSS or Atom feed described by the ESS  
minutesBeforeBuild = The publication date in minutes before buildTime  
titleDumbChecksum  = A checksum in case the feed has multiple publications sharing the same date

Read more about ESS and NNO (No Nonsense Outline) here:

http://go-here.nl/ess-and-nno

module.exports = function(rssUrl,items){
  var buildTimeMinutes = Math.floor(Date.now()/60000);
  return [ buildTimeMinutes*60, rssUrl ].concat(
    items.map(x=> [ '\n'+
      (buildTimeMinutes - Math.floor((x.pubDate*1)/60000)),
      [...x.title].reduce((a,b)=>a+b.charCodeAt(0)&255,0)].join()
    )
  ).join()
}
{
"name": "ess",
"description": "Even Shorter Syndication [ESS] file formatter",
"version": "1.0.0",
"main": "index.js",
"repository": "https://gist.github.com/gaby-de-wilde/341a0d1897e47b57af39fd0a2a06b718",
"author": "gaby-de-wilde",
"license": "WTFPL",
"homepage": "http://go-here.nl/ess-and-nno"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment