From: VirtualTam Date: Tue, 21 Mar 2017 20:57:17 +0000 (+0100) Subject: Merge pull request #826 from virtualtam/readme/badges X-Git-Tag: v0.9.0~29 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=36eb71fb48aa3e752a1e32774b8eead18780bf29;hp=643b631281ba619b7cc7b22141aafcb17712171f;p=github%2Fshaarli%2FShaarli.git Merge pull request #826 from virtualtam/readme/badges README: use explicit version badges --- diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 544aba7c..b133dee8 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php @@ -75,7 +75,8 @@ class PageBuilder } $this->tpl->assign('shaarlititle', $this->conf->get('general.title', 'Shaarli')); $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false)); - $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false)); + $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', true)); + $this->tpl->assign('feed_type', $this->conf->get('feed.show_atom', true) !== false ? 'atom' : 'rss'); $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); $this->tpl->assign('token', getToken($this->conf)); // To be removed with a proper theme configuration. diff --git a/application/Updater.php b/application/Updater.php index fd7e2073..efbfc832 100644 --- a/application/Updater.php +++ b/application/Updater.php @@ -378,6 +378,22 @@ class Updater $this->conf->set('plugins.PIWIK_URL', 'http://'. $this->conf->get('plugins.PIWIK_URL')); $this->conf->write($this->isLoggedIn); + + return true; + } + + /** + * Use ATOM feed as default. + */ + public function updateMethodAtomDefault() + { + if (!$this->conf->exists('feed.show_atom') || $this->conf->get('feed.show_atom') === true) { + return true; + } + + $this->conf->set('feed.show_atom', true); + $this->conf->write($this->isLoggedIn); + return true; } } diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php index 30908d90..9ef2ef56 100644 --- a/application/config/ConfigJson.php +++ b/application/config/ConfigJson.php @@ -21,8 +21,14 @@ class ConfigJson implements ConfigIO $data = str_replace(self::getPhpSuffix(), '', $data); $data = json_decode($data, true); if ($data === null) { - $error = json_last_error(); - throw new \Exception('An error occurred while parsing JSON file: error code #'. $error); + $errorCode = json_last_error(); + $error = 'An error occurred while parsing JSON configuration file ('. $filepath .'): error code #'; + $error .= $errorCode. '
➜ ' . json_last_error_msg() .''; + if ($errorCode === JSON_ERROR_SYNTAX) { + $error .= '
Please check your JSON syntax (without PHP comment tags) using a JSON lint tool such as '; + $error .= 'jsonlint.com.'; + } + throw new \Exception($error); } return $data; } diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index f2097410..7bfbfc72 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php @@ -81,7 +81,11 @@ class ConfigManager */ protected function load() { - $this->loadedConfig = $this->configIO->read($this->getConfigFileExt()); + try { + $this->loadedConfig = $this->configIO->read($this->getConfigFileExt()); + } catch (\Exception $e) { + die($e->getMessage()); + } $this->setDefaultValues(); } @@ -317,7 +321,7 @@ class ConfigManager $this->setEmpty('updates.check_updates_interval', 86400); $this->setEmpty('feed.rss_permalinks', true); - $this->setEmpty('feed.show_atom', false); + $this->setEmpty('feed.show_atom', true); $this->setEmpty('privacy.default_private_links', false); $this->setEmpty('privacy.hide_public_links', false); diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php index b522d616..11b6444a 100644 --- a/tests/Updater/UpdaterTest.php +++ b/tests/Updater/UpdaterTest.php @@ -615,4 +615,49 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; $this->assertTrue($updater->updateMethodPiwikUrl()); $this->assertEquals($url, $this->conf->get('plugins.PIWIK_URL')); } + + /** + * Test updateMethodAtomDefault with show_atom set to false + * => update to true. + */ + public function testUpdateMethodAtomDefault() + { + $sandboxConf = 'sandbox/config'; + copy(self::$configFile . '.json.php', $sandboxConf . '.json.php'); + $this->conf = new ConfigManager($sandboxConf); + $this->conf->set('feed.show_atom', false); + $updater = new Updater([], [], $this->conf, true); + $this->assertTrue($updater->updateMethodAtomDefault()); + $this->assertTrue($this->conf->get('feed.show_atom')); + // reload from file + $this->conf = new ConfigManager($sandboxConf); + $this->assertTrue($this->conf->get('feed.show_atom')); + } + /** + * Test updateMethodAtomDefault with show_atom not set. + * => nothing to do + */ + public function testUpdateMethodAtomDefaultNoExist() + { + $sandboxConf = 'sandbox/config'; + copy(self::$configFile . '.json.php', $sandboxConf . '.json.php'); + $this->conf = new ConfigManager($sandboxConf); + $updater = new Updater([], [], $this->conf, true); + $this->assertTrue($updater->updateMethodAtomDefault()); + $this->assertTrue($this->conf->get('feed.show_atom')); + } + /** + * Test updateMethodAtomDefault with show_atom set to true. + * => nothing to do + */ + public function testUpdateMethodAtomDefaultAlreadyTrue() + { + $sandboxConf = 'sandbox/config'; + copy(self::$configFile . '.json.php', $sandboxConf . '.json.php'); + $this->conf = new ConfigManager($sandboxConf); + $this->conf->set('feed.show_atom', true); + $updater = new Updater([], [], $this->conf, true); + $this->assertTrue($updater->updateMethodAtomDefault()); + $this->assertTrue($this->conf->get('feed.show_atom')); + } } diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php index 3527f83d..d237bc80 100644 --- a/tests/config/ConfigJsonTest.php +++ b/tests/config/ConfigJsonTest.php @@ -40,7 +40,7 @@ class ConfigJsonTest extends \PHPUnit_Framework_TestCase * Read a non existent config file -> empty array. * * @expectedException \Exception - * @expectedExceptionMessage An error occurred while parsing JSON file: error code #4 + * @expectedExceptionMessageRegExp /An error occurred while parsing JSON configuration file \([\w\/\.]+\): error code #4/ */ public function testReadInvalidJson() { diff --git a/tpl/default/page.header.html b/tpl/default/page.header.html index 03ca6843..9388ef79 100644 --- a/tpl/default/page.header.html +++ b/tpl/default/page.header.html @@ -48,7 +48,7 @@ {/loop}
  • - {'RSS Feed'|t} + {'RSS Feed'|t}
  • {if="isLoggedIn()"}
  • @@ -70,7 +70,7 @@
  • - +