Repository: mbertolacci/lorem-rss
Branch: master
Commit: a575fdc92972
Files: 7
Total size: 19.9 KB
Directory structure:
gitextract_vjehonqu/
├── .gitignore
├── Dockerfile
├── Procfile
├── README.md
├── package.json
├── web.coffee
└── web.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
node_modules
================================================
FILE: Dockerfile
================================================
FROM node:12-alpine
COPY package* ./
RUN npm install -g foreman && npm install
COPY . .
EXPOSE 5000
CMD ["nf", "start"]
================================================
FILE: Procfile
================================================
web: node web.js
================================================
FILE: README.md
================================================
# Lorem RSS
Generates RSS feeds with content updated at regular intervals. I wrote this to
answer a [question I asked on Stack Overflow](http://stackoverflow.com/questions/18202048/are-there-any-constantly-updating-rss-feed-services-to-use-for-testing-or-just).
## API
Visit [http://lorem-rss.herokuapp.com/feed](http://lorem-rss.herokuapp.com/feed), with the following optional parameters:
* _unit_: one of second, minute, day, month, or year
* _interval_: an integer to repeat the units at. For seconds and minutes this interval must evenly divide 60, for month it must evenly divide 12, and for day and year it can only be 1.
* _length_: an integer that determines the number of items in the feed. Must be greater or equal to 0 and smaller or equal to 1000. Defaults to 10 items.
## Examples
* The default, updates once a minute, with 10 entries: [/feed](http://lorem-rss.herokuapp.com/feed)
* Update every second instead of minute: [/feed?unit=second](http://lorem-rss.herokuapp.com/feed?unit=second)
* Update every 30 seconds: [/feed?unit=second&interval=30](http://lorem-rss.herokuapp.com/feed?unit=second&interval=30)
* Update once a day: [/feed?unit=day](http://lorem-rss.herokuapp.com/feed?unit=day)
* Update every 6 months: [/feed?unit=month&interval=6](http://lorem-rss.herokuapp.com/feed?unit=month&interval=6)
* Update once a year: [/feed?unit=year](http://lorem-rss.herokuapp.com/feed?unit=year)
* Default feed with 42 entries: [/feed?length=42"](http://lorem-rss.herokuapp.com/feed?length=42)
* **Invalid example:** update every 7 minutes (does not evenly divide 60): [/feed?unit=minute&interval=7](http://lorem-rss.herokuapp.com/feed?unit=minute&interval=7)
## Running locally
The project contains a Dockerfile that can be used to run Lorem RSS locally. Build via:
```
docker build . -t lorem-rss
```
Run via:
```
docker run --rm -it -p 5000:5000 lorem-rss
```
With thanks given to [eelkevdbos](https://github.com/eelkevdbos), who contributed the Dockerfile.
## Copyright
### The feed and documentation
Licensed by Michael Bertolacci under a Creative Commons Attribution 3.0 Unported License.
### The code
The MIT License (MIT)
Copyright (c) 2013 Michael Bertolacci
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: package.json
================================================
{
"name": "lorem-rss",
"version": "0.0.1",
"description": "",
"main": "web.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "BSD",
"dependencies": {
"crypto": "~0.0.3",
"express": "^4.18.2",
"lodash": "^4.17.21",
"lorem-ipsum": "~0.1.1",
"moment": "^2.29.4",
"morgan": "^1.9.1",
"rss": "^1.2.2",
"seed-random": "~1.0.1"
}
}
================================================
FILE: web.coffee
================================================
###
The MIT License (MIT)
Copyright (c) 2013 Michael Bertolacci
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
###
express = require 'express'
RSS = require 'rss'
moment = require 'moment'
_ = require 'lodash'
morgan = require 'morgan'
loremIpsum = require 'lorem-ipsum'
seedRandom = require 'seed-random'
crypto = require 'crypto'
app = express()
app.use morgan('combined')
units = {
second: {
nextUp: 'minute',
mustDivide: 60
}
minute: {
nextUp: 'hour'
mustDivide: 60
}
hour: {
nextUp: 'day'
mustDivide: 24
}
day: {
nextUp: 'year'
mustDivide: 1
}
month: {
nextUp: 'year'
mustDivide: 12
}
year: {
mustDivide: 1
}
}
getNearest = (interval, unit) ->
if interval == 1
return moment().utc().startOf(unit)
else
unitOptions = units[unit]
if unitOptions.mustDivide % interval != 0
throw "When using #{unit}s the interval must divide #{unitOptions.mustDivide}"
now = moment().utc()
returnDate = now.clone().startOf(unitOptions.nextUp || unit)
returnDate[unit](now[unit]() - now[unit]() % interval)
return returnDate
app.get '/', (request, response) ->
response.send """
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Lorem RSS</title>
<meta name="description" content="Web service that generates lorem ipsum RSS feeds">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/4.2.3/css/normalize.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/4.2.3/css/foundation.min.css">
<style type="text/css">
ul.indent {
position: relative;
left: 20px;
}
</style>
</head>
<body>
<div class="row">
<div class="large-12 columns">
<h1>Lorem RSS</h1>
<p>
Generates RSS feeds with content updated at regular intervals. I wrote this to
answer a <a href="http://stackoverflow.com/questions/18202048/are-there-any-constantly-updating-rss-feed-services-to-use-for-testing-or-just">question I asked on Stack Overflow</a>.
</p>
<p>
The code for this service is <a href="https://github.com/mbertolacci/lorem-rss">available on GitHub</a>.
</p>
<h2>API</h2>
<p>
Visit <a href="/feed">/feed</a>, with the following optional parameters:
</p>
<ul class="disc indent">
<li>
<em>unit</em>: one of second, minute, day, month, or year
</li>
<li>
<em>interval</em>: an integer to repeat the units at.
For seconds and minutes this interval must evenly divide 60,
for month it must evenly divide 12, and for day and year it
can only be 1.
</li>
<li>
<em>length</em>: an integer that determines the number of items in the feed.
Must be greater or equal to 0 and smaller or equal to 1000. Defaults to 10 items.
</li>
</ul>
<h2>Examples</h2>
<ul class="disc indent">
<li>
The default, updates once a minute, with 10 entries: <a href="/feed">/feed</a>
</li>
<li>
Update every second instead of minute: <a href="/feed?unit=second">/feed?unit=second</a>
</li>
<li>
Update every 30 seconds: <a href="/feed?unit=second&interval=30">/feed?unit=second&interval=30</a>
</li>
<li>
Update once a day: <a href="/feed?unit=day">/feed?unit=day</a>
</li>
<li>
Update every 6 months: <a href="/feed?unit=month&interval=6">/feed?unit=month&interval=6</a>
</li>
<li>
Update once a year: <a href="/feed?unit=year">/feed?unit=year</a>
</li>
<li>
Default feed with 42 entries: <a href="/feed?length=42">/feed?length=42</a>
</li>
<li>
<strong>Invalid example:</strong>
update every 7 minutes (does not evenly divide 60):
<a href="/feed?unit=minute&interval=7">/feed?unit=minute&interval=7</a>
</li>
</ul>
<hr/>
<p class="copyright">
<a rel="license" href="http://creativecommons.org/licenses/by/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/3.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" property="dct:title" rel="dct:type">Lorem RSS</span> (this page and the feeds generated) by <span xmlns:cc="http://creativecommons.org/ns#" property="cc:attributionName">Michael Bertolacci</span> are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/deed.en_US">Creative Commons Attribution 3.0 Unported License</a>.
</p>
</div>
</div>
</body>
</html>
"""
app.get '/feed', (request, response) ->
if request.query.interval?
interval = parseInt request.query.interval
else
interval = 1
if not interval
response.send(500, "Interval must be an integer")
return
if interval <= 0
response.send(500, "Interval must be greater than 0")
return
unit = request.query.unit || 'minute'
if not units[unit]
response.send(500, "Unit must be one of #{_.keys(units).join(', ')}")
return
length = request.query.length || 10
if length < 0 or length > 1000
response.send(500, "Length must be greater or equal to 0 and smaller or equal to 1000")
return
pubDate = getNearest(interval, unit)
feed = new RSS({
title: "Lorem ipsum feed for an interval of #{interval} #{unit}s with #{length} item(s)",
description: 'This is a constantly updating lorem ipsum feed'
site_url: 'http://example.com/',
copyright: 'Michael Bertolacci, licensed under a Creative Commons Attribution 3.0 Unported License.',
ttl: Math.ceil(moment.duration(interval, unit).asMinutes()),
pubDate: pubDate.clone().toDate()
})
pubDate = getNearest(interval, unit)
for i in [0...length]
feed.item {
title: "Lorem ipsum #{pubDate.format()}",
description: loremIpsum(
random: seedRandom(pubDate.unix())
)
url: "http://example.com/test/#{pubDate.format('X')}"
author: 'John Smith',
date: pubDate.clone().toDate()
}
pubDate = pubDate.subtract(interval, unit)
etagString = feed.pubDate + interval + unit
response.set 'Content-Type', 'application/rss+xml'
response.set 'ETag', "\"#{crypto.createHash('md5').update(etagString).digest("hex");}\""
response.send feed.xml()
port = process.env.PORT || 5000;
app.listen port, () ->
console.log("Listening on " + port);
================================================
FILE: web.js
================================================
// Generated by CoffeeScript 2.5.1
(function() {
/*
The MIT License (MIT)
Copyright (c) 2013 Michael Bertolacci
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
var RSS, _, app, crypto, express, getNearest, loremIpsum, moment, morgan, port, seedRandom, units;
express = require('express');
RSS = require('rss');
moment = require('moment');
_ = require('lodash');
morgan = require('morgan');
loremIpsum = require('lorem-ipsum');
seedRandom = require('seed-random');
crypto = require('crypto');
app = express();
app.use(morgan('combined'));
units = {
second: {
nextUp: 'minute',
mustDivide: 60
},
minute: {
nextUp: 'hour',
mustDivide: 60
},
hour: {
nextUp: 'day',
mustDivide: 24
},
day: {
nextUp: 'year',
mustDivide: 1
},
month: {
nextUp: 'year',
mustDivide: 12
},
year: {
mustDivide: 1
}
};
getNearest = function(interval, unit) {
var now, returnDate, unitOptions;
if (interval === 1) {
return moment().utc().startOf(unit);
} else {
unitOptions = units[unit];
if (unitOptions.mustDivide % interval !== 0) {
throw `When using ${unit}s the interval must divide ${unitOptions.mustDivide}`;
}
now = moment().utc();
returnDate = now.clone().startOf(unitOptions.nextUp || unit);
returnDate[unit](now[unit]() - now[unit]() % interval);
return returnDate;
}
};
app.get('/', function(request, response) {
return response.send(`<html><head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Lorem RSS</title> <meta name="description" content="Web service that generates lorem ipsum RSS feeds"> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/4.2.3/css/normalize.min.css"> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/4.2.3/css/foundation.min.css"> <style type="text/css"> ul.indent{position: relative; left: 20px;}</style></head><body> <div class="row"> <div class="large-12 columns"> <h1>Lorem RSS</h1> <p> Generates RSS feeds with content updated at regular intervals. I wrote this to answer a <a href="http://stackoverflow.com/questions/18202048/are-there-any-constantly-updating-rss-feed-services-to-use-for-testing-or-just">question I asked on Stack Overflow</a>. </p><p> The code for this service is <a href="https://github.com/mbertolacci/lorem-rss">available on GitHub</a>. </p><h2>API</h2> <p> Visit <a href="/feed">/feed</a>, with the following optional parameters: </p><ul class="disc indent"> <li> <em>unit</em>: one of second, minute, day, month, or year </li><li> <em>interval</em>: an integer to repeat the units at. For seconds and minutes this interval must evenly divide 60, for month it must evenly divide 12, and for day and year it can only be 1. </li><li> <em>length</em>: an integer that determines the number of items in the feed. Must be greater or equal to 0 and smaller or equal to 1000. Defaults to 10 items. </li></ul> <h2>Examples</h2> <ul class="disc indent"> <li> The default, updates once a minute, with 10 entries: <a href="/feed">/feed</a> </li><li> Update every second instead of minute: <a href="/feed?unit=second">/feed?unit=second</a> </li><li> Update every 30 seconds: <a href="/feed?unit=second&interval=30">/feed?unit=second&interval=30</a> </li><li> Update once a day: <a href="/feed?unit=day">/feed?unit=day</a> </li><li> Update every 6 months: <a href="/feed?unit=month&interval=6">/feed?unit=month&interval=6</a> </li><li> Update once a year: <a href="/feed?unit=year">/feed?unit=year</a> </li><li> Default feed with 42 entries: <a href="/feed?length=42">/feed?length=42</a> </li><li> <strong>Invalid example:</strong> update every 7 minutes (does not evenly divide 60): <a href="/feed?unit=minute&interval=7">/feed?unit=minute&interval=7</a> </li></ul> <hr/> <p class="copyright"> <a rel="license" href="http://creativecommons.org/licenses/by/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/3.0/88x31.png"/></a><br/><span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" property="dct:title" rel="dct:type">Lorem RSS</span> (this page and the feeds generated) by <span xmlns:cc="http://creativecommons.org/ns#" property="cc:attributionName">Michael Bertolacci</span> are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/deed.en_US">Creative Commons Attribution 3.0 Unported License</a>. </p></div></div></body></html>`);
});
app.get('/feed', function(request, response) {
var etagString, feed, i, interval, j, length, pubDate, ref, unit;
if (request.query.interval != null) {
interval = parseInt(request.query.interval);
} else {
interval = 1;
}
if (!interval) {
response.send(500, "Interval must be an integer");
return;
}
if (interval <= 0) {
response.send(500, "Interval must be greater than 0");
return;
}
unit = request.query.unit || 'minute';
if (!units[unit]) {
response.send(500, `Unit must be one of ${_.keys(units).join(', ')}`);
return;
}
length = request.query.length || 10;
if (length < 0 || length > 1000) {
response.send(500, "Length must be greater or equal to 0 and smaller or equal to 1000");
return;
}
pubDate = getNearest(interval, unit);
feed = new RSS({
title: `Lorem ipsum feed for an interval of ${interval} ${unit}s with ${length} item(s)`,
description: 'This is a constantly updating lorem ipsum feed',
site_url: 'http://example.com/',
copyright: 'Michael Bertolacci, licensed under a Creative Commons Attribution 3.0 Unported License.',
ttl: Math.ceil(moment.duration(interval, unit).asMinutes()),
pubDate: pubDate.clone().toDate()
});
pubDate = getNearest(interval, unit);
for (i = j = 0, ref = length; (0 <= ref ? j < ref : j > ref); i = 0 <= ref ? ++j : --j) {
feed.item({
title: `Lorem ipsum ${pubDate.format()}`,
description: loremIpsum({
random: seedRandom(pubDate.unix())
}),
url: `http://example.com/test/${pubDate.format('X')}`,
author: 'John Smith',
date: pubDate.clone().toDate()
});
pubDate = pubDate.subtract(interval, unit);
}
etagString = feed.pubDate + interval + unit;
response.set('Content-Type', 'application/rss+xml');
response.set('ETag', `\"${crypto.createHash('md5').update(etagString).digest("hex")}\"`);
return response.send(feed.xml());
});
port = process.env.PORT || 5000;
app.listen(port, function() {
return console.log("Listening on " + port);
});
}).call(this);
gitextract_vjehonqu/ ├── .gitignore ├── Dockerfile ├── Procfile ├── README.md ├── package.json ├── web.coffee └── web.js
Condensed preview — 7 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (21K chars).
[
{
"path": ".gitignore",
"chars": 13,
"preview": "node_modules\n"
},
{
"path": "Dockerfile",
"chars": 120,
"preview": "FROM node:12-alpine\nCOPY package* ./\nRUN npm install -g foreman && npm install\nCOPY . .\nEXPOSE 5000\nCMD [\"nf\", \"start\"]\n"
},
{
"path": "Procfile",
"chars": 16,
"preview": "web: node web.js"
},
{
"path": "README.md",
"chars": 3246,
"preview": "# Lorem RSS\n\nGenerates RSS feeds with content updated at regular intervals. I wrote this to\nanswer a [question I asked o"
},
{
"path": "package.json",
"chars": 431,
"preview": "{\n \"name\": \"lorem-rss\",\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"main\": \"web.js\",\n \"scripts\": {\n \"test\": \"echo"
},
{
"path": "web.coffee",
"chars": 8730,
"preview": "###\nThe MIT License (MIT)\n\nCopyright (c) 2013 Michael Bertolacci\n\nPermission is hereby granted, free of charge, to any p"
},
{
"path": "web.js",
"chars": 7812,
"preview": "// Generated by CoffeeScript 2.5.1\n(function() {\n /*\n The MIT License (MIT)\n\n Copyright (c) 2013 Michael Bertolacci\n\n"
}
]
About this extraction
This page contains the full source code of the mbertolacci/lorem-rss GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 7 files (19.9 KB), approximately 5.4k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.