Commit bbe301a5 authored by yPhil's avatar yPhil
Browse files

Default feeds re-installed

parent af56efd5
Pipeline #418143 passed with stage
in 30 seconds
......@@ -2,10 +2,10 @@
PTL.feed = {
add:function($column, url, name, type, limit, status, iconhash, nbitems, lastitem, clickNew, isQueryString, progress) {
add: function($column, url, name, type, limit, status, iconhash, nbitems, lastitem, clickNew, isQueryString, progress) {
const $feed = $('<li>')
.attr('class', 'feed');
.attr('class', 'feed');
const $feedImg = $('<img>')
.attr({
......@@ -23,88 +23,90 @@ PTL.feed = {
});
const $newItemsBadge = $('<div>')
.attr('class', 'newItemsBadge hidden');
.attr('class', 'newItemsBadge hidden');
const $feedIcon = $('<i>')
.attr({'class': 'feed-control feedIcon translate',
'title': PTL.tr('Fold / unfold this feed (%1)', url)})
.data('title', 'Fold / unfold this feed (%1)', url)
.click(function() {
if ($feedControls.data('status') == 'on') {
$(this).removeClass('fold')
.parent().parent().parent()
.children('div.feedBody')
.addClass('folded');
$feedControls.data('status', 'off');
$refreshIcon.removeClass('icon-refresh')
.addClass('icon-pin');
} else {
$(this).addClass('fold')
.parent().parent().parent()
.children('div.feedBody')
.removeClass('folded');
$feedControls.data('status', 'on');
$refreshIcon.removeClass('icon-pin')
.addClass('icon-refresh');
}
PTL.tab.saveTabs();
PTL.feed.populate($refreshIcon);
});
.attr({
'class': 'feed-control feedIcon translate',
'title': PTL.tr('Fold / unfold this feed (%1)', url)
})
.data('title', 'Fold / unfold this feed (%1)', url)
.click(function() {
if ($feedControls.data('status') == 'on') {
$(this).removeClass('fold')
.parent().parent().parent()
.children('div.feedBody')
.addClass('folded');
$feedControls.data('status', 'off');
$refreshIcon.removeClass('icon-refresh')
.addClass('icon-pin');
} else {
$(this).addClass('fold')
.parent().parent().parent()
.children('div.feedBody')
.removeClass('folded');
$feedControls.data('status', 'on');
$refreshIcon.removeClass('icon-pin')
.addClass('icon-refresh');
}
PTL.tab.saveTabs();
PTL.feed.populate($refreshIcon);
});
const $selectIcon = $('<i>')
.attr('class', 'feed-control translate icon-checkbox feedSelect')
.data('title', 'Select this feed', url)
.attr('title', PTL.tr('Select this feed', url))
.click(function() {
$(this).parent().parent().parent().parent()
.toggleClass('selected');
$(this).toggleClass('icon-checked icon-checkbox');
});
.attr('class', 'feed-control translate icon-checkbox feedSelect')
.data('title', 'Select this feed', url)
.attr('title', PTL.tr('Select this feed', url))
.click(function() {
$(this).parent().parent().parent().parent()
.toggleClass('selected');
$(this).toggleClass('icon-checked icon-checkbox');
});
const $deleteIcon = $('<i>')
.attr('class', 'feed-control translate icon-trash-empty feed-delete')
.data('title', 'Delete this feed', url)
.attr('title', PTL.tr('Delete this feed', url))
.click(function() {
$('.selected').removeClass('selected');
$('.icon-checked').toggleClass('icon-checked icon-checkbox');
PTL.dialog.killFeed($(this));
});
.attr('class', 'feed-control translate icon-trash-empty feed-delete')
.data('title', 'Delete this feed', url)
.attr('title', PTL.tr('Delete this feed', url))
.click(function() {
$('.selected').removeClass('selected');
$('.icon-checked').toggleClass('icon-checked icon-checkbox');
PTL.dialog.killFeed($(this));
});
const $prefsIcon = $('<i>')
.attr('class', 'feed-control translate icon-cog feedPrefs')
.data('title', 'Edit this feed parameters', url)
.attr('title', PTL.tr('Edit this feed parameters', url))
.click(function() {
$('.selected').removeClass('selected');
$('.icon-checked').toggleClass('icon-checked icon-checkbox');
PTL.dialog.feedPrefs($(this));
});
.attr('class', 'feed-control translate icon-cog feedPrefs')
.data('title', 'Edit this feed parameters', url)
.attr('title', PTL.tr('Edit this feed parameters', url))
.click(function() {
$('.selected').removeClass('selected');
$('.icon-checked').toggleClass('icon-checked icon-checkbox');
PTL.dialog.feedPrefs($(this));
});
const $refreshIcon = $('<i>')
.attr('class', 'feed-control translate icon-refresh feedRefresh')
.data('title', 'Refresh this feed', url)
.attr('title', PTL.tr('Refresh this feed', url))
.click(async function() {
// var plop = $(this).parent().parent().parent().next('div.feedBody').find('li').lengh;
$('.selected').removeClass('selected');
$('.icon-checked').toggleClass('icon-checked icon-checkbox');
await PTL.feed.populate($(this), progress);
});
.attr('class', 'feed-control translate icon-refresh feedRefresh')
.data('title', 'Refresh this feed', url)
.attr('title', PTL.tr('Refresh this feed', url))
.click(async function() {
// var plop = $(this).parent().parent().parent().next('div.feedBody').find('li').lengh;
$('.selected').removeClass('selected');
$('.icon-checked').toggleClass('icon-checked icon-checkbox');
await PTL.feed.populate($(this), progress);
});
const $feedControls = $('<div>')
.attr('class', 'feedControls dataStore')
.data('url', url)
.data('name', name)
.data('type', type)
.data('limit', limit)
.data('status', status)
.data('iconhash', iconhash)
.data('nbitems', nbitems)
.data('lastitem', lastitem);
.attr('class', 'feedControls dataStore')
.data('url', url)
.data('name', name)
.data('type', type)
.data('limit', limit)
.data('status', status)
.data('iconhash', iconhash)
.data('nbitems', nbitems)
.data('lastitem', lastitem);
$refreshIcon
.attr('data-url', url)
......@@ -125,34 +127,34 @@ PTL.feed = {
}
const $feedHandle = $('<div>')
.data('title', PTL.tr('Move this feed (%1)', url))
.attr({
title: PTL.tr('Move this feed (%1)', url),
class:'feedHandle'
});
.data('title', PTL.tr('Move this feed (%1)', url))
.attr({
title: PTL.tr('Move this feed (%1)', url),
class: 'feedHandle'
});
const $feedBody = $('<div>').attr('class', 'feedBody').css('height', limit),
$feedHeader = $('<div>').attr('class', 'feedHeader'),
$feedToggle = $('<div>').attr('class', 'feedToggle').append($feedIcon, $feedImg),
$selectDiv = $('<div>').append($selectIcon),
$deleteDiv = $('<div>').append($deleteIcon),
$prefsDiv = $('<div>').append($prefsIcon),
$reloadDiv = $('<div>').append($refreshIcon);
$feedHeader = $('<div>').attr('class', 'feedHeader'),
$feedToggle = $('<div>').attr('class', 'feedToggle').append($feedIcon, $feedImg),
$selectDiv = $('<div>').append($selectIcon),
$deleteDiv = $('<div>').append($deleteIcon),
$prefsDiv = $('<div>').append($prefsIcon),
$reloadDiv = $('<div>').append($refreshIcon);
const $titleDiv = $('<div>')
.attr({
title: name || PTL.tr('New feed'),
class:'feedTitle trucate'
});
.attr({
title: name || PTL.tr('New feed'),
class: 'feedTitle trucate'
});
const $titleLink = $('<a>')
.attr('href', url)
.attr('target', '_blank')
.html(name || PTL.tr('New feed'));
.attr('href', url)
.attr('target', '_blank')
.html(name || PTL.tr('New feed'));
$feedControls.hover (
function() {$(this).find('.collapsible').show();},
function() {$(this).find('.collapsible').hide('fade', 'fast');}
$feedControls.hover(
function() { $(this).find('.collapsible').show(); },
function() { $(this).find('.collapsible').hide('fade', 'fast'); }
);
if (!PTL.util.isMobile()) {
......@@ -164,7 +166,7 @@ PTL.feed = {
}
$feedHeader.hover (function() {
$feedHeader.hover(function() {
$(this).find('img.favicon').hide();
$feedIcon.removeClass('icon-rss').addClass('icon-down');
......@@ -177,10 +179,10 @@ PTL.feed = {
});
$feedHeader.append($feedToggle,
$feedHandle,
$titleDiv.append($titleLink),
$newItemsBadge,
$feedControls.append($prefsDiv, $reloadDiv));
$feedHandle,
$titleDiv.append($titleLink),
$newItemsBadge,
$feedControls.append($prefsDiv, $reloadDiv));
$feed.append($feedHeader, $feedBody);
......@@ -193,20 +195,20 @@ PTL.feed = {
}
},
lastItems:function(feedItems, $dataStore) {
lastItems: function(feedItems, $dataStore) {
return new Promise((resolve, reject) => {
// console.log('feedItems: %s (%s)', JSON.stringify(feedItems));
const $feedBodyUl = $('<ul>').attr('class', 'feedBody'),
feedUrl = $dataStore.data('url'),
nbItems = $dataStore.data('nbitems'),
feedType = $dataStore.data('type');
feedUrl = $dataStore.data('url'),
nbItems = $dataStore.data('nbitems'),
feedType = $dataStore.data('type');
const l = PTL.util.getLocation(feedUrl),
p = l.protocol ? l.protocol + '//' : '//',
feedHost = p + l.hostname;
p = l.protocol ? l.protocol + '//' : '//',
feedHost = p + l.hostname;
var newItems = 0;
......@@ -218,7 +220,7 @@ PTL.feed = {
if (nbItems > 0 && newItems == nbItems) break;
const $description = $.parseHTML(item.description),
imgTypes = ['image', 'image/jpg', 'image/jpeg', 'image/gif', 'image/png'];
imgTypes = ['image', 'image/jpg', 'image/jpeg', 'image/gif', 'image/png'];
let summary, imageUrl, audioUrl, audioType, videoUrl, videoType;
......@@ -237,12 +239,12 @@ PTL.feed = {
}
const $imageLink = $('<a>').attr('target', '_blank').attr('class', 'imageLink'),
$itemLink = $('<a>').attr('target', '_blank').attr('class', 'itemLink'),
$commentsLink = $('<a>').attr('target', '_blank').attr('class', 'commentsLink'),
$commentsIcon = $('<i>'),
$summary = $('<null>').append(PTL.util.sanitizeInput(summary)).text(),
$itemDiv = $('<div>').attr('class', 'itemDiv'),
$feedItem = $('<li>').attr('class', 'feedItem');
$itemLink = $('<a>').attr('target', '_blank').attr('class', 'itemLink'),
$commentsLink = $('<a>').attr('target', '_blank').attr('class', 'commentsLink'),
$commentsIcon = $('<i>'),
$summary = $('<null>').append(PTL.util.sanitizeInput(summary)).text(),
$itemDiv = $('<div>').attr('class', 'itemDiv'),
$feedItem = $('<li>').attr('class', 'feedItem');
let $image;
......@@ -316,7 +318,7 @@ PTL.feed = {
if (!videoUrl && imageUrl && typeof imageUrl !== 'undefined' && !imageUrl.includes('pixel')) {
$imageLink
.attr('href', imageUrl.replace('http://','https://'))
.attr('href', imageUrl.replace('http://', 'https://'))
.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>');
......@@ -327,7 +329,7 @@ PTL.feed = {
$image = $('<img>')
.attr('src', '/static/images/loading.gif')
.attr('data-srcset', imageUrl.replace('http://','https://'))
.attr('data-srcset', imageUrl.replace('http://', 'https://'))
.attr('srcset', '/static/images/loading.gif')
.attr('title', $summary.trim())
.attr('alt', item['mastodon:scope'] ? $summary.trim() : item.title)
......@@ -366,16 +368,16 @@ PTL.feed = {
});
},
appendAudioPlayer:function($itemDiv, audioUrl, audioType) {
appendAudioPlayer: function($itemDiv, audioUrl, audioType) {
const $audioLink = $('<a>').attr('target', '_blank').attr('class', 'audioLink'),
$audioIcon = $('<i>'),
audioPlayer = document.createElement('audio');
$audioIcon = $('<i>'),
audioPlayer = document.createElement('audio');
audioPlayer.controls = 'controls';
audioPlayer.src = audioUrl;
audioPlayer.type = audioType;
audioPlayer.preload = PTL.prefs.readConfig('mediaPreload');
audioPlayer.src = audioUrl;
audioPlayer.type = audioType;
audioPlayer.preload = PTL.prefs.readConfig('mediaPreload');
$itemDiv.append(audioPlayer);
......@@ -387,16 +389,16 @@ PTL.feed = {
.appendTo($audioLink);
},
appendVideoPlayer:function($itemDiv, videoUrl, videoType) {
appendVideoPlayer: function($itemDiv, videoUrl, videoType) {
const videoPlayer = document.createElement('video'),
$videoIcon = $('<i>'),
$videoLink = $('<a>').attr('target', '_blank').attr('class', 'videoLink');
const videoPlayer = document.createElement('video'),
$videoIcon = $('<i>'),
$videoLink = $('<a>').attr('target', '_blank').attr('class', 'videoLink');
videoPlayer.controls = 'controls';
videoPlayer.src = videoUrl;
videoPlayer.type = videoType;
videoPlayer.preload = PTL.prefs.readConfig('mediaPreload');
videoPlayer.src = videoUrl;
videoPlayer.type = videoType;
videoPlayer.preload = PTL.prefs.readConfig('mediaPreload');
$itemDiv.append(videoPlayer);
......@@ -410,8 +412,8 @@ PTL.feed = {
return $itemDiv;
},
errorFeed:function(error, feedUrl) {
errorFeed: function(error, feedUrl) {
const status = error.status;
const message = error.message;
const type = error.type;
......@@ -466,9 +468,9 @@ PTL.feed = {
.append($errorItem);
return $feedBodyUl;
},
fetchIcon:function(feedHost) {
fetchIcon: function(feedHost) {
return new Promise((resolve, reject) => {
......@@ -487,7 +489,7 @@ PTL.feed = {
});
},
fetchFeed:function(feedUrl, lastItem, nbItems) {
fetchFeed: function(feedUrl, lastItem, nbItems) {
return new Promise((resolve, reject) => {
$.get("/feed", {
......@@ -501,28 +503,28 @@ PTL.feed = {
reject(jqXHR, textStatus, errorThrown);
});
});
},
populate:async function($button, progress, newLimit) {
populate: async function($button, progress, newLimit) {
const $dataStore = $button.parent().parent(),
$refreshButton = $dataStore.find('i.feedRefresh.icon-refresh').addClass('spin'),
$feedHeader = $dataStore.parent(),
$feedLink = $feedHeader.children('div.feedTitle').children('a'),
$badge = $feedHeader.children('.newItemsBadge'),
$feedBody = $dataStore.parent().next('div.feedBody'),
$feedBodyUl = $feedBody.find('ul.feedBody'),
feedUrl = $dataStore.data('url'),
feedIconHash = $dataStore.data('iconhash'),
$feedToggle = $feedHeader.children('.feedToggle'),
$feedIcon = $feedToggle.children('.feedIcon').addClass('fold'),
$favIcon = $feedToggle.children('.favicon');
$refreshButton = $dataStore.find('i.feedRefresh.icon-refresh').addClass('spin'),
$feedHeader = $dataStore.parent(),
$feedLink = $feedHeader.children('div.feedTitle').children('a'),
$badge = $feedHeader.children('.newItemsBadge'),
$feedBody = $dataStore.parent().next('div.feedBody'),
$feedBodyUl = $feedBody.find('ul.feedBody'),
feedUrl = $dataStore.data('url'),
feedIconHash = $dataStore.data('iconhash'),
$feedToggle = $feedHeader.children('.feedToggle'),
$feedIcon = $feedToggle.children('.feedIcon').addClass('fold'),
$favIcon = $feedToggle.children('.favicon');
const l = PTL.util.getLocation(feedUrl),
feedProtocol = l.protocol ? l.protocol + '//' : '//',
feedHost = feedProtocol + l.hostname,
dateObj = new Date(),
timeStamp = dateObj.getUTCHours() + ":" + dateObj.getUTCMinutes() + ":" + dateObj.getUTCSeconds();
feedProtocol = l.protocol ? l.protocol + '//' : '//',
feedHost = feedProtocol + l.hostname,
dateObj = new Date(),
timeStamp = dateObj.getUTCHours() + ":" + dateObj.getUTCMinutes() + ":" + dateObj.getUTCSeconds();
var feedLastItem = $dataStore.data('lastitem');
......@@ -537,8 +539,21 @@ PTL.feed = {
.children('div.feedBody')
.addClass('folded');
}
// console.log('lastItem: %s', feedLastItem, feedUrl);
if (feedIconHash) {
$favIcon.attr('src', '/favicons/' + feedIconHash + '.favicon');
} else {
await PTL.feed.fetchIcon(feedHost).then((iconhash) => {
if (iconhash) {
$favIcon.attr('src', '/favicons/' + iconhash + '.favicon');
$dataStore.data('iconhash', iconhash);
PTL.tab.saveTabs();
}
}).catch((error) => {
console.error('Fav: %s (%s)', error, feedUrl);
$favIcon.addClass('icon-rss');
});
}
if ($dataStore.data('status') == 'on') {
......@@ -580,7 +595,7 @@ PTL.feed = {
}
}
} else {
$dataStore
......@@ -589,21 +604,6 @@ PTL.feed = {
.children('div.feedBody')
.addClass('folded');
}
if (feedIconHash) {
$favIcon.attr('src', '/favicons/' + feedIconHash + '.favicon');
} else {
await PTL.feed.fetchIcon(feedHost).then((iconhash) => {
if (iconhash) {
$favIcon.attr('src', '/favicons/' + iconhash + '.favicon');
$dataStore.data('iconhash', iconhash);
PTL.tab.saveTabs();
}
}).catch((error) => {
console.error('Fav: %s (%s)', error, feedUrl);
$favIcon.addClass('icon-rss');
});
}
if (progress) progress.increment();
......
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