Commit 6b9185ce authored by Malcolm Blaney's avatar Malcolm Blaney

Recent change to Reader module to show "via" links when item domain

was different to author domain didn't work because url matching was
too specific. Check is now based on domain only. Bug in setChannel
js meant channel wasn't set if the feed url was displaying a
shortened version.
parent 35ae171e
Pipeline #40233013 passed with stage
in 1 minute and 24 seconds
...@@ -1631,12 +1631,31 @@ class Reader extends Base { ...@@ -1631,12 +1631,31 @@ class Reader extends Base {
} }
$group_header = ''; $group_header = '';
$group_link = $item['html_url']; $group_link = $item['html_url'];
// If the group link doesn't match the author url add it to the author, as // If the group link domain doesn't match the author url domain add it to
// it's possible the group header is not shown. // the author, as it's possible the group header is not shown. Special case
if (strpos($group_link, $author_url) !== 0 || // twitter and facebook atom feeds don't need to show via.
strpos($author_url, $group_link) !== 0) { if ($group_link !== 'https://twitter-atom.appspot.com' &&
$group_link !== 'https://facebook-atom.appspot.com') {
$group_link_domain = $group_link;
if (preg_match('/\/\/([^\/]+)/', $group_link_domain, $match)) {
$group_link_domain = $match[1];
// Drop subdomains too.
if (preg_match('/([^\.]+\.[^\.]+)$/', $group_link_domain, $match)) {
$group_link_domain = $match[1];
}
}
$author_url_domain = $author_url;
if (preg_match('/\/\/([^\/]+)/', $author_url_domain, $match)) {
$author_url_domain = $match[1];
if (preg_match('/([^\.]+\.[^\.]+)$/', $author_url_domain, $match)) {
$author_url_domain = $match[1];
}
}
if ($group_link_domain !== $author_url_domain) {
$author .= ' <span class="reader-via-url">via ' . $author .= ' <span class="reader-via-url">via ' .
'<a href="' . $group_link . '">' . $item['feed_title'] . '</a></span>'; '<a href="' . $group_link . '">' .
$item['feed_title'] . '</a></span>';
}
} }
// Allow feed items to be grouped by their url by setting a matching // Allow feed items to be grouped by their url by setting a matching
...@@ -2213,7 +2232,7 @@ class Reader extends Base { ...@@ -2213,7 +2232,7 @@ class Reader extends Base {
private function SaveCloud($us_cloud, $us_xml_url) { private function SaveCloud($us_cloud, $us_xml_url) {
// If xml_url is on the same domain as the currently configured ServerName, // If xml_url is on the same domain as the currently configured ServerName,
// do nothing as UpdateFeed does notifications in this case. // do nothing as UpdateFeed does notifications in this case.
if (preg_match('/\/\/([^\/]*)/', $us_xml_url, $match)) { if (preg_match('/\/\/([^\/]+)/', $us_xml_url, $match)) {
$domain = $match[1]; $domain = $match[1];
if ($domain === $this->user->config->ServerName()) return; if ($domain === $this->user->config->ServerName()) return;
} }
...@@ -2274,7 +2293,7 @@ class Reader extends Base { ...@@ -2274,7 +2293,7 @@ class Reader extends Base {
private function SaveHub($us_hub, $us_self, $us_xml_url) { private function SaveHub($us_hub, $us_self, $us_xml_url) {
// If xml_url is on the same domain as the currently configured ServerName, // If xml_url is on the same domain as the currently configured ServerName,
// do nothing as UpdateFeed does notifications in this case. // do nothing as UpdateFeed does notifications in this case.
if (preg_match('/\/\/([^\/]*)/', $us_xml_url, $match)) { if (preg_match('/\/\/([^\/]+)/', $us_xml_url, $match)) {
$domain = $match[1]; $domain = $match[1];
if ($domain === $this->user->config->ServerName()) return; if ($domain === $this->user->config->ServerName()) return;
} }
......
...@@ -36,8 +36,8 @@ function setChannel(option,add){var feed=$('#reader-channel-url').html();$.post( ...@@ -36,8 +36,8 @@ function setChannel(option,add){var feed=$('#reader-channel-url').html();$.post(
var channel=JSON.parse(response);var text=channel.name==='not set'?'The channel for this feed is no longer set.':'The channel for this feed has been updated to <b>'+ var channel=JSON.parse(response);var text=channel.name==='not set'?'The channel for this feed is no longer set.':'The channel for this feed has been updated to <b>'+
channel.name+'</b>';$('#reader-channel-status').html(text);$('.reader-feed-list .feed-url').each(function(){if($(this).html()===feed){let channelButton=$(this).parents('.feed-item').find('.reader-channel-button');channelButton.button('option','label',channel.name);}});if(add){$('#reader-channel-select').append('<option selected="selected">'+ channel.name+'</b>';$('#reader-channel-status').html(text);$('.reader-feed-list .feed-url').each(function(){if($(this).html()===feed){let channelButton=$(this).parents('.feed-item').find('.reader-channel-button');channelButton.button('option','label',channel.name);}});if(add){$('#reader-channel-select').append('<option selected="selected">'+
channel.name+'</option>');$('#reader-channel-select').selectmenu('refresh');$('#reader-channel-select').parent().show();}});} channel.name+'</option>');$('#reader-channel-select').selectmenu('refresh');$('#reader-channel-select').parent().show();}});}
var title=$(this).parent().find('.feed-title');var link=$(this).parent().find('.feed-url');var channel=$(this).html();var text='';if(title&&link){text='<span id="reader-channel-title">'+title.html()+'</span> [<a href="'+link.html()+'" '+'id="reader-channel-url">'+link.html()+'</a>]';} var title=$(this).parent().find('.feed-title');var link=$(this).parent().find('.feed-url');var channel=$(this).html();var text='';if(title&&link){text='<span id="reader-channel-title">'+title.html()+'</span> [<a href="'+link.attr('href')+'" '+'id="reader-channel-url">'+link.html()+'</a>]';}
else if(link){text+='<a href="'+link.html()+'" id="reader-channel-url">'+ else if(link){text+='<a href="'+link.attr('href')+'" id="reader-channel-url">'+
link.html()+'</a>';} link.html()+'</a>';}
$('#reader-channel-select').selectmenu({change:function(event,ui){setChannel(ui.item.value,false);}});$('#reader-channel-submit').button().click(addChannel);if(channel==='not set'){text+='<p id="reader-channel-status">'+'This feed does not have a channel set. ';if($('#reader-channel-select').children().length===0){text+='You can add one below to set the channel for this feed.</p>';} $('#reader-channel-select').selectmenu({change:function(event,ui){setChannel(ui.item.value,false);}});$('#reader-channel-submit').button().click(addChannel);if(channel==='not set'){text+='<p id="reader-channel-status">'+'This feed does not have a channel set. ';if($('#reader-channel-select').children().length===0){text+='You can add one below to set the channel for this feed.</p>';}
else{let firstOption=$('#reader-channel-select').children().first().html();if(firstOption!=='not set'){$('#reader-channel-select').prepend('<option selected="selected">'+'not set</option>');} else{let firstOption=$('#reader-channel-select').children().first().html();if(firstOption!=='not set'){$('#reader-channel-select').prepend('<option selected="selected">'+'not set</option>');}
...@@ -116,6 +116,6 @@ if($('.reader-discovered').dialog('isOpen')){$('.reader-discovered').dialog('clo ...@@ -116,6 +116,6 @@ if($('.reader-discovered').dialog('isOpen')){$('.reader-discovered').dialog('clo
if(reader.content){$('.reader-content').html(reader.content);} if(reader.content){$('.reader-content').html(reader.content);}
if(reader.more){$('.reader-more').show();} if(reader.more){$('.reader-more').show();}
else{$('.reader-more').hide();} else{$('.reader-more').hide();}
$('.reader-settings').html(reader.settings);feedSettings();newFeedEvents();if(dobrado.localStorage){localStorage.reader=reader.content;localStorage.readerUpdate=new Date().getTime();localStorage.readerPage=location.href;}});};dobrado.reader.channelSelect=function(channel){$.post('php/request.php',{id:'#'+$('.reader').attr('id'),request:'reader',action:'changeChannel',channel:channel,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'reader change channel')){return;} $('.reader-settings').html(reader.settings);feedSettings();newFeedEvents();if(dobrado.localStorage){localStorage.reader=reader.content;localStorage.readerUpdate=new Date().getTime();localStorage.readerPage=location.href;}});};dobrado.reader.channelSelect=function(channel){$.post('/php/request.php',{id:'#'+$('.reader').attr('id'),request:'reader',action:'changeChannel',channel:channel,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'reader change channel')){return;}
var change=JSON.parse(response);if(change.channel){reset(false);} var change=JSON.parse(response);if(change.channel){reset(false);}
else{dobrado.changePage(channel);}});};dobrado.reader.update=function(action){request('newer',action);};dobrado.reader.scrollback=function(url,cancelled){if($('.reader-item a[href="'+url+'"]').length!==0){$('.reader-item a[href="'+url+'"]').get(0).scrollIntoView();if(!cancelled){let item=$('.reader-item a[href="'+url+'"]').parents('.reader-item');item.find('indie-action').data('checked',false);dobrado.indieConfig();}}};}()); else{dobrado.changePage(channel);}});};dobrado.reader.update=function(action){request('newer',action);};dobrado.reader.scrollback=function(url,cancelled){if($('.reader-item a[href="'+url+'"]').length!==0){$('.reader-item a[href="'+url+'"]').get(0).scrollIntoView();if(!cancelled){let item=$('.reader-item a[href="'+url+'"]').parents('.reader-item');item.find('indie-action').data('checked',false);dobrado.indieConfig();}}};}());
\ No newline at end of file
...@@ -164,11 +164,11 @@ if (!this.dobrado.reader) { ...@@ -164,11 +164,11 @@ if (!this.dobrado.reader) {
var text = ''; var text = '';
if (title && link) { if (title && link) {
text = '<span id="reader-channel-title">' + title.html() + text = '<span id="reader-channel-title">' + title.html() +
'</span> [<a href="' + link.html() + '" ' + '</span> [<a href="' + link.attr('href') + '" ' +
'id="reader-channel-url">' + link.html() + '</a>]'; 'id="reader-channel-url">' + link.html() + '</a>]';
} }
else if (link) { else if (link) {
text += '<a href="' + link.html() + '" id="reader-channel-url">' + text += '<a href="' + link.attr('href') + '" id="reader-channel-url">' +
link.html() + '</a>'; link.html() + '</a>';
} }
$('#reader-channel-select').selectmenu({ change: function(event, ui) { $('#reader-channel-select').selectmenu({ change: function(event, ui) {
...@@ -670,7 +670,7 @@ if (!this.dobrado.reader) { ...@@ -670,7 +670,7 @@ if (!this.dobrado.reader) {
}; };
dobrado.reader.channelSelect = function(channel) { dobrado.reader.channelSelect = function(channel) {
$.post('php/request.php', $.post('/php/request.php',
{ id: '#' + $('.reader').attr('id'), request: 'reader', { id: '#' + $('.reader').attr('id'), request: 'reader',
action: 'changeChannel', channel: channel, action: 'changeChannel', channel: channel,
url: location.href, token: dobrado.token }, url: location.href, token: dobrado.token },
......
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