diff options
Diffstat (limited to 'application/bookmark')
-rw-r--r-- | application/bookmark/BookmarkFileService.php | 4 | ||||
-rw-r--r-- | application/bookmark/BookmarkFilter.php | 17 | ||||
-rw-r--r-- | application/bookmark/BookmarkInitializer.php | 74 | ||||
-rw-r--r-- | application/bookmark/LinkUtils.php | 2 |
4 files changed, 78 insertions, 19 deletions
diff --git a/application/bookmark/BookmarkFileService.php b/application/bookmark/BookmarkFileService.php index e3a61146..c9ec2609 100644 --- a/application/bookmark/BookmarkFileService.php +++ b/application/bookmark/BookmarkFileService.php | |||
@@ -362,7 +362,9 @@ class BookmarkFileService implements BookmarkServiceInterface | |||
362 | */ | 362 | */ |
363 | public function filterDay($request) | 363 | public function filterDay($request) |
364 | { | 364 | { |
365 | return $this->bookmarkFilter->filter(BookmarkFilter::$FILTER_DAY, $request); | 365 | $visibility = $this->isLoggedIn ? BookmarkFilter::$ALL : BookmarkFilter::$PUBLIC; |
366 | |||
367 | return $this->bookmarkFilter->filter(BookmarkFilter::$FILTER_DAY, $request, false, $visibility); | ||
366 | } | 368 | } |
367 | 369 | ||
368 | /** | 370 | /** |
diff --git a/application/bookmark/BookmarkFilter.php b/application/bookmark/BookmarkFilter.php index 797a36b8..6636bbfe 100644 --- a/application/bookmark/BookmarkFilter.php +++ b/application/bookmark/BookmarkFilter.php | |||
@@ -115,7 +115,7 @@ class BookmarkFilter | |||
115 | return $this->filterTags($request, $casesensitive, $visibility); | 115 | return $this->filterTags($request, $casesensitive, $visibility); |
116 | } | 116 | } |
117 | case self::$FILTER_DAY: | 117 | case self::$FILTER_DAY: |
118 | return $this->filterDay($request); | 118 | return $this->filterDay($request, $visibility); |
119 | default: | 119 | default: |
120 | return $this->noFilter($visibility); | 120 | return $this->noFilter($visibility); |
121 | } | 121 | } |
@@ -425,21 +425,26 @@ class BookmarkFilter | |||
425 | * print_r($mydb->filterDay('20120125')); | 425 | * print_r($mydb->filterDay('20120125')); |
426 | * | 426 | * |
427 | * @param string $day day to filter. | 427 | * @param string $day day to filter. |
428 | * | 428 | * @param string $visibility return only all/private/public bookmarks. |
429 | |||
429 | * @return array all link matching given day. | 430 | * @return array all link matching given day. |
430 | * | 431 | * |
431 | * @throws Exception if date format is invalid. | 432 | * @throws Exception if date format is invalid. |
432 | */ | 433 | */ |
433 | public function filterDay($day) | 434 | public function filterDay($day, $visibility) |
434 | { | 435 | { |
435 | if (!checkDateFormat('Ymd', $day)) { | 436 | if (!checkDateFormat('Ymd', $day)) { |
436 | throw new Exception('Invalid date format'); | 437 | throw new Exception('Invalid date format'); |
437 | } | 438 | } |
438 | 439 | ||
439 | $filtered = []; | 440 | $filtered = []; |
440 | foreach ($this->bookmarks as $key => $l) { | 441 | foreach ($this->bookmarks as $key => $bookmark) { |
441 | if ($l->getCreated()->format('Ymd') == $day) { | 442 | if ($visibility === static::$PUBLIC && $bookmark->isPrivate()) { |
442 | $filtered[$key] = $l; | 443 | continue; |
444 | } | ||
445 | |||
446 | if ($bookmark->getCreated()->format('Ymd') == $day) { | ||
447 | $filtered[$key] = $bookmark; | ||
443 | } | 448 | } |
444 | } | 449 | } |
445 | 450 | ||
diff --git a/application/bookmark/BookmarkInitializer.php b/application/bookmark/BookmarkInitializer.php index cd2d1724..815047e3 100644 --- a/application/bookmark/BookmarkInitializer.php +++ b/application/bookmark/BookmarkInitializer.php | |||
@@ -34,25 +34,77 @@ class BookmarkInitializer | |||
34 | public function initialize() | 34 | public function initialize() |
35 | { | 35 | { |
36 | $bookmark = new Bookmark(); | 36 | $bookmark = new Bookmark(); |
37 | $bookmark->setTitle(t('My secret stuff... - Pastebin.com')); | 37 | $bookmark->setTitle('quicksilver (loop) on Vimeo ' . t('(private bookmark with thumbnail demo)')); |
38 | $bookmark->setUrl('http://sebsauvage.net/paste/?8434b27936c09649#bR7XsXhoTiLcqCpQbmOpBi3rq2zzQUC5hBI7ZT1O3x8='); | 38 | $bookmark->setUrl('https://vimeo.com/153493904'); |
39 | $bookmark->setDescription(t('Shhhh! I\'m a private link only YOU can see. You can delete me too.')); | 39 | $bookmark->setDescription(t( |
40 | $bookmark->setTagsString('secretstuff'); | 40 | 'Shaarli will automatically pick up the thumbnail for links to a variety of websites. |
41 | |||
42 | Explore your new Shaarli instance by trying out controls and menus. | ||
43 | Visit the project on [Github](https://github.com/shaarli/Shaarli) or [the documentation](https://shaarli.readthedocs.io/en/master/) to learn more about Shaarli. | ||
44 | |||
45 | Now you can edit or delete the default shaares. | ||
46 | ' | ||
47 | )); | ||
48 | $bookmark->setTagsString('shaarli help thumbnail'); | ||
49 | $bookmark->setPrivate(true); | ||
50 | $this->bookmarkService->add($bookmark, false); | ||
51 | |||
52 | $bookmark = new Bookmark(); | ||
53 | $bookmark->setTitle(t('Note: Shaare descriptions')); | ||
54 | $bookmark->setDescription(t( | ||
55 | 'Adding a shaare without entering a URL creates a text-only "note" post such as this one. | ||
56 | This note is private, so you are the only one able to see it while logged in. | ||
57 | |||
58 | You can use this to keep notes, post articles, code snippets, and much more. | ||
59 | |||
60 | The Markdown formatting setting allows you to format your notes and bookmark description: | ||
61 | |||
62 | ### Title headings | ||
63 | |||
64 | #### Multiple headings levels | ||
65 | * bullet lists | ||
66 | * _italic_ text | ||
67 | * **bold** text | ||
68 | * ~~strike through~~ text | ||
69 | * `code` blocks | ||
70 | * images | ||
71 | * [links](https://en.wikipedia.org/wiki/Markdown) | ||
72 | |||
73 | Markdown also supports tables: | ||
74 | |||
75 | | Name | Type | Color | Qty | | ||
76 | | ------- | --------- | ------ | ----- | | ||
77 | | Orange | Fruit | Orange | 126 | | ||
78 | | Apple | Fruit | Any | 62 | | ||
79 | | Lemon | Fruit | Yellow | 30 | | ||
80 | | Carrot | Vegetable | Red | 14 | | ||
81 | ' | ||
82 | )); | ||
83 | $bookmark->setTagsString('shaarli help'); | ||
41 | $bookmark->setPrivate(true); | 84 | $bookmark->setPrivate(true); |
42 | $this->bookmarkService->add($bookmark, false); | 85 | $this->bookmarkService->add($bookmark, false); |
43 | 86 | ||
44 | $bookmark = new Bookmark(); | 87 | $bookmark = new Bookmark(); |
45 | $bookmark->setTitle(t('The personal, minimalist, super-fast, database free, bookmarking service')); | 88 | $bookmark->setTitle( |
46 | $bookmark->setUrl('https://shaarli.readthedocs.io', []); | 89 | 'Shaarli - ' . t('The personal, minimalist, super-fast, database free, bookmarking service') |
90 | ); | ||
47 | $bookmark->setDescription(t( | 91 | $bookmark->setDescription(t( |
48 | 'Welcome to Shaarli! This is your first public bookmark. ' | 92 | 'Welcome to Shaarli! |
49 | . 'To edit or delete me, you must first login. | 93 | |
94 | Shaarli allows you to bookmark your favorite pages, and share them with others or store them privately. | ||
95 | You can add a description to your bookmarks, such as this one, and tag them. | ||
96 | |||
97 | Create a new shaare by clicking the `+Shaare` button, or using any of the recommended tools (browser extension, mobile app, bookmarklet, REST API, etc.). | ||
50 | 98 | ||
51 | To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page. | 99 | You can easily retrieve your links, even with thousands of them, using the internal search engine, or search through tags (e.g. this Shaare is tagged with `shaarli` and `help`). |
100 | Hashtags such as #shaarli #help are also supported. | ||
101 | You can also filter the available [RSS feed](/feed/atom) and picture wall by tag or plaintext search. | ||
52 | 102 | ||
53 | You use the community supported version of the original Shaarli project, by Sebastien Sauvage.' | 103 | We hope that you will enjoy using Shaarli, maintained with ❤️ by the community! |
104 | Feel free to open [an issue](https://github.com/shaarli/Shaarli/issues) if you have a suggestion or encounter an issue. | ||
105 | ' | ||
54 | )); | 106 | )); |
55 | $bookmark->setTagsString('opensource software'); | 107 | $bookmark->setTagsString('shaarli help'); |
56 | $this->bookmarkService->add($bookmark, false); | 108 | $this->bookmarkService->add($bookmark, false); |
57 | } | 109 | } |
58 | } | 110 | } |
diff --git a/application/bookmark/LinkUtils.php b/application/bookmark/LinkUtils.php index 03e1b82a..faf5dbfd 100644 --- a/application/bookmark/LinkUtils.php +++ b/application/bookmark/LinkUtils.php | |||
@@ -26,7 +26,7 @@ function html_extract_title($html) | |||
26 | */ | 26 | */ |
27 | function header_extract_charset($header) | 27 | function header_extract_charset($header) |
28 | { | 28 | { |
29 | preg_match('/charset="?([^; ]+)/i', $header, $match); | 29 | preg_match('/charset=["\']?([^; "\']+)/i', $header, $match); |
30 | if (! empty($match[1])) { | 30 | if (! empty($match[1])) { |
31 | return strtolower(trim($match[1])); | 31 | return strtolower(trim($match[1])); |
32 | } | 32 | } |