]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | declare(strict_types=1); | |
4 | ||
5 | namespace Shaarli\Bookmark; | |
6 | ||
7 | /** | |
8 | * Class BookmarkInitializer | |
9 | * | |
10 | * This class is used to initialized default bookmarks after a fresh install of Shaarli. | |
11 | * It should be only called if the datastore file does not exist(users might want to delete the default bookmarks). | |
12 | * | |
13 | * To prevent data corruption, it does not overwrite existing bookmarks, | |
14 | * even though there should not be any. | |
15 | * | |
16 | * We disable this because otherwise it creates indentation issues, and heredoc is not supported by PHP gettext. | |
17 | * @phpcs:disable Generic.Files.LineLength.TooLong | |
18 | * | |
19 | * @package Shaarli\Bookmark | |
20 | */ | |
21 | class BookmarkInitializer | |
22 | { | |
23 | /** @var BookmarkServiceInterface */ | |
24 | protected $bookmarkService; | |
25 | ||
26 | /** | |
27 | * BookmarkInitializer constructor. | |
28 | * | |
29 | * @param BookmarkServiceInterface $bookmarkService | |
30 | */ | |
31 | public function __construct(BookmarkServiceInterface $bookmarkService) | |
32 | { | |
33 | $this->bookmarkService = $bookmarkService; | |
34 | } | |
35 | ||
36 | /** | |
37 | * Initialize the data store with default bookmarks | |
38 | */ | |
39 | public function initialize(): void | |
40 | { | |
41 | $bookmark = new Bookmark(); | |
42 | $bookmark->setTitle('Calm Jazz Music - YouTube ' . t('(private bookmark with thumbnail demo)')); | |
43 | $bookmark->setUrl('https://www.youtube.com/watch?v=DVEUcbPkb-c'); | |
44 | $bookmark->setDescription(t( | |
45 | 'Shaarli will automatically pick up the thumbnail for links to a variety of websites. | |
46 | ||
47 | Explore your new Shaarli instance by trying out controls and menus. | |
48 | Visit the project on [Github](https://github.com/shaarli/Shaarli) or [the documentation](https://shaarli.readthedocs.io/en/master/) to learn more about Shaarli. | |
49 | ||
50 | Now you can edit or delete the default shaares. | |
51 | ' | |
52 | )); | |
53 | $bookmark->setTagsString('shaarli help thumbnail'); | |
54 | $bookmark->setPrivate(true); | |
55 | $this->bookmarkService->add($bookmark, false); | |
56 | ||
57 | $bookmark = new Bookmark(); | |
58 | $bookmark->setTitle(t('Note: Shaare descriptions')); | |
59 | $bookmark->setDescription(t( | |
60 | 'Adding a shaare without entering a URL creates a text-only "note" post such as this one. | |
61 | This note is private, so you are the only one able to see it while logged in. | |
62 | ||
63 | You can use this to keep notes, post articles, code snippets, and much more. | |
64 | ||
65 | The Markdown formatting setting allows you to format your notes and bookmark description: | |
66 | ||
67 | ### Title headings | |
68 | ||
69 | #### Multiple headings levels | |
70 | * bullet lists | |
71 | * _italic_ text | |
72 | * **bold** text | |
73 | * ~~strike through~~ text | |
74 | * `code` blocks | |
75 | * images | |
76 | * [links](https://en.wikipedia.org/wiki/Markdown) | |
77 | ||
78 | Markdown also supports tables: | |
79 | ||
80 | | Name | Type | Color | Qty | | |
81 | | ------- | --------- | ------ | ----- | | |
82 | | Orange | Fruit | Orange | 126 | | |
83 | | Apple | Fruit | Any | 62 | | |
84 | | Lemon | Fruit | Yellow | 30 | | |
85 | | Carrot | Vegetable | Red | 14 | | |
86 | ' | |
87 | )); | |
88 | $bookmark->setTagsString('shaarli help'); | |
89 | $bookmark->setPrivate(true); | |
90 | $this->bookmarkService->add($bookmark, false); | |
91 | ||
92 | $bookmark = new Bookmark(); | |
93 | $bookmark->setTitle( | |
94 | 'Shaarli - ' . t('The personal, minimalist, super-fast, database free, bookmarking service') | |
95 | ); | |
96 | $bookmark->setDescription(t( | |
97 | 'Welcome to Shaarli! | |
98 | ||
99 | Shaarli allows you to bookmark your favorite pages, and share them with others or store them privately. | |
100 | You can add a description to your bookmarks, such as this one, and tag them. | |
101 | ||
102 | Create a new shaare by clicking the `+Shaare` button, or using any of the recommended tools (browser extension, mobile app, bookmarklet, REST API, etc.). | |
103 | ||
104 | 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`). | |
105 | Hashtags such as #shaarli #help are also supported. | |
106 | You can also filter the available [RSS feed](/feed/atom) and picture wall by tag or plaintext search. | |
107 | ||
108 | We hope that you will enjoy using Shaarli, maintained with ❤️ by the community! | |
109 | Feel free to open [an issue](https://github.com/shaarli/Shaarli/issues) if you have a suggestion or encounter an issue. | |
110 | ' | |
111 | )); | |
112 | $bookmark->setTagsString('shaarli help'); | |
113 | $this->bookmarkService->add($bookmark, false); | |
114 | } | |
115 | } |