Commit 1d219089 authored by Malcolm Blaney's avatar Malcolm Blaney

Setting channels for authors from Facebook and Twitter feeds needs

to be a special case due to how their feed urls are displayed.
parent f8cd822e
Pipeline #43215775 passed with stage
in 1 minute and 13 seconds
......@@ -567,7 +567,9 @@ class Reader extends Base {
'"","#tooltip-channel-add","margin","5px"',
'"","#tooltip-channel-submit","margin-right","10px"',
'"","#tooltip-channel-submit","float","right"',
'"","li.reader-unread-true","font-weight","bold"'];
'"","li.reader-unread-true","font-weight","bold"',
'"","#page-select-menu .ui-state-active","font-weight",' .
'"inherit"'];
$this->AddSiteStyle($site_style);
$this->AddSettingTypes(['"reader","defaultChannel","","text","Enter the ' .
'name of the channel you would like to see ' .
......@@ -654,7 +656,7 @@ class Reader extends Base {
'"","label[for=reader-channel-order]","width","7em"',
'"","#reader-channel-order","width","50px"',
'"","label[for=reader-channel-update]","width","7em"',
'"","#reader-channel-display-submit","margin-left","8em"',
'"","#reader-channel-display-submit","margin-left","6.5em"',
'"","a.tooltip-photo","float","left"',
'"","a.tooltip-photo","margin","5px"',
'"","a.tooltip-photo img","max-width","80px"',
......@@ -1987,9 +1989,8 @@ class Reader extends Base {
$group_header .= $group_image;
}
}
$group_header .= $config['hide-permalinks'] ? $item['feed_title'] :
'<a href="' . $group_link . '">' . $item['feed_title'] . '</a>';
$group_header .= '</h3>';
$group_header .= '<a class="reader-group-link" ' .
'href="' . $group_link . '">' . $item['feed_title'] . '</a></h3>';
}
$reader_actions = '';
if ($config['actions']) {
......@@ -2839,16 +2840,33 @@ class Reader extends Base {
}
$mysqli = connect_db();
$channel = $us_channel === 'not set' ? '' :
$mysqli->escape_string($us_channel);
$xml_url = $mysqli->escape_string($_POST['feed']);
$us_xml_url = $_POST['feed'];
$xml_url = $mysqli->escape_string($us_xml_url);
$author = isset($_POST['author']) ?
$mysqli->escape_string($_POST['author']) : '';
$channel = $us_channel === 'not set' ? '' :
$mysqli->escape_string($us_channel);
$owner = $this->SwitchOwner();
// If author is set check if the channel being set is the same as for the
// generic channel for this feed and remove the more specific entry.
$delete_author = false;
if ($author !== '') {
// Facebook and Twitter feeds are special cased when displaying urls so
// need to look up the full url here.
if ($us_xml_url === 'https://facebook-atom.appspot.com' ||
$us_xml_url === 'https://twitter-atom.appspot.com') {
$query = 'SELECT xml_url FROM reader_channels WHERE ' .
'user = "' . $owner . '" AND box_id = ' . $id .
' AND xml_url LIKE "' . $xml_url . '%"';
if ($mysqli_result = $mysqli->query($query)) {
if ($reader_channels = $mysqli_result->fetch_assoc()) {
$xml_url = $mysqli->escape_string($reader_channels['xml_url']);
}
}
else {
$this->Log('Reader->SetChannel 1: ' . $mysqli->error);
}
}
$query = 'SELECT channel FROM reader_channels WHERE ' .
'user = "' . $owner . '" AND box_id = ' . $id . ' AND ' .
'xml_url = "' . $xml_url . '" AND author = ""';
......@@ -2859,7 +2877,7 @@ class Reader extends Base {
$mysqli_result->close();
}
else {
$this->Log('Reader->SetChannel 1: ' . $mysqli->error);
$this->Log('Reader->SetChannel 2: ' . $mysqli->error);
}
}
$query = '';
......@@ -2874,7 +2892,7 @@ class Reader extends Base {
'ON DUPLICATE KEY UPDATE channel = "' . $channel . '"';
}
if (!$mysqli->query($query)) {
$this->Log('Reader->SetChannel 2: ' . $mysqli->error);
$this->Log('Reader->SetChannel 3: ' . $mysqli->error);
}
$max_order = 0;
$query = 'SELECT MAX(channel_order) AS channel_order FROM ' .
......@@ -2885,14 +2903,14 @@ class Reader extends Base {
}
}
else {
$this->Log('Reader->SetChannel 3: ' . $mysqli->error);
$this->Log('Reader->SetChannel 4: ' . $mysqli->error);
}
// Do nothing on duplicate key rather than checking if entry exists.
$query = 'INSERT INTO reader_channel_info VALUES ("' . $owner . '", ' .
$id . ', "' . $channel . '", ' . $max_order . ', "true", 0) ' .
'ON DUPLICATE KEY UPDATE channel_name = "' . $channel . '"';
if (!$mysqli->query($query)) {
$this->Log('Reader->SetChannel 4: ' . $mysqli->error);
$this->Log('Reader->SetChannel 5: ' . $mysqli->error);
}
$mysqli->close();
return ['name' => $us_channel];
......
......@@ -77,13 +77,12 @@ var formData=new FormData();if(!formData){dobrado.log('Your browser doesn\'t sup
dobrado.log('Importing file...','info');var file=$('#reader-file-import').get(0).files[0];if(file){formData.append('file',file);formData.append('request','reader');formData.append('action','import');formData.append('url',location.href);formData.append('token',dobrado.token);$.ajax({url:'/php/request.php',data:formData,contentType:false,processData:false,type:'POST',success:function(response){if(dobrado.checkResponseError(response,'reader importFile')){return;}
importList=JSON.parse(response);importCount=0;if(importList.length!==0){var text='<p>Found <b>'+importList.length+'</b> feeds in imported file:</p>';$('.reader-discovered').html(text).dialog('open');addImportedFeed();}}});}
return false;}
function newFeedEvents(){(function tooltipEvents(){var channelOptions=$('#reader-channel-select').html();function tooltipContent(){var photo=$(this).siblings('.author-photo-url');var name=$(this).html();var link=$(this).attr('href');var feed=$(this).parents('.reader-group').find('.group-title a');var content='<a class="tooltip-photo" href="'+photo.attr('href')+'">'+
photo.html()+'</a>'+'<a class="tooltip-name" href="'+link+'">'+name+'</a><br>'+'<a class="tooltip-url" href="'+link+'">'+link+'</a>';if(channelOptions!==''){content+='<div class="tooltip-channel-info">';if(link===feed.attr('href')){content+='Channel: <a class="tooltip-feed" href="'+
feed.attr('href')+'"></a>';}
else{content+='Channel for posts from '+name+' in <a class="tooltip-feed" href="'+
feed.attr('href')+'">'+feed.html()+'</a>: ';}
content+='<select id="tooltip-channel-select">'+
channelOptions+'<option>Add new channel</option></select></div>'+'<div class="hidden">'+'<label for="tooltip-channel-add">Add channel:</label>'+'<input id="tooltip-channel-add" type="text">'+'<button id="tooltip-channel-submit">submit</button>'+'</div>';}
function newFeedEvents(){(function tooltipEvents(){var channelOptions=$('#reader-channel-select').html();function tooltipContent(){var photo=$(this).siblings('.author-photo-url');var name=$(this).html();var link=$(this).attr('href');var feed=$(this).parents('.reader-group').find('a.reader-group-link');var feedUrl=feed.attr('href');var content='<a class="tooltip-photo" href="'+photo.attr('href')+'">'+
photo.html()+'</a>'+'<a class="tooltip-name" href="'+link+'">'+name+'</a><br>'+'<a class="tooltip-url" href="'+link+'">'+link+'</a>';if(channelOptions!==''){content+='<div class="tooltip-channel-info">';if(feedUrl===link||feedUrl==='https://twitter-atom.appspot.com'||feedUrl==='https://facebook-atom.appspot.com'){content+='Channel: <a class="tooltip-feed" href="'+
feedUrl+'"></a>';}
else{content+='Channel for posts from '+name+' in <a class="tooltip-feed" href="'+feedUrl+'">'+
feed.html()+'</a>: ';}
content+='<select id="tooltip-channel-select">'+channelOptions+'<option>Add new channel</option></select></div>'+'<div class="hidden">'+'<label for="tooltip-channel-add">Add channel:</label>'+'<input id="tooltip-channel-add" type="text">'+'<button id="tooltip-channel-submit">submit</button>'+'</div>';}
return content;}
function tooltipOpen(event,ui){function tooltipSelectChannel(event,ui){if(ui.item.value==='Add new channel'){$('#tooltip-channel-add').parent().show();}
else{tooltipSetChannel(ui.item.value,false);}}
......
......@@ -468,7 +468,8 @@ if (!this.dobrado.reader) {
var photo = $(this).siblings('.author-photo-url');
var name = $(this).html();
var link = $(this).attr('href');
var feed = $(this).parents('.reader-group').find('.group-title a');
var feed = $(this).parents('.reader-group').find('a.reader-group-link');
var feedUrl = feed.attr('href');
var content =
'<a class="tooltip-photo" href="' + photo.attr('href') + '">' +
photo.html() + '</a>' +
......@@ -477,17 +478,19 @@ if (!this.dobrado.reader) {
if (channelOptions !== '') {
content += '<div class="tooltip-channel-info">';
// If author matches feed don't need to show as much detail here.
if (link === feed.attr('href')) {
// (Also special case Facebook and Twitter feeds.)
if (feedUrl === link ||
feedUrl === 'https://twitter-atom.appspot.com' ||
feedUrl === 'https://facebook-atom.appspot.com') {
content += 'Channel: <a class="tooltip-feed" href="' +
feed.attr('href') + '"></a>';
feedUrl + '"></a>';
}
else {
content += 'Channel for posts from ' + name +
' in <a class="tooltip-feed" href="' +
feed.attr('href') + '">' + feed.html() + '</a>: ';
' in <a class="tooltip-feed" href="' + feedUrl + '">' +
feed.html() + '</a>: ';
}
content += '<select id="tooltip-channel-select">' +
channelOptions +
content += '<select id="tooltip-channel-select">' + channelOptions +
'<option>Add new channel</option></select></div>' +
'<div class="hidden">' +
'<label for="tooltip-channel-add">Add channel:</label>' +
......
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