Commit b92f6cb6 authored by yPhil's avatar yPhil
Browse files

Ready to merge 1.3.2

- New favicon error handling
- New favicon saving routine
- Support for protocol-relative urls in images
- New feeds saved back
- Libs version update
- Default feeds update
parent 0b18a23f
Pipeline #424763 passed with stage
in 47 seconds
This diff is collapsed.
{
"name": "petrolette",
"description": "The news reader that doesn't know you",
"version": "1.3.1",
"version": "v1.3.2",
"private": true,
"license": "GPL-3.0-only",
"HTTP_PORT": 8000,
......@@ -41,13 +41,12 @@
"morgan": "^1.10.0",
"node-fetch": "^2.6.1",
"npm": "^7.10.0",
"pm2": "^4.5.6",
"pm2": "^5.1.0",
"sanitize": "^2.1.0"
},
"devDependencies": {
"mocha": "^8.3.2",
"mocha": "^9.0.0",
"nyc": "^15.1.0",
"rollup": "^2.47.0",
"should": "^13.2.3"
}
}
......@@ -398,9 +398,7 @@ i.tabCloser:hover {
flex-grow: 4;
flex-shrink: 1;
font-family: var(--font-feed-title);
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
text-rendering: optimizeLegibility;
font-size: var(--feed-title-font-size);
font-style: oblique;
text-transform: capitalize;
......
......@@ -287,15 +287,13 @@ PTL.dialog = {
.data('name', newName)
.data('type', newType);
console.log('newUrl: %s (%s)', newUrl, $dataStore.data('url'));
if ($('input[name=killFeedCheckbox]:checked').val() === 'on') {
$feed.hide('fade', 1000, function() { $feed.remove(); });
} else {
PTL.feed.populate($button);
}
// PTL.tab.saveTabs();
PTL.tab.saveTabs();
PTL.dialog.kill($dialog);
}
......@@ -332,7 +330,7 @@ PTL.dialog = {
});
function guessError() {
$guessSpinner.removeClass('icon-cog spin ui-state-success')
$guessSpinner.removeClass('icon-refresh spin ui-state-success')
.addClass('icon-error');
$guessButton
......@@ -408,7 +406,7 @@ PTL.dialog = {
$guessSpinner
.removeClass('icon-checked icon-error icon-search ui-state-success ui-state-error')
.addClass('spin icon-cog');
.addClass('spin icon-refresh');
$guessButton.removeClass('icon-checked ui-state-success ui-state-error');
$.get('/discover', {
......@@ -419,7 +417,7 @@ PTL.dialog = {
}).fail(function(req, status, xhr) {
guessError();
}).done(function(feed) {
$guessSpinner.removeClass('spin icon-cog');
$guessSpinner.removeClass('spin icon-refresh');
$feedGuessInput.val(feed);
......
......@@ -58,9 +58,9 @@ PTL.feed = {
.data('title', 'Select this feed', url)
.attr('title', PTL.tr('Select this feed', url))
.click(function() {
$(this).parent().parent().parent().parent()
$(this).toggleClass('icon-checked icon-checkbox')
.parent().parent().parent().parent()
.toggleClass('selected');
$(this).toggleClass('icon-checked icon-checkbox');
});
const $deleteIcon = $('<i>')
......@@ -90,9 +90,7 @@ PTL.feed = {
.click(function() {
$('.selected').removeClass('selected');
$('.icon-checked').toggleClass('icon-checked icon-checkbox');
PTL.feed.populate($(this), progress)
.then(() => {return true;})
.catch(error => {console.log('whoap: %s (%s)', JSON.stringify(error));});
PTL.feed.populate($(this), progress);
});
const $feedControls = $('<div>')
......@@ -312,15 +310,16 @@ PTL.feed = {
if (!videoUrl && imageUrl && typeof imageUrl !== 'undefined' && !imageUrl.includes('pixel')) {
$imageLink
.attr('href', imageUrl.replace('http://', 'https://'))
.attr('href', imageUrl)
.attr('title', $summary.trim())
.attr('data-fancybox', 'gallery')
.attr('data-caption', '<a href="' + item.link + '" class="ui-button ui-corner-all" title="' + $summary.trim() + '">' + item.title + '</a>');
if (!(imageUrl.indexOf('http://') === 0 || imageUrl.indexOf('https://') === 0)) {
imageUrl = feedHost + imageUrl;
}
const protocols = ['http://', 'http://', '//'];
if (protocols.indexOf(imageUrl) !== -1) imageUrl = feedHost + imageUrl;
$image = $('<img>')
.attr('src', '/static/images/loading.gif')
.attr('data-srcset', imageUrl.replace('http://', 'https://'))
......
......@@ -3080,8 +3080,8 @@
"nbitems": 10
},
{
"url": "http://journalduhacker.net/comments.rss",
"name": "Journal du hacker: Derniers commentaires",
"url": "http://journalduhacker.net/rss",
"name": "Journal du hacker",
"type": "mixed",
"limit": 220,
"status": "off",
......
const fetch = require('node-fetch'),
iconv = require('iconv-lite'),
FeedParser = require('feedparser');
iconv = require('iconv-lite'),
FeedParser = require('feedparser');
exports.getFeed = getFeed;
......@@ -40,7 +40,7 @@ function formatError(error) {
}
function getFeed(feedUrl, lastItem, callback) {
fetch(feedUrl, {
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36',
'accept': 'text/html,application/xhtml+xml',
......
......@@ -17,33 +17,34 @@ console.error('### (re)START ## Version (%s)', pjson.version);
router.use(sanitize);
const downloadFile = (async (url, path) => {
const res = await fetch(url);
const fileStream = fs.createWriteStream(path);
await new Promise((resolve, reject) => {
res.body.pipe(fileStream);
res.body.on("error", reject);
fileStream.on("finish", resolve);
});
});
router.get('/favicon', function(req, res) {
favrat(req.query.url, function(error, url) {
favrat(req.query.url, async function(error, url) {
if (error) {
res.status(500).send(error);
} else if (url) {
// if (!url.startsWith('http') || !url.startsWith('//')) url = 'http://' + url.substring(url.indexOf("/") + 1);
const hash = crypto.createHash('md5').update(url).digest('hex'),
fileName = hash + '.favicon',
filePath = path.join(pjson.FAVICONS_CACHE_DIR, fileName);
downloadFile(url, filePath);
try {
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);
});
res.send(hash);
} catch (err) {
res.status(500).send(error);
}
}
......
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