]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #816 from ArthurHoaro/project/master-version
authorArthurHoaro <arthur@hoa.ro>
Wed, 22 Mar 2017 17:50:33 +0000 (18:50 +0100)
committerGitHub <noreply@github.com>
Wed, 22 Mar 2017 17:50:33 +0000 (18:50 +0100)
Use 'dev' version on the master branch

CHANGELOG.md
README.md
application/PageBuilder.php
application/Updater.php
application/config/ConfigJson.php
application/config/ConfigManager.php
tests/Updater/UpdaterTest.php
tests/config/ConfigJsonTest.php
tpl/default/page.footer.html
tpl/default/page.header.html

index d9f2f4f3b781cf16fea74f7ad1292b10cacd996c..f0813b97eafa3714c42369b391143333c3d2266c 100644 (file)
@@ -25,6 +25,7 @@ Theming:
     - Introduce a new theme
     - Allow selecting themes/templates from the configuration page
     - New/Edit link form can be submitted using CTRL+Enter in the textarea
+    - Shaarli version is displayed in the footer when logged in 
 - Add plugin placeholders to Atom/RSS feed templates
 - Add OpenSearch to feed templates
 - Add `campaign_` to the URL cleanup pattern list
index db1b901f27a3ae7709fef55bfc420f306fb39b95..cfdefc66da5763b050d61487900f35002a267d4b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -6,13 +6,18 @@ _Do you want to share the links you discover?_
 _Shaarli is a minimalist delicious clone that you can install on your own server._
 _It is designed to be personal (single-user), fast and handy._
 
-[![](https://img.shields.io/travis/shaarli/Shaarli.svg?label=master)](https://travis-ci.org/shaarli/Shaarli)
+[![](https://img.shields.io/badge/stable-v0.7.1-blue.svg)](https://github.com/shaarli/Shaarli/releases/tag/v0.7.1)
 [![](https://img.shields.io/travis/shaarli/Shaarli/stable.svg?label=stable)](https://travis-ci.org/shaarli/Shaarli)
-[![](https://img.shields.io/github/release/shaarli/shaarli.svg)](https://github.com/shaarli/Shaarli/releases/latest/)
-[![Docker repository](https://img.shields.io/docker/pulls/shaarli/shaarli.svg)](https://hub.docker.com/r/shaarli/shaarli/)
+&bull;
+[![](https://img.shields.io/badge/latest-v0.8.4-blue.svg)](https://github.com/shaarli/Shaarli/releases/tag/v0.8.4)
+[![](https://img.shields.io/travis/shaarli/Shaarli/latest.svg?label=latest)](https://travis-ci.org/shaarli/Shaarli)
+&bull;
+[![](https://img.shields.io/badge/master-v0.9.x-blue.svg)](https://github.com/shaarli/Shaarli)
+[![](https://img.shields.io/travis/shaarli/Shaarli.svg?label=master)](https://travis-ci.org/shaarli/Shaarli)
 
 [![Join the chat at https://gitter.im/shaarli/Shaarli](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/shaarli/Shaarli)
 [![Bountysource](https://www.bountysource.com/badge/team?team_id=19583&style=bounties_received)](https://www.bountysource.com/teams/shaarli/issues)
+[![Docker repository](https://img.shields.io/docker/pulls/shaarli/shaarli.svg)](https://hub.docker.com/r/shaarli/shaarli/)
 
 ## Quickstart
 - [Wiki/documentation](https://github.com/shaarli/Shaarli/wiki)
index 544aba7ca3f3c1504a093a4f2483b29474af9268..b133dee83644794f7617726a79e1d087f373f825 100644 (file)
@@ -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.
index 1bc5be0c3d24ad9b0c1bd8b8f6f0eabaab9c71ed..0fb68c5aa151bedffe10e5c79e8207997ee812de 100644 (file)
@@ -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;
     }
 
index 30908d90db436574f9585d20d6b437f29d56e363..9ef2ef562634bb346cf398b290093cbd02e66926 100644 (file)
@@ -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. '<br>➜ <code>' . json_last_error_msg() .'</code>';
+            if ($errorCode === JSON_ERROR_SYNTAX) {
+                $error .= '<br>Please check your JSON syntax (without PHP comment tags) using a JSON lint tool such as ';
+                $error .= '<a href="http://jsonlint.com/">jsonlint.com</a>.';
+            }
+            throw new \Exception($error);
         }
         return $data;
     }
index f2097410364db285236fdd5013bcfa8729882e35..7bfbfc729fe4b67c153d8c5c367d1bd763d074f5 100644 (file)
@@ -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);
index b522d616b4dc658ab72d285234f9e4354af58633..11b6444acbfb02b0441ed71993eb3829f43c0ee3 100644 (file)
@@ -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'));
+    }
 }
index 3527f83d67af1bae0816f61ea8bd164d1cfb4b99..d237bc80cdacd1a7919399f68cad57ece869a470 100644 (file)
@@ -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()
     {
index f7b80b68647c14553d3415a70b94476bb64247aa..77fc65dd9630feef1520b28c43569f18d13f8b85 100644 (file)
@@ -3,7 +3,11 @@
 <div class="pure-g">
   <div class="pure-u-2-24"></div>
   <div id="footer" class="pure-u-20-24">
-    <strong><a href="https://github.com/shaarli/Shaarli">Shaarli</a></strong> &middot;
+    <strong><a href="https://github.com/shaarli/Shaarli">Shaarli</a></strong>
+    {if="isLoggedIn()===true"}
+      {$version}
+    {/if}
+    &middot;
     The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community &middot;
     <a href="doc/Home.html" rel="nofollow">Documentation</a>
       {loop="$plugins_footer.text"}
index 03ca6843e4a6c61984be516ca7b747421a6eae0b..9388ef79e9cdc42ca3e1b9c288a21df91d4255ce 100644 (file)
@@ -48,7 +48,7 @@
           </li>
         {/loop}
         <li class="pure-menu-item pure-u-lg-0">
-          <a href="?do=atom{$searchcrits}" class="pure-menu-link">{'RSS Feed'|t}</a>
+            <a href="?do={$feed_type}{$searchcrits}" class="pure-menu-link">{'RSS Feed'|t}</a>
         </li>
         {if="isLoggedIn()"}
           <li class="pure-menu-item pure-u-lg-0">
@@ -70,7 +70,7 @@
             </a>
           </li>
           <li class="pure-menu-item">
-            <a href="?do=atom{$searchcrits}" class="pure-menu-link" title="{'RSS Feed'|t}">
+            <a href="?do={$feed_type}{$searchcrits}" class="pure-menu-link" title="{'RSS Feed'|t}">
               <i class="fa fa-rss"></i>
             </a>
           </li>