]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Fixes #304: use atom feed as default 804/head
authorArthurHoaro <arthur@hoa.ro>
Sat, 11 Mar 2017 13:11:06 +0000 (14:11 +0100)
committerArthurHoaro <arthur@hoa.ro>
Sat, 11 Mar 2017 13:13:58 +0000 (14:13 +0100)
RSS feed is still available with the  setting set to false

application/PageBuilder.php
application/Updater.php
application/config/ConfigManager.php
tests/Updater/UpdaterTest.php
tpl/default/page.header.html

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 fd7e2073089eaca16a51fee881a1a68b45cc05df..efbfc832d352cb4872dd96a4f5a3e3162a88c4e3 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 f2097410364db285236fdd5013bcfa8729882e35..c5eeda08681728acbc0638aca8bff3737d184166 100644 (file)
@@ -317,7 +317,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 b76fc03e003a111221085b0440d2caf3cc809e2a..04f33ea2377e7675832612bd210dd73330c391ba 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>