diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | application/HttpUtils.php | 2 | ||||
-rw-r--r-- | application/NetscapeBookmarkUtils.php | 15 | ||||
-rw-r--r-- | application/Router.php | 26 | ||||
-rw-r--r-- | application/Utils.php | 16 | ||||
-rw-r--r-- | index.php | 36 | ||||
-rw-r--r-- | plugins/markdown/markdown.css | 7 | ||||
-rw-r--r-- | tests/NetscapeBookmarkUtilsTest.php | 38 | ||||
-rw-r--r-- | tpl/export.html | 24 | ||||
-rw-r--r-- | tpl/page.footer.html | 4 |
10 files changed, 120 insertions, 50 deletions
@@ -1,6 +1,6 @@ | |||
1 | ![Shaarli logo](doc/images/doc-logo.png) | 1 | ![Shaarli logo](doc/images/doc-logo.png) |
2 | 2 | ||
3 | The personal, minimalist, super-fast, no-database delicious clone. | 3 | The personal, minimalist, super-fast, database free, bookmarking service. |
4 | 4 | ||
5 | _Do you want to share the links you discover?_ | 5 | _Do you want to share the links you discover?_ |
6 | _Shaarli is a minimalist delicious clone that you can install on your own server._ | 6 | _Shaarli is a minimalist delicious clone that you can install on your own server._ |
diff --git a/application/HttpUtils.php b/application/HttpUtils.php index c84ba6f0..2e0792f9 100644 --- a/application/HttpUtils.php +++ b/application/HttpUtils.php | |||
@@ -193,7 +193,7 @@ function server_url($server) | |||
193 | function index_url($server) | 193 | function index_url($server) |
194 | { | 194 | { |
195 | $scriptname = $server['SCRIPT_NAME']; | 195 | $scriptname = $server['SCRIPT_NAME']; |
196 | if (endswith($scriptname, 'index.php')) { | 196 | if (endsWith($scriptname, 'index.php')) { |
197 | $scriptname = substr($scriptname, 0, -9); | 197 | $scriptname = substr($scriptname, 0, -9); |
198 | } | 198 | } |
199 | return server_url($server) . $scriptname; | 199 | return server_url($server) . $scriptname; |
diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php index 8a296705..fdbb0ad7 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/NetscapeBookmarkUtils.php | |||
@@ -13,17 +13,19 @@ class NetscapeBookmarkUtils | |||
13 | * - timestamp link addition date, using the Unix epoch format | 13 | * - timestamp link addition date, using the Unix epoch format |
14 | * - taglist comma-separated tag list | 14 | * - taglist comma-separated tag list |
15 | * | 15 | * |
16 | * @param LinkDB $linkDb The link datastore | 16 | * @param LinkDB $linkDb Link datastore |
17 | * @param string $selection Which links to export: (all|private|public) | 17 | * @param string $selection Which links to export: (all|private|public) |
18 | * @param bool $prependNoteUrl Prepend note permalinks with the server's URL | ||
19 | * @param string $indexUrl Absolute URL of the Shaarli index page | ||
18 | * | 20 | * |
19 | * @throws Exception Invalid export selection | 21 | * @throws Exception Invalid export selection |
20 | * | 22 | * |
21 | * @return array The links to be exported, with additional fields | 23 | * @return array The links to be exported, with additional fields |
22 | */ | 24 | */ |
23 | public static function filterAndFormat($linkDb, $selection) | 25 | public static function filterAndFormat($linkDb, $selection, $prependNoteUrl, $indexUrl) |
24 | { | 26 | { |
25 | // see tpl/export.html for possible values | 27 | // see tpl/export.html for possible values |
26 | if (! in_array($selection, array('all','public','private'))) { | 28 | if (! in_array($selection, array('all', 'public', 'private'))) { |
27 | throw new Exception('Invalid export selection: "'.$selection.'"'); | 29 | throw new Exception('Invalid export selection: "'.$selection.'"'); |
28 | } | 30 | } |
29 | 31 | ||
@@ -39,6 +41,11 @@ class NetscapeBookmarkUtils | |||
39 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); | 41 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); |
40 | $link['timestamp'] = $date->getTimestamp(); | 42 | $link['timestamp'] = $date->getTimestamp(); |
41 | $link['taglist'] = str_replace(' ', ',', $link['tags']); | 43 | $link['taglist'] = str_replace(' ', ',', $link['tags']); |
44 | |||
45 | if (startsWith($link['url'], '?') && $prependNoteUrl) { | ||
46 | $link['url'] = $indexUrl . $link['url']; | ||
47 | } | ||
48 | |||
42 | $bookmarkLinks[] = $link; | 49 | $bookmarkLinks[] = $link; |
43 | } | 50 | } |
44 | 51 | ||
diff --git a/application/Router.php b/application/Router.php index a1e594a0..2c3934b0 100644 --- a/application/Router.php +++ b/application/Router.php | |||
@@ -63,19 +63,19 @@ class Router | |||
63 | return self::$PAGE_LINKLIST; | 63 | return self::$PAGE_LINKLIST; |
64 | } | 64 | } |
65 | 65 | ||
66 | if (startswith($query, 'do='. self::$PAGE_LOGIN) && $loggedIn === false) { | 66 | if (startsWith($query, 'do='. self::$PAGE_LOGIN) && $loggedIn === false) { |
67 | return self::$PAGE_LOGIN; | 67 | return self::$PAGE_LOGIN; |
68 | } | 68 | } |
69 | 69 | ||
70 | if (startswith($query, 'do='. self::$PAGE_PICWALL)) { | 70 | if (startsWith($query, 'do='. self::$PAGE_PICWALL)) { |
71 | return self::$PAGE_PICWALL; | 71 | return self::$PAGE_PICWALL; |
72 | } | 72 | } |
73 | 73 | ||
74 | if (startswith($query, 'do='. self::$PAGE_TAGCLOUD)) { | 74 | if (startsWith($query, 'do='. self::$PAGE_TAGCLOUD)) { |
75 | return self::$PAGE_TAGCLOUD; | 75 | return self::$PAGE_TAGCLOUD; |
76 | } | 76 | } |
77 | 77 | ||
78 | if (startswith($query, 'do='. self::$PAGE_OPENSEARCH)) { | 78 | if (startsWith($query, 'do='. self::$PAGE_OPENSEARCH)) { |
79 | return self::$PAGE_OPENSEARCH; | 79 | return self::$PAGE_OPENSEARCH; |
80 | } | 80 | } |
81 | 81 | ||
@@ -96,23 +96,23 @@ class Router | |||
96 | return self::$PAGE_LINKLIST; | 96 | return self::$PAGE_LINKLIST; |
97 | } | 97 | } |
98 | 98 | ||
99 | if (startswith($query, 'do='. self::$PAGE_TOOLS)) { | 99 | if (startsWith($query, 'do='. self::$PAGE_TOOLS)) { |
100 | return self::$PAGE_TOOLS; | 100 | return self::$PAGE_TOOLS; |
101 | } | 101 | } |
102 | 102 | ||
103 | if (startswith($query, 'do='. self::$PAGE_CHANGEPASSWORD)) { | 103 | if (startsWith($query, 'do='. self::$PAGE_CHANGEPASSWORD)) { |
104 | return self::$PAGE_CHANGEPASSWORD; | 104 | return self::$PAGE_CHANGEPASSWORD; |
105 | } | 105 | } |
106 | 106 | ||
107 | if (startswith($query, 'do='. self::$PAGE_CONFIGURE)) { | 107 | if (startsWith($query, 'do='. self::$PAGE_CONFIGURE)) { |
108 | return self::$PAGE_CONFIGURE; | 108 | return self::$PAGE_CONFIGURE; |
109 | } | 109 | } |
110 | 110 | ||
111 | if (startswith($query, 'do='. self::$PAGE_CHANGETAG)) { | 111 | if (startsWith($query, 'do='. self::$PAGE_CHANGETAG)) { |
112 | return self::$PAGE_CHANGETAG; | 112 | return self::$PAGE_CHANGETAG; |
113 | } | 113 | } |
114 | 114 | ||
115 | if (startswith($query, 'do='. self::$PAGE_ADDLINK)) { | 115 | if (startsWith($query, 'do='. self::$PAGE_ADDLINK)) { |
116 | return self::$PAGE_ADDLINK; | 116 | return self::$PAGE_ADDLINK; |
117 | } | 117 | } |
118 | 118 | ||
@@ -120,19 +120,19 @@ class Router | |||
120 | return self::$PAGE_EDITLINK; | 120 | return self::$PAGE_EDITLINK; |
121 | } | 121 | } |
122 | 122 | ||
123 | if (startswith($query, 'do='. self::$PAGE_EXPORT)) { | 123 | if (startsWith($query, 'do='. self::$PAGE_EXPORT)) { |
124 | return self::$PAGE_EXPORT; | 124 | return self::$PAGE_EXPORT; |
125 | } | 125 | } |
126 | 126 | ||
127 | if (startswith($query, 'do='. self::$PAGE_IMPORT)) { | 127 | if (startsWith($query, 'do='. self::$PAGE_IMPORT)) { |
128 | return self::$PAGE_IMPORT; | 128 | return self::$PAGE_IMPORT; |
129 | } | 129 | } |
130 | 130 | ||
131 | if (startswith($query, 'do='. self::$PAGE_PLUGINSADMIN)) { | 131 | if (startsWith($query, 'do='. self::$PAGE_PLUGINSADMIN)) { |
132 | return self::$PAGE_PLUGINSADMIN; | 132 | return self::$PAGE_PLUGINSADMIN; |
133 | } | 133 | } |
134 | 134 | ||
135 | if (startswith($query, 'do='. self::$PAGE_SAVE_PLUGINSADMIN)) { | 135 | if (startsWith($query, 'do='. self::$PAGE_SAVE_PLUGINSADMIN)) { |
136 | return self::$PAGE_SAVE_PLUGINSADMIN; | 136 | return self::$PAGE_SAVE_PLUGINSADMIN; |
137 | } | 137 | } |
138 | 138 | ||
diff --git a/application/Utils.php b/application/Utils.php index 5b8ca508..da521cce 100644 --- a/application/Utils.php +++ b/application/Utils.php | |||
@@ -41,8 +41,14 @@ function smallHash($text) | |||
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Tells if a string start with a substring | 43 | * Tells if a string start with a substring |
44 | * | ||
45 | * @param string $haystack Given string. | ||
46 | * @param string $needle String to search at the beginning of $haystack. | ||
47 | * @param bool $case Case sensitive. | ||
48 | * | ||
49 | * @return bool True if $haystack starts with $needle. | ||
44 | */ | 50 | */ |
45 | function startsWith($haystack, $needle, $case=true) | 51 | function startsWith($haystack, $needle, $case = true) |
46 | { | 52 | { |
47 | if ($case) { | 53 | if ($case) { |
48 | return (strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0); | 54 | return (strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0); |
@@ -52,8 +58,14 @@ function startsWith($haystack, $needle, $case=true) | |||
52 | 58 | ||
53 | /** | 59 | /** |
54 | * Tells if a string ends with a substring | 60 | * Tells if a string ends with a substring |
61 | * | ||
62 | * @param string $haystack Given string. | ||
63 | * @param string $needle String to search at the end of $haystack. | ||
64 | * @param bool $case Case sensitive. | ||
65 | * | ||
66 | * @return bool True if $haystack ends with $needle. | ||
55 | */ | 67 | */ |
56 | function endsWith($haystack, $needle, $case=true) | 68 | function endsWith($haystack, $needle, $case = true) |
57 | { | 69 | { |
58 | if ($case) { | 70 | if ($case) { |
59 | return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0); | 71 | return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0); |
@@ -690,7 +690,7 @@ class pageBuilder | |||
690 | // This RSS feed cannot be filtered. | 690 | // This RSS feed cannot be filtered. |
691 | function showDailyRSS() { | 691 | function showDailyRSS() { |
692 | // Cache system | 692 | // Cache system |
693 | $query = $_SERVER["QUERY_STRING"]; | 693 | $query = $_SERVER['QUERY_STRING']; |
694 | $cache = new CachedPage( | 694 | $cache = new CachedPage( |
695 | $GLOBALS['config']['PAGECACHE'], | 695 | $GLOBALS['config']['PAGECACHE'], |
696 | page_url($_SERVER), | 696 | page_url($_SERVER), |
@@ -951,7 +951,7 @@ function renderPage() | |||
951 | exit; | 951 | exit; |
952 | } | 952 | } |
953 | // -------- User wants to logout. | 953 | // -------- User wants to logout. |
954 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=logout')) | 954 | if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=logout')) |
955 | { | 955 | { |
956 | invalidateCaches($GLOBALS['config']['PAGECACHE']); | 956 | invalidateCaches($GLOBALS['config']['PAGECACHE']); |
957 | logout(); | 957 | logout(); |
@@ -1202,12 +1202,6 @@ function renderPage() | |||
1202 | exit; | 1202 | exit; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | // Same case as above except that user tried to access ?do=addlink without being logged in | ||
1206 | // Note: passing empty parameters makes Shaarli generate default URLs and descriptions. | ||
1207 | if (isset($_GET['do']) && $_GET['do'] === 'addlink') { | ||
1208 | header('Location: ?do=login&post='); | ||
1209 | exit; | ||
1210 | } | ||
1211 | showLinkList($PAGE, $LINKSDB); | 1205 | showLinkList($PAGE, $LINKSDB); |
1212 | if (isset($_GET['edit_link'])) { | 1206 | if (isset($_GET['edit_link'])) { |
1213 | header('Location: ?do=login&edit_link='. escape($_GET['edit_link'])); | 1207 | header('Location: ?do=login&edit_link='. escape($_GET['edit_link'])); |
@@ -1593,8 +1587,9 @@ function renderPage() | |||
1593 | exit; | 1587 | exit; |
1594 | } | 1588 | } |
1595 | 1589 | ||
1596 | // -------- Export as Netscape Bookmarks HTML file. | ||
1597 | if ($targetPage == Router::$PAGE_EXPORT) { | 1590 | if ($targetPage == Router::$PAGE_EXPORT) { |
1591 | // Export links as a Netscape Bookmarks file | ||
1592 | |||
1598 | if (empty($_GET['selection'])) { | 1593 | if (empty($_GET['selection'])) { |
1599 | $PAGE->assign('linkcount',count($LINKSDB)); | 1594 | $PAGE->assign('linkcount',count($LINKSDB)); |
1600 | $PAGE->renderPage('export'); | 1595 | $PAGE->renderPage('export'); |
@@ -1603,10 +1598,21 @@ function renderPage() | |||
1603 | 1598 | ||
1604 | // export as bookmarks_(all|private|public)_YYYYmmdd_HHMMSS.html | 1599 | // export as bookmarks_(all|private|public)_YYYYmmdd_HHMMSS.html |
1605 | $selection = $_GET['selection']; | 1600 | $selection = $_GET['selection']; |
1601 | if (isset($_GET['prepend_note_url'])) { | ||
1602 | $prependNoteUrl = $_GET['prepend_note_url']; | ||
1603 | } else { | ||
1604 | $prependNoteUrl = false; | ||
1605 | } | ||
1606 | |||
1606 | try { | 1607 | try { |
1607 | $PAGE->assign( | 1608 | $PAGE->assign( |
1608 | 'links', | 1609 | 'links', |
1609 | NetscapeBookmarkUtils::filterAndFormat($LINKSDB, $selection) | 1610 | NetscapeBookmarkUtils::filterAndFormat( |
1611 | $LINKSDB, | ||
1612 | $selection, | ||
1613 | $prependNoteUrl, | ||
1614 | index_url($_SERVER) | ||
1615 | ) | ||
1610 | ); | 1616 | ); |
1611 | } catch (Exception $exc) { | 1617 | } catch (Exception $exc) { |
1612 | header('Content-Type: text/plain; charset=utf-8'); | 1618 | header('Content-Type: text/plain; charset=utf-8'); |
@@ -1627,7 +1633,7 @@ function renderPage() | |||
1627 | } | 1633 | } |
1628 | 1634 | ||
1629 | // -------- User is uploading a file for import | 1635 | // -------- User is uploading a file for import |
1630 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=upload')) | 1636 | if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=upload')) |
1631 | { | 1637 | { |
1632 | // If file is too big, some form field may be missing. | 1638 | // If file is too big, some form field may be missing. |
1633 | if (!isset($_POST['token']) || (!isset($_FILES)) || (isset($_FILES['filetoupload']['size']) && $_FILES['filetoupload']['size']==0)) | 1639 | if (!isset($_POST['token']) || (!isset($_FILES)) || (isset($_FILES['filetoupload']['size']) && $_FILES['filetoupload']['size']==0)) |
@@ -1730,7 +1736,7 @@ function importFile($LINKSDB) | |||
1730 | { | 1736 | { |
1731 | $link = array('linkdate'=>'','title'=>'','url'=>'','description'=>'','tags'=>'','private'=>0); | 1737 | $link = array('linkdate'=>'','title'=>'','url'=>'','description'=>'','tags'=>'','private'=>0); |
1732 | $d = explode('<DD>',$html); | 1738 | $d = explode('<DD>',$html); |
1733 | if (startswith($d[0],'<A ')) | 1739 | if (startsWith($d[0], '<A ')) |
1734 | { | 1740 | { |
1735 | $link['description'] = (isset($d[1]) ? html_entity_decode(trim($d[1]),ENT_QUOTES,'UTF-8') : ''); // Get description (optional) | 1741 | $link['description'] = (isset($d[1]) ? html_entity_decode(trim($d[1]),ENT_QUOTES,'UTF-8') : ''); // Get description (optional) |
1736 | preg_match('!<A .*?>(.*?)</A>!i',$d[0],$matches); $link['title'] = (isset($matches[1]) ? trim($matches[1]) : ''); // Get title | 1742 | preg_match('!<A .*?>(.*?)</A>!i',$d[0],$matches); $link['title'] = (isset($matches[1]) ? trim($matches[1]) : ''); // Get title |
@@ -2201,7 +2207,7 @@ function genThumbnail() | |||
2201 | 2207 | ||
2202 | // Is this a link to an image, or to a flickr page ? | 2208 | // Is this a link to an image, or to a flickr page ? |
2203 | $imageurl=''; | 2209 | $imageurl=''; |
2204 | if (endswith(parse_url($url,PHP_URL_PATH),'.jpg')) | 2210 | if (endsWith(parse_url($url, PHP_URL_PATH), '.jpg')) |
2205 | { // This is a direct link to an image. e.g. http://farm1.staticflickr.com/5/5921913_ac83ed27bd_o.jpg | 2211 | { // This is a direct link to an image. e.g. http://farm1.staticflickr.com/5/5921913_ac83ed27bd_o.jpg |
2206 | preg_match('!(http://farm\d+\.staticflickr\.com/\d+/\d+_\w+_)\w.jpg!',$url,$matches); | 2212 | preg_match('!(http://farm\d+\.staticflickr\.com/\d+/\d+_\w+_)\w.jpg!',$url,$matches); |
2207 | if (!empty($matches[1])) $imageurl=$matches[1].'m.jpg'; | 2213 | if (!empty($matches[1])) $imageurl=$matches[1].'m.jpg'; |
@@ -2378,8 +2384,8 @@ function resizeImage($filepath) | |||
2378 | return true; | 2384 | return true; |
2379 | } | 2385 | } |
2380 | 2386 | ||
2381 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database. | 2387 | if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database. |
2382 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; } | 2388 | if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=dailyrss')) { showDailyRSS(); exit; } |
2383 | if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; | 2389 | if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; |
2384 | renderPage(); | 2390 | renderPage(); |
2385 | ?> | 2391 | ?> |
diff --git a/plugins/markdown/markdown.css b/plugins/markdown/markdown.css index 3c1b2aeb..6789ce84 100644 --- a/plugins/markdown/markdown.css +++ b/plugins/markdown/markdown.css | |||
@@ -143,6 +143,13 @@ | |||
143 | hyphens: none; | 143 | hyphens: none; |
144 | } | 144 | } |
145 | 145 | ||
146 | .markdown :not(pre) code { | ||
147 | background-color: #eee; | ||
148 | padding: 1px 3px; | ||
149 | border-radius: 1px; | ||
150 | box-shadow: 0 -1px 0 #e5e5e5,0 0 1px rgba(0,0,0,0.12),0 1px 1px rgba(0,0,0,0.24); | ||
151 | } | ||
152 | |||
146 | .md_help { | 153 | .md_help { |
147 | color: white; | 154 | color: white; |
148 | } | 155 | } |
diff --git a/tests/NetscapeBookmarkUtilsTest.php b/tests/NetscapeBookmarkUtilsTest.php index b7472d92..41e6d84c 100644 --- a/tests/NetscapeBookmarkUtilsTest.php +++ b/tests/NetscapeBookmarkUtilsTest.php | |||
@@ -39,7 +39,7 @@ class NetscapeBookmarkUtilsTest extends PHPUnit_Framework_TestCase | |||
39 | */ | 39 | */ |
40 | public function testFilterAndFormatInvalid() | 40 | public function testFilterAndFormatInvalid() |
41 | { | 41 | { |
42 | NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'derp'); | 42 | NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'derp', false, ''); |
43 | } | 43 | } |
44 | 44 | ||
45 | /** | 45 | /** |
@@ -47,7 +47,7 @@ class NetscapeBookmarkUtilsTest extends PHPUnit_Framework_TestCase | |||
47 | */ | 47 | */ |
48 | public function testFilterAndFormatAll() | 48 | public function testFilterAndFormatAll() |
49 | { | 49 | { |
50 | $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'all'); | 50 | $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'all', false, ''); |
51 | $this->assertEquals(self::$refDb->countLinks(), sizeof($links)); | 51 | $this->assertEquals(self::$refDb->countLinks(), sizeof($links)); |
52 | foreach ($links as $link) { | 52 | foreach ($links as $link) { |
53 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); | 53 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); |
@@ -67,7 +67,7 @@ class NetscapeBookmarkUtilsTest extends PHPUnit_Framework_TestCase | |||
67 | */ | 67 | */ |
68 | public function testFilterAndFormatPrivate() | 68 | public function testFilterAndFormatPrivate() |
69 | { | 69 | { |
70 | $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'private'); | 70 | $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'private', false, ''); |
71 | $this->assertEquals(self::$refDb->countPrivateLinks(), sizeof($links)); | 71 | $this->assertEquals(self::$refDb->countPrivateLinks(), sizeof($links)); |
72 | foreach ($links as $link) { | 72 | foreach ($links as $link) { |
73 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); | 73 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); |
@@ -87,7 +87,7 @@ class NetscapeBookmarkUtilsTest extends PHPUnit_Framework_TestCase | |||
87 | */ | 87 | */ |
88 | public function testFilterAndFormatPublic() | 88 | public function testFilterAndFormatPublic() |
89 | { | 89 | { |
90 | $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'public'); | 90 | $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'public', false, ''); |
91 | $this->assertEquals(self::$refDb->countPublicLinks(), sizeof($links)); | 91 | $this->assertEquals(self::$refDb->countPublicLinks(), sizeof($links)); |
92 | foreach ($links as $link) { | 92 | foreach ($links as $link) { |
93 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); | 93 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); |
@@ -101,4 +101,34 @@ class NetscapeBookmarkUtilsTest extends PHPUnit_Framework_TestCase | |||
101 | ); | 101 | ); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | |||
105 | /** | ||
106 | * Do not prepend notes with the Shaarli index's URL | ||
107 | */ | ||
108 | public function testFilterAndFormatDoNotPrependNoteUrl() | ||
109 | { | ||
110 | $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'public', false, ''); | ||
111 | $this->assertEquals( | ||
112 | '?WDWyig', | ||
113 | $links[0]['url'] | ||
114 | ); | ||
115 | } | ||
116 | |||
117 | /** | ||
118 | * Prepend notes with the Shaarli index's URL | ||
119 | */ | ||
120 | public function testFilterAndFormatPrependNoteUrl() | ||
121 | { | ||
122 | $indexUrl = 'http://localhost:7469/shaarli/'; | ||
123 | $links = NetscapeBookmarkUtils::filterAndFormat( | ||
124 | self::$linkDb, | ||
125 | 'public', | ||
126 | true, | ||
127 | $indexUrl | ||
128 | ); | ||
129 | $this->assertEquals( | ||
130 | $indexUrl . '?WDWyig', | ||
131 | $links[0]['url'] | ||
132 | ); | ||
133 | } | ||
104 | } | 134 | } |
diff --git a/tpl/export.html b/tpl/export.html index 9582627a..67c3d05f 100644 --- a/tpl/export.html +++ b/tpl/export.html | |||
@@ -5,15 +5,21 @@ | |||
5 | <div id="pageheader"> | 5 | <div id="pageheader"> |
6 | {include="page.header"} | 6 | {include="page.header"} |
7 | <div id="toolsdiv"> | 7 | <div id="toolsdiv"> |
8 | <a href="?do=export&selection=all"> | 8 | <form method="GET"> |
9 | <b>Export all</b><span>: Export all links</span> | 9 | <input type="hidden" name="do" value="export"> |
10 | </a><br> | 10 | Selection:<br> |
11 | <a href="?do=export&selection=public"> | 11 | <input type="radio" name="selection" value="all" checked="true"> All<br> |
12 | <b>Export public</b><span>: Only export public links</span> | 12 | <input type="radio" name="selection" value="private"> Private<br> |
13 | </a><br> | 13 | <input type="radio" name="selection" value="public"> Public<br> |
14 | <a href="?do=export&selection=private"> | 14 | <br> |
15 | <b>Export private</b><span>: Only export private links</span> | 15 | <input type="checkbox" name="prepend_note_url" id="prepend_note_url"> |
16 | </a> | 16 | <label for="prepend_note_url"> |
17 | Prepend note permalinks with this Shaarli instance's URL | ||
18 | <em>(useful to import bookmarks in a web browser)</em> | ||
19 | </label> | ||
20 | <br><br> | ||
21 | <input class="bigbutton" type="submit" value="Export"> | ||
22 | </form> | ||
17 | <div class="clear"></div> | 23 | <div class="clear"></div> |
18 | </div> | 24 | </div> |
19 | </div> | 25 | </div> |
diff --git a/tpl/page.footer.html b/tpl/page.footer.html index 195dada0..006d1d68 100644 --- a/tpl/page.footer.html +++ b/tpl/page.footer.html | |||
@@ -1,5 +1,7 @@ | |||
1 | <div id="footer"> | 1 | <div id="footer"> |
2 | <b><a href="https://github.com/shaarli/Shaarli">Shaarli</a></b> - The personal, minimalist, super-fast, no-database delicious clone by the <a href="https://github.com/shaarli/Shaarli">Shaarli</a> community - <a href="doc/Home.html">Help/documentation</a> | 2 | <strong><a href="https://github.com/shaarli/Shaarli">Shaarli</a></strong> |
3 | - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community | ||
4 | - <a href="doc/Home.html" rel="nofollow">Help/documentation</a> | ||
3 | {loop="$plugins_footer.text"} | 5 | {loop="$plugins_footer.text"} |
4 | {$value} | 6 | {$value} |
5 | {/loop} | 7 | {/loop} |