]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge remote-tracking branch 'virtualtam/test/link-db' into next
authornodiscc <nodiscc@gmail.com>
Tue, 23 Jun 2015 12:38:43 +0000 (14:38 +0200)
committernodiscc <nodiscc@gmail.com>
Tue, 23 Jun 2015 12:38:43 +0000 (14:38 +0200)
Conflicts:
index.php

.travis.yml [new file with mode: 0644]
inc/shaarli.css
index.php
tpl/linklist.html

diff --git a/.travis.yml b/.travis.yml
new file mode 100644 (file)
index 0000000..bcaf682
--- /dev/null
@@ -0,0 +1,10 @@
+language: php
+php:
+  - 5.6
+  - 5.5
+  - 5.4
+install:
+  - composer self-update
+  - composer install
+script:
+  - make test
index c4348c70ff92757a8f102ed8509d26054041a19c..f54135249a80da97a14fdc64179db6ae3af94d81 100644 (file)
@@ -221,8 +221,17 @@ h1 {
     margin-left:24px;
 }
 
+.tagfilter div.awesomplete {
+    width: inherit;
+}
+
 .tagfilter #tagfilter_value {
-    width: 10%;
+    width: 100%;
+    display: inline;
+}
+
+.tagfilter li {
+    color: black;
 }
 
 .tagfilter input.bigbutton, .searchform input.bigbutton, .addform input.bigbutton {
index ed18c7f948c9de773c7bd90150e804371afa30ba..d0dd5306eb41d28d713079db721986d0a2b3436d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -702,16 +702,13 @@ 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']);
+    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if user it not logged in).
 
     // Optionally filter the results:
     $linksToDisplay=array();
     if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
     else if (!empty($_GET['searchtags']))   $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
     else $linksToDisplay = $LINKSDB;
-    
-    if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
-        $linksToDisplay = array();
         
     $nblinksToDisplay = 50;  // Number of links to display.
     if (!empty($_GET['nb']))  // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
@@ -780,7 +777,7 @@ 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']);
+    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);  // Read links from database (and filter private links if used it not logged in).
 
 
     // Optionally filter the results:
@@ -788,9 +785,6 @@ function showATOM()
     if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
     else if (!empty($_GET['searchtags']))   $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
     else $linksToDisplay = $LINKSDB;
-    
-    if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
-        $linksToDisplay = array();
         
     $nblinksToDisplay = 50;  // Number of links to display.
     if (!empty($_GET['nb']))  // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
@@ -865,7 +859,7 @@ 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']);
+    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);  // Read links from database (and filter private links if used it not logged in).
 
     /* Some Shaarlies may have very few links, so we need to look
        back in time (rsort()) until we have enough days ($nb_of_days).
@@ -933,7 +927,7 @@ function showDailyRSS()
 // "Daily" page.
 function showDaily()
 {
-    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);
+    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);  // Read links from database (and filter private links if used it not logged in).
 
 
     $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD.
@@ -951,8 +945,6 @@ function showDaily()
     }
 
     $linksToDisplay=$LINKSDB->filterDay($day);
-    if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
-        $linksToDisplay = array();
     // We pre-format some fields for proper output.
     foreach($linksToDisplay as $key=>$link)
     {
@@ -1001,7 +993,7 @@ function showDaily()
 // Render HTML page (according to URL parameters and user rights)
 function renderPage()
 {
-    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);
+    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);  // Read links from database (and filter private links if used it not logged in).
 
     // -------- Display login form.
     if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=login'))
@@ -1031,9 +1023,6 @@ function renderPage()
         if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']);
         elseif (!empty($_GET['searchtags']))   $links = $LINKSDB->filterTags(trim($_GET['searchtags']));
         else $links = $LINKSDB;
-        
-        if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
-            $links = array();
             
         $body='';
         $linksToDisplay=array();
@@ -1061,8 +1050,7 @@ function renderPage()
     if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud'))
     {
         $tags= $LINKSDB->allTags();
-        if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
-            $tags = array();
+
         // We sort tags alphabetically, then choose a font size according to count.
         // First, find max value.
         $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value);
@@ -1583,7 +1571,7 @@ HTML;
 function importFile()
 {
     if (!(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'])) { die('Not allowed.'); }
-    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);
+    $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']);   // Read links from database (and filter private links if used it not logged in).
     $filename=$_FILES['filetoupload']['name'];
     $filesize=$_FILES['filetoupload']['size'];
     $data=file_get_contents($_FILES['filetoupload']['tmp_name']);
@@ -1675,16 +1663,12 @@ function buildLinkList($PAGE,$LINKSDB)
     if (isset($_GET['searchterm'])) // Fulltext search
     {
         $linksToDisplay = $LINKSDB->filterFulltext(trim($_GET['searchterm']));
-        if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
-            $linksToDisplay = array();  
         $search_crits=htmlspecialchars(trim($_GET['searchterm']));
         $search_type='fulltext';
     }
     elseif (isset($_GET['searchtags'])) // Search by tag
     {
         $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
-        if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
-            $linksToDisplay = array();
         $search_crits=explode(' ',trim($_GET['searchtags']));
         $search_type='tags';
     }
@@ -1700,9 +1684,6 @@ function buildLinkList($PAGE,$LINKSDB)
         }
         $search_type='permalink';
     }
-    // We chose to disable all private links and the user isn't logged in, do not return any link.
-    else if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
-        $linksToDisplay = array();
     else
         $linksToDisplay = $LINKSDB;  // Otherwise, display without filtering.
 
@@ -1779,6 +1760,7 @@ function buildLinkList($PAGE,$LINKSDB)
     $PAGE->assign('redirector',empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector']); // Optional redirector URL.
     $PAGE->assign('token',$token);
     $PAGE->assign('links',$linkDisp);
+    $PAGE->assign('tags', $LINKSDB->allTags());
     return;
 }
 
index 766a80ce83044e9f5f07ee8b6df3d725e26414e9..47e67e71effd6e96ac8e93984c5c205ac532bb65 100644 (file)
@@ -1,12 +1,21 @@
 <!DOCTYPE html>
 <html>
-<head>{include="includes"}</head>
+<head>
+    <link type="text/css" rel="stylesheet" href="../inc/awesomplete.css" />
+    {include="includes"}
+</head>
 <body>
 <div id="pageheader">
     {include="page.header"}
     <div id="headerform" class="search">
         <form method="GET" class="searchform" name="searchform"><input type="text" id="searchform_value" name="searchterm" placeholder="Search text" value=""> <input type="submit" value="Search" class="bigbutton"></form>
-        <form method="GET" class="tagfilter" name="tagfilter"><input type="text" name="searchtags" id="tagfilter_value" placeholder="Filter by tag" value=""> <input type="submit" value="Search" class="bigbutton"></form>
+        <form method="GET" class="tagfilter" name="tagfilter">
+            <input type="text" name="searchtags" id="tagfilter_value" placeholder="Filter by tag" value="" list="tagsList" autocomplete="off" class="awesomplete" data-minChars="1">
+            <datalist id="tagsList">
+                {loop="$tags"}<option>{$key}</option>{/loop}
+            </datalist>
+            <input type="submit" value="Search" class="bigbutton">
+        </form>
     </div>
 </div>
 
@@ -129,5 +138,6 @@ function showQrCode(caller,loading)
     return false;
 }
 </script>
+<script src="inc/awesomplete.min.js#"></script>
 </body>
 </html>