diff --git a/index.php b/index.php index 448c23a..b7ed370 100644 --- a/index.php +++ b/index.php @@ -858,6 +858,10 @@ function showRSS() { header('Content-Type: application/rss+xml; charset=utf-8'); + // $usepermalink : If true, use permalink instead of final link. + // User just has to add 'permalink' in URL parameters. eg. http://mysite.com/shaarli/?do=rss&permalinks + $usepermalinks = isset($_GET['permalinks']); + // Cache system $query = $_SERVER["QUERY_STRING"]; $cache = new pageCache(pageUrl(),startsWith($query,'do=rss') && !isLoggedIn()); @@ -892,13 +896,22 @@ function showRSS() $rfc822date = linkdate2rfc822($link['linkdate']); $absurl = htmlspecialchars($link['url']); if (startsWith($absurl,'?')) $absurl=$pageaddr.$absurl; // make permalink URL absolute - echo ''.htmlspecialchars($link['title']).''.$guid.''.$absurl.''; + if ($usepermalinks===true) + echo ''.htmlspecialchars($link['title']).''.$guid.''.$guid.''; + else + echo ''.htmlspecialchars($link['title']).''.$guid.''.$absurl.''; if (!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()) echo ''.htmlspecialchars($rfc822date)."\n"; if ($link['tags']!='') // Adding tags to each RSS entry (as mentioned in RSS specification) { foreach(explode(' ',$link['tags']) as $tag) { echo ''.htmlspecialchars($tag).''."\n"; } } - echo ''."\n\n"; + + // Add permalink in description + $descriptionlink = '(Permalink)'; + // If user wants permalinks first, put the final link in description + if ($usepermalinks===true) $descriptionlink = '(Link)'; + if (strlen($link['description'])>0) $descriptionlink = '
'.$descriptionlink; + echo ''."\n
\n"; $i++; } echo ''; @@ -914,6 +927,10 @@ function showATOM() { header('Content-Type: application/atom+xml; charset=utf-8'); + // $usepermalink : If true, use permalink instead of final link. + // User just has to add 'permalink' in URL parameters. eg. http://mysite.com/shaarli/?do=atom&permalinks + $usepermalinks = isset($_GET['permalinks']); + // Cache system $query = $_SERVER["QUERY_STRING"]; $cache = new pageCache(pageUrl(),startsWith($query,'do=atom') && !isLoggedIn()); @@ -942,9 +959,20 @@ function showATOM() $latestDate = max($latestDate,$iso8601date); $absurl = htmlspecialchars($link['url']); if (startsWith($absurl,'?')) $absurl=$pageaddr.$absurl; // make permalink URL absolute - $entries.=''.htmlspecialchars($link['title']).''.$guid.''; + $entries.=''.htmlspecialchars($link['title']).''; + if ($usepermalinks===true) + $entries.=''.$guid.''; + else + $entries.=''.$guid.''; if (!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()) $entries.=''.htmlspecialchars($iso8601date).''; - $entries.=''.htmlspecialchars(nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description'])))))."\n"; + + // Add permalink in description + $descriptionlink = htmlspecialchars('(Permalink)'); + // If user wants permalinks first, put the final link in description + if ($usepermalinks===true) $descriptionlink = htmlspecialchars('(Link)'); + if (strlen($link['description'])>0) $descriptionlink = '<br>'.$descriptionlink; + + $entries.=''.htmlspecialchars(nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description']))))).$descriptionlink."\n"; if ($link['tags']!='') // Adding tags to each ATOM entry (as mentioned in ATOM specification) { foreach(explode(' ',$link['tags']) as $tag)