]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - application/bookmark/BookmarkInitializer.php
Manually fix remaining PHPCS errors
[github/shaarli/Shaarli.git] / application / bookmark / BookmarkInitializer.php
CommitLineData
336a28fa
A
1<?php
2
efb7d21b
A
3declare(strict_types=1);
4
336a28fa
A
5namespace Shaarli\Bookmark;
6
7/**
8 * Class BookmarkInitializer
9 *
10 * This class is used to initialized default bookmarks after a fresh install of Shaarli.
d6e5f04d 11 * It should be only called if the datastore file does not exist(users might want to delete the default bookmarks).
336a28fa
A
12 *
13 * To prevent data corruption, it does not overwrite existing bookmarks,
14 * even though there should not be any.
15 *
b99e00f7
A
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 *
336a28fa
A
19 * @package Shaarli\Bookmark
20 */
21class BookmarkInitializer
22{
23 /** @var BookmarkServiceInterface */
24 protected $bookmarkService;
25
26 /**
27 * BookmarkInitializer constructor.
28 *
29 * @param BookmarkServiceInterface $bookmarkService
30 */
efb7d21b 31 public function __construct(BookmarkServiceInterface $bookmarkService)
336a28fa
A
32 {
33 $this->bookmarkService = $bookmarkService;
34 }
35
36 /**
37 * Initialize the data store with default bookmarks
38 */
efb7d21b 39 public function initialize(): void
336a28fa
A
40 {
41 $bookmark = new Bookmark();
9952de2f
A
42 $bookmark->setTitle('Calm Jazz Music - YouTube ' . t('(private bookmark with thumbnail demo)'));
43 $bookmark->setUrl('https://www.youtube.com/watch?v=DVEUcbPkb-c');
da7acb98 44 $bookmark->setDescription(t(
53054b2b 45 'Shaarli will automatically pick up the thumbnail for links to a variety of websites.
da7acb98
A
46
47Explore your new Shaarli instance by trying out controls and menus.
48Visit the project on [Github](https://github.com/shaarli/Shaarli) or [the documentation](https://shaarli.readthedocs.io/en/master/) to learn more about Shaarli.
49
50Now 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(
53054b2b 60 'Adding a shaare without entering a URL creates a text-only "note" post such as this one.
da7acb98
A
61This note is private, so you are the only one able to see it while logged in.
62
63You can use this to keep notes, post articles, code snippets, and much more.
64
65The 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
78Markdown 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');
336a28fa 89 $bookmark->setPrivate(true);
c4ad3d4f 90 $this->bookmarkService->add($bookmark, false);
336a28fa
A
91
92 $bookmark = new Bookmark();
da7acb98
A
93 $bookmark->setTitle(
94 'Shaarli - ' . t('The personal, minimalist, super-fast, database free, bookmarking service')
95 );
336a28fa 96 $bookmark->setDescription(t(
53054b2b 97 'Welcome to Shaarli!
da7acb98
A
98
99Shaarli allows you to bookmark your favorite pages, and share them with others or store them privately.
100You can add a description to your bookmarks, such as this one, and tag them.
101
102Create a new shaare by clicking the `+Shaare` button, or using any of the recommended tools (browser extension, mobile app, bookmarklet, REST API, etc.).
336a28fa 103
da7acb98
A
104You 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`).
105Hashtags such as #shaarli #help are also supported.
106You can also filter the available [RSS feed](/feed/atom) and picture wall by tag or plaintext search.
336a28fa 107
da7acb98
A
108We hope that you will enjoy using Shaarli, maintained with ❤️ by the community!
109Feel free to open [an issue](https://github.com/shaarli/Shaarli/issues) if you have a suggestion or encounter an issue.
110'
336a28fa 111 ));
da7acb98 112 $bookmark->setTagsString('shaarli help');
c4ad3d4f 113 $this->bookmarkService->add($bookmark, false);
336a28fa
A
114 }
115}