From ed5b38ddd249c0e50eec7e06e74c9d1c2e864dab Mon Sep 17 00:00:00 2001 From: Florian Eula Date: Fri, 21 Nov 2014 21:31:21 +0100 Subject: [PATCH] Feature: enable/disable permalinks for RSS The option to see the shortlinks or permalinks has been added to the configuration panel. It is a simple checkbox This option is disabled by default (meaning that shortlinks are the default) Updated writeConfig() to save this option Also fixed a slight typo in config.html. Removed useless CSS & fixed a comment Enabled permalinks for the ATOM feed and fixed the isPermaLink attribute for the tag Reverted to default behavior and clarified its meaning EnableRssPermalinks is an oddly behaving option: when enabled, it shows a permalink in the description and a full link in the element title, and swaps it around when disabled. This clarifies the option for end-users Also, moved enable_rss_permalinks to $GLOBALS['config'] because it is a config option. fix indent --- inc/shaarli.css | 4 ++++ index.php | 12 ++++++++---- tpl/configure.html | 12 +++++++++--- tpl/tools.html | 12 ++++++------ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/inc/shaarli.css b/inc/shaarli.css index 325515e..f6e580b 100644 --- a/inc/shaarli.css +++ b/inc/shaarli.css @@ -1039,6 +1039,10 @@ div.dailyNoEntry { } } +#toolsdiv a.button-description { + clear: none; +} + /* Highlight search results */ .highlight { background-color: #FFFF33; diff --git a/index.php b/index.php index d48e388..818fa68 100644 --- a/index.php +++ b/index.php @@ -11,7 +11,7 @@ date_default_timezone_set('UTC'); // ----------------------------------------------------------------------------------------------- -// Hardcoded parameter (These parameters can be overwritten by creating the file /config/options.php) +// Hardcoded parameter (These parameters can be overwritten by creating the file /data/options.php) $GLOBALS['config']['DATADIR'] = 'data'; // Data subdirectory $GLOBALS['config']['CONFIG_FILE'] = $GLOBALS['config']['DATADIR'].'/config.php'; // Configuration file (user login/password) $GLOBALS['config']['DATASTORE'] = $GLOBALS['config']['DATADIR'].'/datastore.php'; // Data storage file. @@ -33,6 +33,7 @@ $GLOBALS['config']['UPDATECHECK_FILENAME'] = $GLOBALS['config']['DATADIR'].'/las $GLOBALS['config']['UPDATECHECK_INTERVAL'] = 86400 ; // Updates check frequency for Shaarli. 86400 seconds=24 hours // Note: You must have publisher.php in the same directory as Shaarli index.php $GLOBALS['config']['ARCHIVE_ORG'] = false; // For each link, add a link to an archived version on archive.org +$GLOBALS['config']['ENABLE_RSS_PERMALINKS'] = true; // Enable RSS permalinks by default. This corresponds to the default behavior of shaarli before this was added as an option. // ----------------------------------------------------------------------------------------------- // You should not touch below (or at your own risks!) // Optional config file. @@ -894,7 +895,8 @@ function showRSS() // $usepermalink : If true, use permalink instead of final link. // User just has to add 'permalink' in URL parameters. e.g. http://mysite.com/shaarli/?do=rss&permalinks - $usepermalinks = isset($_GET['permalinks']); + // Also enabled through a config option + $usepermalinks = isset($_GET['permalinks']) || !$GLOBALS['config']['ENABLE_RSS_PERMALINKS']; // Cache system $query = $_SERVER["QUERY_STRING"]; @@ -936,7 +938,7 @@ function showRSS() $absurl = htmlspecialchars($link['url']); if (startsWith($absurl,'?')) $absurl=$pageaddr.$absurl; // make permalink URL absolute if ($usepermalinks===true) - echo ''.htmlspecialchars($link['title']).''.$guid.''.$guid.''; + echo ''.htmlspecialchars($link['title']).''.$guid.''.$guid.''; else echo ''.htmlspecialchars($link['title']).''.$guid.''.$absurl.''; if (!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()) echo ''.htmlspecialchars($rfc822date)."\n"; @@ -968,7 +970,7 @@ function showATOM() // $usepermalink : If true, use permalink instead of final link. // User just has to add 'permalink' in URL parameters. e.g. http://mysite.com/shaarli/?do=atom&permalinks - $usepermalinks = isset($_GET['permalinks']); + $usepermalinks = isset($_GET['permalinks']) || !$GLOBALS['config']['ENABLE_RSS_PERMALINKS']; // Cache system $query = $_SERVER["QUERY_STRING"]; @@ -1423,6 +1425,7 @@ function renderPage() $GLOBALS['disablesessionprotection']=!empty($_POST['disablesessionprotection']); $GLOBALS['disablejquery']=!empty($_POST['disablejquery']); $GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']); + $GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']); writeConfig(); echo ''; exit; @@ -2290,6 +2293,7 @@ function writeConfig() $config .= '$GLOBALS[\'disablesessionprotection\']='.var_export($GLOBALS['disablesessionprotection'],true).'; '; $config .= '$GLOBALS[\'disablejquery\']='.var_export($GLOBALS['disablejquery'],true).'; '; $config .= '$GLOBALS[\'privateLinkByDefault\']='.var_export($GLOBALS['privateLinkByDefault'],true).'; '; + $config .= '$GLOBALS[\'config\'][\'ENABLE_RSS_PERMALINKS\']='.var_export($GLOBALS['config']['ENABLE_RSS_PERMALINKS'], true).'; '; $config .= ' ?>'; if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0) { diff --git a/tpl/configure.html b/tpl/configure.html index 89e48bd..c096018 100644 --- a/tpl/configure.html +++ b/tpl/configure.html @@ -21,8 +21,14 @@ Features: - New link: - + New link: + + + + Enable RSS Permalinks + + + @@ -30,4 +36,4 @@ {include="page.footer"} - \ No newline at end of file + diff --git a/tpl/tools.html b/tpl/tools.html index c2520fd..bf0539b 100644 --- a/tpl/tools.html +++ b/tpl/tools.html @@ -6,12 +6,12 @@ {include="page.header"} {include="page.footer"}