]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge remote-tracking branch 'ArthurHoaro/input-escape' into next
authornodiscc <nodiscc@gmail.com>
Tue, 23 Jun 2015 22:51:38 +0000 (00:51 +0200)
committernodiscc <nodiscc@gmail.com>
Tue, 23 Jun 2015 22:51:38 +0000 (00:51 +0200)
Conflicts:
index.php

CONTRIBUTING.md
README.md
application/LinkDB.php
inc/awesomplete.css
inc/shaarli.css
index.php
tests/LinkDBTest.php

index b819e0b975ffc7eac05697af703da47849b32018..054b9a3f1628901f1a52412aae2971487394d9d6 100644 (file)
@@ -57,6 +57,7 @@ Please report any problem you might find.
  * starting from branch ` master`, switch to a new branch (eg. `git checkout -b my-awesome-feature`)
  * edit the required files (from the Github web interface or your text editor)
  * add and commit your changes with a meaningful commit message (eg `Cool new feature, fixes issue #1001`)
+ * run unit tests against your patched version, see [Running unit tests](https://github.com/shaarli/Shaarli/wiki/Running-unit-tests)
  * Open your fork in the Github web interface and click the "Compare and Pull Request" button, enter required info and submit your Pull Request.
 
 All changes you will do on the `my-awesome-feature`  in the future will be added to your Pull Request. Don't work directly on the master branch, don't do unrelated work on your  `my-awesome-feature` branch.
index aef3f44b4a8d32ad924223fb756b465abab2e229..107269302bc63132759cd165038cbd65ca4772da 100644 (file)
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ Shaarli, the personal, minimalist, super-fast, no-database delicious clone.
 You want to share the links you discover ? Shaarli is a minimalist delicious clone you can install on your own website.
 It is designed to be personal (single-user), fast and handy.
 
-[![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)
+[![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) [![](https://api.travis-ci.org/shaarli/Shaarli.svg)](https://travis-ci.org/shaarli/Shaarli)
 
 ## Features:
 
index 0f7c5bfed2d9c61bdf95acae617e05abf9000beb..2b3fb60bb47be7fe9bd09728044315e55289186a 100644 (file)
@@ -45,6 +45,9 @@ class LinkDB implements Iterator, Countable, ArrayAccess
     // Is the user logged in? (used to filter private links)
     private $loggedIn;
 
+    // Hide public links
+    private $hidePublicLinks;
+
     /**
      * Creates a new LinkDB
      *
@@ -52,10 +55,11 @@ class LinkDB implements Iterator, Countable, ArrayAccess
      *
      * @param $isLoggedIn is the user logged in?
      */
-    function __construct($isLoggedIn)
+    function __construct($isLoggedIn, $hidePublicLinks)
     {
         // FIXME: do not access $GLOBALS, pass the datastore instead
         $this->loggedIn = $isLoggedIn;
+        $this->hidePublicLinks = $hidePublicLinks;
         $this->checkDB();
         $this->readdb();
     }
@@ -210,7 +214,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
     {
 
         // Public links are hidden and user not logged in => nothing to show
-        if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) {
+        if ($this->hidePublicLinks && !$this->loggedIn) {
             $this->links = array();
             return;
         }
index 76f903f7d57fff429f32ebf1974f266109604805..0382e139da0cffde65808c8a6343ab42565a8a5c 100644 (file)
@@ -8,7 +8,6 @@
 div.awesomplete {
     display: inline-block;
     position: relative;
-    width: 100%;
 }
 
 div.awesomplete > input {
@@ -94,4 +93,4 @@ div.awesomplete li:hover mark {
 div.awesomplete li[aria-selected="true"] mark {
     background: hsl(86, 102%, 21%);
     color: inherit;
-}
\ No newline at end of file
+}
index fcd5c6a2b436944ee74f31a9f19019eb51b41873..95732da866ff664a9b10cbf031c790133622512d 100644 (file)
@@ -221,12 +221,7 @@ h1 {
     margin-left:24px;
 }
 
-.tagfilter div.awesomplete {
-    width: inherit;
-}
-
 .tagfilter #tagfilter_value {
-    width: 100%;
     display: inline;
 }
 
@@ -349,6 +344,7 @@ h1 {
 }
 
 #headerform label {
+    cursor: pointer;
     margin-right: 10px;
 }
 
@@ -976,6 +972,11 @@ div.dailyNoEntry {
 
 @media handheld, only screen and (max-width: 480px), only screen and (max-device-width: 854px) {
     /* A few fixes for mobile devices (far from perfect). */
+
+    .tagfilter div.awesomplete {
+        width: 70%;
+    }
+
     .nomobile {
        display: none;
     }
index 39b01a2eb0eb3c3457a78da481f459367220d538..dd3ec3a41a4fd3bc2e2a641707e52d7768aba94f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -716,7 +716,11 @@ function showRSS()
     $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; }
 
     // If cached was not found (or not usable), then read the database and build the response:
-    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if user it not logged in).
+    $LINKSDB = new LinkDB(
+        isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
+        $GLOBALS['config']['HIDE_PUBLIC_LINKS']
+    );
+    // Read links from database (and filter private links if user it not logged in).
 
     // Optionally filter the results:
     $linksToDisplay=array();
@@ -791,7 +795,11 @@ function showATOM()
     $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; }
     // If cached was not found (or not usable), then read the database and build the response:
 
-    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);  // Read links from database (and filter private links if used it not logged in).
+// Read links from database (and filter private links if used it not logged in).
+    $LINKSDB = new LinkDB(
+        isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
+        $GLOBALS['config']['HIDE_PUBLIC_LINKS']
+    );
 
     // Optionally filter the results:
     $linksToDisplay=array();
@@ -872,7 +880,12 @@ function showDailyRSS()
     $cache = new pageCache(pageUrl(),startsWith($query,'do=dailyrss') && !isLoggedIn());
     $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; }
     // If cached was not found (or not usable), then read the database and build the response:
-    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);  // Read links from database (and filter private links if used it not logged in).
+
+// Read links from database (and filter private links if used it not logged in).
+    $LINKSDB = new LinkDB(
+        isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
+        $GLOBALS['config']['HIDE_PUBLIC_LINKS']
+    );
 
     /* Some Shaarlies may have very few links, so we need to look
        back in time (rsort()) until we have enough days ($nb_of_days).
@@ -940,7 +953,10 @@ function showDailyRSS()
 // "Daily" page.
 function showDaily()
 {
-    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);  // Read links from database (and filter private links if used it not logged in).
+    $LINKSDB = new LinkDB(
+        isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
+        $GLOBALS['config']['HIDE_PUBLIC_LINKS']
+    );
 
     $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD.
     if (isset($_GET['day'])) $day=$_GET['day'];
@@ -1006,7 +1022,10 @@ function showDaily()
 // Render HTML page (according to URL parameters and user rights)
 function renderPage()
 {
-    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);  // Read links from database (and filter private links if used it not logged in).
+    $LINKSDB = new LinkDB(
+        isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
+        $GLOBALS['config']['HIDE_PUBLIC_LINKS']
+    );
 
     // -------- Display login form.
     if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=login'))
@@ -1584,7 +1603,10 @@ HTML;
 function importFile()
 {
     if (!(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'])) { die('Not allowed.'); }
-    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);   // Read links from database (and filter private links if used it not logged in).
+    $LINKSDB = new LinkDB(
+        isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
+        $GLOBALS['config']['HIDE_PUBLIC_LINKS']
+    );
     $filename=$_FILES['filetoupload']['name'];
     $filesize=$_FILES['filetoupload']['size'];
     $data=file_get_contents($_FILES['filetoupload']['tmp_name']);
index bbe4e026963785c75193fd5287b838cbdfd4d491..f67d4d9bdde93d80a582d80644a2e6e493c0876d 100644 (file)
@@ -41,8 +41,8 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
         self::$refDB->write(self::$testDatastore, PHPPREFIX, PHPSUFFIX);
 
         $GLOBALS['config']['DATASTORE'] = self::$testDatastore;
-        self::$publicLinkDB = new LinkDB(false);
-        self::$privateLinkDB = new LinkDB(true);
+        self::$publicLinkDB = new LinkDB(false, false);
+        self::$privateLinkDB = new LinkDB(true, false);
     }
 
     /**
@@ -76,7 +76,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
      */
     public function testConstructLoggedIn()
     {
-        new LinkDB(true);
+        new LinkDB(true, false);
         $this->assertFileExists(self::$testDatastore);
     }
 
@@ -85,7 +85,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
      */
     public function testConstructLoggedOut()
     {
-        new LinkDB(false);
+        new LinkDB(false, false);
         $this->assertFileExists(self::$testDatastore);
     }
 
@@ -98,7 +98,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
     public function testConstructDatastoreNotWriteable()
     {
         $GLOBALS['config']['DATASTORE'] = 'null/store.db';
-        new LinkDB(false);
+        new LinkDB(false, false);
     }
 
     /**
@@ -106,7 +106,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
      */
     public function testCheckDBNew()
     {
-        $linkDB = new LinkDB(false);
+        $linkDB = new LinkDB(false, false);
         unlink(self::$testDatastore);
         $this->assertFileNotExists(self::$testDatastore);
 
@@ -126,7 +126,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
      */
     public function testCheckDBLoad()
     {
-        $linkDB = new LinkDB(false);
+        $linkDB = new LinkDB(false, false);
         $this->assertEquals(
             self::$dummyDatastoreSHA1,
             sha1_file(self::$testDatastore)
@@ -148,7 +148,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
     public function testReadEmptyDB()
     {
         file_put_contents(self::$testDatastore, PHPPREFIX.'S7QysKquBQA='.PHPSUFFIX);
-        $emptyDB = new LinkDB(false);
+        $emptyDB = new LinkDB(false, false);
         $this->assertEquals(0, sizeof($emptyDB));
         $this->assertEquals(0, count($emptyDB));
     }
@@ -180,7 +180,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
      */
     public function testSaveDB()
     {
-        $testDB = new LinkDB(true);
+        $testDB = new LinkDB(true, false);
         $dbSize = sizeof($testDB);
 
         $link = array(
@@ -198,7 +198,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
 
         $testDB->savedb();
 
-        $testDB = new LinkDB(true);
+        $testDB = new LinkDB(true, false);
         $this->assertEquals($dbSize + 1, sizeof($testDB));
     }
 
@@ -217,6 +217,23 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Count existing links - public links hidden
+     */
+    public function testCountHiddenPublic()
+    {
+        $linkDB = new LinkDB(false, true);
+
+        $this->assertEquals(
+            0,
+            $linkDB->count()
+        );
+        $this->assertEquals(
+            0,
+            $linkDB->count()
+        );
+    }
+
     /**
      * List the days for which links have been posted
      */