Commit 7174fb06 authored by yPhil's avatar yPhil
Browse files

v1.4.9

- Deps update
- Feedrat refactoring
  - Youtube specifics are now useless / obsolete
  - Search feeds is now Pétrolette's job and no longer feedrat's
- #Bug: Lang menu preselection
parent bc7f9124
Pipeline #443067 passed with stage
in 40 seconds
......@@ -19,17 +19,17 @@
"tests"
],
"dependencies": {
"jquery-ui": "1.12.1",
"fancybox": "3.5.7",
"intro.js": "^3.3.1",
"jquery-ui": "^1.12.1",
"fancybox": "^3.5.7",
"intro.js": "4.2.1",
"remotestorage": "rs#1.2.3",
"rs-widget": "1.3.0",
"rs-widget": "^1.3.0",
"DOMPurify": "dompurify#^2.2.6",
"responsively-lazy": "^2.0.2",
"idb-keyval": "^5.0.5",
"mousetrap": "^1.6.5"
},
"resolutions": {
"intro.js": "^3.3.1"
"intro.js": "^4.2.1"
}
}
This diff is collapsed.
{
"name": "petrolette",
"description": "The news reader that doesn't know you",
"version": "v1.4.8",
"private": true,
"license": "GPL-3.0-only",
"HTTP_PORT": 8000,
"HTTPS_PORT": 8001,
"FAVICONS_CACHE_DIR": "favicons-cache",
"engines": {
"node": "*"
},
"repository": {
"type": "git",
"url": "https://framagit.org/yphil/petrolette"
},
"scripts": {
"start": "pm2 start pm2.config.json ; pm2 update",
"restart": "pm2 restart pm2.config.json",
"stop": "pm2 stop petrolette",
"show": "pm2 show petrolette",
"logs": "pm2 logs petrolette",
"errors": "pm2 logs --err --format",
"test": "mocha --timeout 30s",
"coverage": "nyc npm test",
"postinstall": "bower install --allow-root"
},
"dependencies": {
"body-parser": "^1.19.0",
"bower": "^1.8.12",
"compression": "^1.7.4",
"ejs": "^3.1.5",
"express": "^4.17.1",
"favrat": "latest",
"feedrat": "latest",
"feedparser": "^2.2.10",
"helmet": "^4.4.1",
"iconv-lite": "^0.6.2",
"idb": "^6.0.0",
"morgan": "^1.10.0",
"node-fetch": "^2.6.1",
"npm": "^7.20.1",
"pm2": "^5.1.0",
"sanitize": "^2.1.0"
},
"devDependencies": {
"mocha": "^9.0.3",
"nyc": "^15.1.0",
"should": "^13.2.3"
}
"name": "petrolette",
"description": "The news page that doesn't know you",
"version": "v1.4.9",
"private": true,
"license": "GPL-3.0-only",
"HTTP_PORT": 8000,
"HTTPS_PORT": 8001,
"FAVICONS_CACHE_DIR": "favicons-cache",
"engines": {
"node": "*"
},
"repository": {
"type": "git",
"url": "https://framagit.org/yphil/petrolette"
},
"scripts": {
"prestart": "pm2 update",
"start": "pm2 start pm2.config.json",
"restart": "pm2 restart pm2.config.json",
"stop": "pm2 stop petrolette",
"show": "pm2 show petrolette",
"logs": "pm2 logs petrolette --timestamp=HH:mm:ss",
"errors": "pm2 logs petrolette --err --timestamp=HH:mm:ss",
"test": "mocha --timeout 30s",
"coverage": "nyc npm test",
"postinstall": "bower install --allow-root"
},
"dependencies": {
"body-parser": "^1.19.0",
"bower": "^1.8.12",
"compression": "^1.7.4",
"ejs": "^3.1.5",
"express": "^4.17.1",
"favrat": "latest",
"feedrat": "latest",
"feedparser": "^2.2.10",
"helmet": "^4.4.1",
"iconv-lite": "^0.6.2",
"idb": "^6.0.0",
"morgan": "^1.10.0",
"node-fetch": "^2.6.1",
"npm": "^7.20.1",
"pm2": "^5.1.0",
"sanitize": "^2.1.0"
},
"devDependencies": {
"mocha": "^9.0.3",
"nyc": "^15.1.0",
"should": "^13.2.3"
}
}
{
"apps" : [
{
"name" : "petrolette",
"script" : "./http/server.js",
"watch" : true,
"ignore_watch" : ["#*", "favicons-cache", ".git", "node_modules"],
"time" : false
}
]
"apps" : [
{
"name" : "petrolette",
"script" : "./http/server.js",
"watch" : true,
"ignore_watch" : ["favicons-cache", ".git", "node_modules"],
"time" : false,
"instances":"1",
"exec_mode" : "fork_mode"
}
]
}
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
PTL.feed = {
add: function($column, url, name, type, limit, status, iconhash, nbitems, lastitem, isNewFeed, progress) {
const $feed = $('<li>')
......
This diff is collapsed.
......@@ -3,9 +3,9 @@ const express = require('express'),
feeder = require('./feeder'),
fetch = require('node-fetch'),
favrat = require('favrat'),
// favrat = require(__dirname + '/../../favrat/'),
// favrat = require('/home/px/src/favrat/'),
feedrat = require('feedrat'),
// feedrat = require(__dirname + '/../../feedrat/'),
// feedrat = require('/home/px/src/feedrat/'),
fs = require('fs'),
path = require('path'),
crypto = require('crypto'),
......@@ -23,101 +23,107 @@ router.use(sanitize);
router.get('/favicon', function(req, res) {
favrat(req.query.url, async function(error, url) {
favrat(req.query.url, async function(error, url) {
if (error) {
res.status(500).send(error);
} else if (url) {
if (error) {
res.status(500).send(error);
} else if (url) {
const hash = crypto.createHash('md5').update(url).digest('hex'),
fileName = hash + '.favicon',
filePath = path.join(pjson.FAVICONS_CACHE_DIR, fileName);
const hash = crypto.createHash('md5').update(url).digest('hex'),
fileName = hash + '.favicon',
filePath = path.join(pjson.FAVICONS_CACHE_DIR, fileName);
try {
try {
const response = await fetch(url);
const fileStream = fs.createWriteStream(filePath);
const response = await fetch(url);
const fileStream = fs.createWriteStream(filePath);
response.body.pipe(fileStream);
response.body.on("error", () => {
res.status(500).send(error);
});
fileStream.on("finish", () => {
res.send(hash);
});
response.body.pipe(fileStream);
response.body.on("error", () => {
res.status(500).send(error);
});
fileStream.on("finish", () => {
res.send(hash);
});
} catch (err) {
res.status(500).send(error);
}
}
});
} catch (err) {
res.status(500).send(error);
}
}
});
});
router.use(morgan('combined'));
router.get('/feed', function(req, res) {
feeder.getFeed(req.query.url, req.query.lastItem, function (error, feedItems, feedTitle, feedLink, lastItem, totalNewItems) {
if (feedItems && !res.headersSent) {
res.send({
feedItems: feedItems,
feedLink: feedLink,
feedTitle: feedTitle,
lastItem: lastItem,
totalNewItems: totalNewItems
});
} else if (error && !res.headersSent) {
res.send({ error: error });
}
});
feeder.getFeed(req.query.url, req.query.lastItem, function (error, feedItems, feedTitle, feedLink, lastItem, totalNewItems) {
if (feedItems && !res.headersSent) {
res.send({
feedItems: feedItems,
feedLink: feedLink,
feedTitle: feedTitle,
lastItem: lastItem,
totalNewItems: totalNewItems
});
} else if (error && !res.headersSent) {
res.send({ error: error });
}
});
});
router.get('/robots.txt', function (req, res) {
res.type('text/plain');
res.send("User-agent: *\nDisallow: /feed\nDisallow: /discover\nDisallow: /favicon");
res.type('text/plain');
res.send("User-agent: *\nDisallow: /feed\nDisallow: /discover\nDisallow: /favicon");
});
router.get('/discover', function(req, res) {
feedrat(req.query.url, req.query.searchPrefix, function(err, feed) {
if (feed) {
res.send(feed);
} else if (err) {
res.status(500).send(err.code);
} else {
res.status(500).send('No feed found');
try {
var p = new URL(req.query.url);
} catch (error) {
return res.send(new String(req.query.searchPrefix + req.query.url.split(' ')));
}
});
feedrat(req.query.url, function(err, url) {
if (err) {
res.status(500).send(err.code);
} else if (url) {
res.send(url);
} else {
res.status(500).send('No feed found');
}
});
});
router.get('/about/javascript', function(req, res) {
res.render('javascript');
res.render('javascript');
});
router.get('/', function(req, res) {
res.render('index', {
queryString: req.query.add,
version: pjson.version,
favratversion: favratpjson.version,
feedratversion: feedratpjson.version
});
res.render('index', {
queryString: req.query.add,
version: pjson.version,
favratversion: favratpjson.version,
feedratversion: feedratpjson.version
});
});
router.use(function(req, res) {
console.error('404 req: %s (%s)', req.url);
res.status(404).send('404: Page not Found');
console.error('404 req: %s (%s)', req.url);
res.status(404).send('404: Page not Found');
});
router.use(function(error, req, res, next) {
console.error('500 req: %s (%s)', req.url);
res.status(500).send('500: whoa! Internal Server Error');
console.error('500 req: %s (%s)', req.url);
res.status(500).send('500: whoa! Internal Server Error');
});
module.exports = router;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment