aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.travis.yml10
-rw-r--r--inc/shaarli.css11
-rw-r--r--index.php34
-rw-r--r--tpl/linklist.html14
4 files changed, 40 insertions, 29 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..bcaf682c
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,10 @@
1language: php
2php:
3 - 5.6
4 - 5.5
5 - 5.4
6install:
7 - composer self-update
8 - composer install
9script:
10 - make test
diff --git a/inc/shaarli.css b/inc/shaarli.css
index c4348c70..f5413524 100644
--- a/inc/shaarli.css
+++ b/inc/shaarli.css
@@ -221,8 +221,17 @@ h1 {
221 margin-left:24px; 221 margin-left:24px;
222} 222}
223 223
224.tagfilter div.awesomplete {
225 width: inherit;
226}
227
224.tagfilter #tagfilter_value { 228.tagfilter #tagfilter_value {
225 width: 10%; 229 width: 100%;
230 display: inline;
231}
232
233.tagfilter li {
234 color: black;
226} 235}
227 236
228.tagfilter input.bigbutton, .searchform input.bigbutton, .addform input.bigbutton { 237.tagfilter input.bigbutton, .searchform input.bigbutton, .addform input.bigbutton {
diff --git a/index.php b/index.php
index ed18c7f9..d0dd5306 100644
--- a/index.php
+++ b/index.php
@@ -702,16 +702,13 @@ function showRSS()
702 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; } 702 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; }
703 703
704 // If cached was not found (or not usable), then read the database and build the response: 704 // If cached was not found (or not usable), then read the database and build the response:
705 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 705 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if user it not logged in).
706 706
707 // Optionally filter the results: 707 // Optionally filter the results:
708 $linksToDisplay=array(); 708 $linksToDisplay=array();
709 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); 709 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
710 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); 710 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
711 else $linksToDisplay = $LINKSDB; 711 else $linksToDisplay = $LINKSDB;
712
713 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
714 $linksToDisplay = array();
715 712
716 $nblinksToDisplay = 50; // Number of links to display. 713 $nblinksToDisplay = 50; // Number of links to display.
717 if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. 714 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()
780 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; } 777 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; }
781 // If cached was not found (or not usable), then read the database and build the response: 778 // If cached was not found (or not usable), then read the database and build the response:
782 779
783 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 780 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
784 781
785 782
786 // Optionally filter the results: 783 // Optionally filter the results:
@@ -788,9 +785,6 @@ function showATOM()
788 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); 785 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
789 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); 786 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
790 else $linksToDisplay = $LINKSDB; 787 else $linksToDisplay = $LINKSDB;
791
792 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
793 $linksToDisplay = array();
794 788
795 $nblinksToDisplay = 50; // Number of links to display. 789 $nblinksToDisplay = 50; // Number of links to display.
796 if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. 790 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()
865 $cache = new pageCache(pageUrl(),startsWith($query,'do=dailyrss') && !isLoggedIn()); 859 $cache = new pageCache(pageUrl(),startsWith($query,'do=dailyrss') && !isLoggedIn());
866 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; } 860 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; }
867 // If cached was not found (or not usable), then read the database and build the response: 861 // If cached was not found (or not usable), then read the database and build the response:
868 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 862 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
869 863
870 /* Some Shaarlies may have very few links, so we need to look 864 /* Some Shaarlies may have very few links, so we need to look
871 back in time (rsort()) until we have enough days ($nb_of_days). 865 back in time (rsort()) until we have enough days ($nb_of_days).
@@ -933,7 +927,7 @@ function showDailyRSS()
933// "Daily" page. 927// "Daily" page.
934function showDaily() 928function showDaily()
935{ 929{
936 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 930 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
937 931
938 932
939 $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD. 933 $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD.
@@ -951,8 +945,6 @@ function showDaily()
951 } 945 }
952 946
953 $linksToDisplay=$LINKSDB->filterDay($day); 947 $linksToDisplay=$LINKSDB->filterDay($day);
954 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
955 $linksToDisplay = array();
956 // We pre-format some fields for proper output. 948 // We pre-format some fields for proper output.
957 foreach($linksToDisplay as $key=>$link) 949 foreach($linksToDisplay as $key=>$link)
958 { 950 {
@@ -1001,7 +993,7 @@ function showDaily()
1001// Render HTML page (according to URL parameters and user rights) 993// Render HTML page (according to URL parameters and user rights)
1002function renderPage() 994function renderPage()
1003{ 995{
1004 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 996 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
1005 997
1006 // -------- Display login form. 998 // -------- Display login form.
1007 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=login')) 999 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=login'))
@@ -1031,9 +1023,6 @@ function renderPage()
1031 if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']); 1023 if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']);
1032 elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags'])); 1024 elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags']));
1033 else $links = $LINKSDB; 1025 else $links = $LINKSDB;
1034
1035 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
1036 $links = array();
1037 1026
1038 $body=''; 1027 $body='';
1039 $linksToDisplay=array(); 1028 $linksToDisplay=array();
@@ -1061,8 +1050,7 @@ function renderPage()
1061 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud')) 1050 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud'))
1062 { 1051 {
1063 $tags= $LINKSDB->allTags(); 1052 $tags= $LINKSDB->allTags();
1064 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) 1053
1065 $tags = array();
1066 // We sort tags alphabetically, then choose a font size according to count. 1054 // We sort tags alphabetically, then choose a font size according to count.
1067 // First, find max value. 1055 // First, find max value.
1068 $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value); 1056 $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value);
@@ -1583,7 +1571,7 @@ HTML;
1583function importFile() 1571function importFile()
1584{ 1572{
1585 if (!(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'])) { die('Not allowed.'); } 1573 if (!(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'])) { die('Not allowed.'); }
1586 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 1574 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
1587 $filename=$_FILES['filetoupload']['name']; 1575 $filename=$_FILES['filetoupload']['name'];
1588 $filesize=$_FILES['filetoupload']['size']; 1576 $filesize=$_FILES['filetoupload']['size'];
1589 $data=file_get_contents($_FILES['filetoupload']['tmp_name']); 1577 $data=file_get_contents($_FILES['filetoupload']['tmp_name']);
@@ -1675,16 +1663,12 @@ function buildLinkList($PAGE,$LINKSDB)
1675 if (isset($_GET['searchterm'])) // Fulltext search 1663 if (isset($_GET['searchterm'])) // Fulltext search
1676 { 1664 {
1677 $linksToDisplay = $LINKSDB->filterFulltext(trim($_GET['searchterm'])); 1665 $linksToDisplay = $LINKSDB->filterFulltext(trim($_GET['searchterm']));
1678 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
1679 $linksToDisplay = array();
1680 $search_crits=htmlspecialchars(trim($_GET['searchterm'])); 1666 $search_crits=htmlspecialchars(trim($_GET['searchterm']));
1681 $search_type='fulltext'; 1667 $search_type='fulltext';
1682 } 1668 }
1683 elseif (isset($_GET['searchtags'])) // Search by tag 1669 elseif (isset($_GET['searchtags'])) // Search by tag
1684 { 1670 {
1685 $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); 1671 $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
1686 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
1687 $linksToDisplay = array();
1688 $search_crits=explode(' ',trim($_GET['searchtags'])); 1672 $search_crits=explode(' ',trim($_GET['searchtags']));
1689 $search_type='tags'; 1673 $search_type='tags';
1690 } 1674 }
@@ -1700,9 +1684,6 @@ function buildLinkList($PAGE,$LINKSDB)
1700 } 1684 }
1701 $search_type='permalink'; 1685 $search_type='permalink';
1702 } 1686 }
1703 // We chose to disable all private links and the user isn't logged in, do not return any link.
1704 else if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
1705 $linksToDisplay = array();
1706 else 1687 else
1707 $linksToDisplay = $LINKSDB; // Otherwise, display without filtering. 1688 $linksToDisplay = $LINKSDB; // Otherwise, display without filtering.
1708 1689
@@ -1779,6 +1760,7 @@ function buildLinkList($PAGE,$LINKSDB)
1779 $PAGE->assign('redirector',empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector']); // Optional redirector URL. 1760 $PAGE->assign('redirector',empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector']); // Optional redirector URL.
1780 $PAGE->assign('token',$token); 1761 $PAGE->assign('token',$token);
1781 $PAGE->assign('links',$linkDisp); 1762 $PAGE->assign('links',$linkDisp);
1763 $PAGE->assign('tags', $LINKSDB->allTags());
1782 return; 1764 return;
1783} 1765}
1784 1766
diff --git a/tpl/linklist.html b/tpl/linklist.html
index 766a80ce..47e67e71 100644
--- a/tpl/linklist.html
+++ b/tpl/linklist.html
@@ -1,12 +1,21 @@
1<!DOCTYPE html> 1<!DOCTYPE html>
2<html> 2<html>
3<head>{include="includes"}</head> 3<head>
4 <link type="text/css" rel="stylesheet" href="../inc/awesomplete.css" />
5 {include="includes"}
6</head>
4<body> 7<body>
5<div id="pageheader"> 8<div id="pageheader">
6 {include="page.header"} 9 {include="page.header"}
7 <div id="headerform" class="search"> 10 <div id="headerform" class="search">
8 <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> 11 <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>
9 <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> 12 <form method="GET" class="tagfilter" name="tagfilter">
13 <input type="text" name="searchtags" id="tagfilter_value" placeholder="Filter by tag" value="" list="tagsList" autocomplete="off" class="awesomplete" data-minChars="1">
14 <datalist id="tagsList">
15 {loop="$tags"}<option>{$key}</option>{/loop}
16 </datalist>
17 <input type="submit" value="Search" class="bigbutton">
18 </form>
10 </div> 19 </div>
11</div> 20</div>
12 21
@@ -129,5 +138,6 @@ function showQrCode(caller,loading)
129 return false; 138 return false;
130} 139}
131</script> 140</script>
141<script src="inc/awesomplete.min.js#"></script>
132</body> 142</body>
133</html> 143</html>