From: ArthurHoaro Date: Thu, 5 Nov 2020 16:54:14 +0000 (+0100) Subject: Merge pull request #1626 from ArthurHoaro/fix/vintage-webpack X-Git-Tag: v0.12.1^2~11 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=48df9f45b8c4b2995c1e04146071628668531b37;hp=c61d8a85b7a8cb424e347625923d3293d334d3b0;p=github%2Fshaarli%2FShaarli.git Merge pull request #1626 from ArthurHoaro/fix/vintage-webpack Webpack: fix vintage theme images include --- diff --git a/application/bookmark/LinkUtils.php b/application/bookmark/LinkUtils.php index faf5dbfd..17c37979 100644 --- a/application/bookmark/LinkUtils.php +++ b/application/bookmark/LinkUtils.php @@ -138,12 +138,17 @@ function space2nbsp($text) * * @param string $description shaare's description. * @param string $indexUrl URL to Shaarli's index. - + * @param bool $autolink Turn on/off automatic linkifications of URLs and hashtags + * * @return string formatted description. */ -function format_description($description, $indexUrl = '') +function format_description($description, $indexUrl = '', $autolink = true) { - return nl2br(space2nbsp(hashtag_autolink(text2clickable($description), $indexUrl))); + if ($autolink) { + $description = hashtag_autolink(text2clickable($description), $indexUrl); + } + + return nl2br(space2nbsp($description)); } /** diff --git a/application/formatter/BookmarkDefaultFormatter.php b/application/formatter/BookmarkDefaultFormatter.php index d58a5e39..149a3eb9 100644 --- a/application/formatter/BookmarkDefaultFormatter.php +++ b/application/formatter/BookmarkDefaultFormatter.php @@ -46,8 +46,13 @@ class BookmarkDefaultFormatter extends BookmarkFormatter $bookmark->getDescription() ?? '', $bookmark->getAdditionalContentEntry('search_highlight')['description'] ?? [] ); + $description = format_description( + escape($description), + $indexUrl, + $this->conf->get('formatter_settings.autolink', true) + ); - return $this->replaceTokens(format_description(escape($description), $indexUrl)); + return $this->replaceTokens($description); } /** diff --git a/application/front/controller/admin/ShaareManageController.php b/application/front/controller/admin/ShaareManageController.php index 7ceb8d8a..2ed298f5 100644 --- a/application/front/controller/admin/ShaareManageController.php +++ b/application/front/controller/admin/ShaareManageController.php @@ -66,8 +66,8 @@ class ShaareManageController extends ShaarliAdminController return $response->write(''); } - // Don't redirect to where we were previously because the datastore has changed. - return $this->redirect($response, '/'); + // Don't redirect to permalink after deletion. + return $this->redirectFromReferer($request, $response, ['shaare/']); } /** diff --git a/assets/default/js/base.js b/assets/default/js/base.js index 4163577d..66badfb2 100644 --- a/assets/default/js/base.js +++ b/assets/default/js/base.js @@ -294,7 +294,8 @@ function init(description) { const deleteLinks = document.querySelectorAll('.confirm-delete'); [...deleteLinks].forEach((deleteLink) => { deleteLink.addEventListener('click', (event) => { - if (!confirm(document.getElementById('translation-delete-tag').innerHTML)) { + const type = event.currentTarget.getAttribute('data-type') || 'link'; + if (!confirm(document.getElementById(`translation-delete-${type}`).innerHTML)) { event.preventDefault(); } }); diff --git a/doc/md/Shaarli-configuration.md b/doc/md/Shaarli-configuration.md index dbfc3da9..99084728 100644 --- a/doc/md/Shaarli-configuration.md +++ b/doc/md/Shaarli-configuration.md @@ -164,6 +164,22 @@ _These settings should not be edited_ - **trusted_proxies**: List of trusted IP which won't be banned after failed login attemps. Useful if Shaarli is behind a reverse proxy. - **allowed_protocols**: List of allowed protocols in shaare URLs or markdown-rendered descriptions. Useful if you want to store `javascript:` links (bookmarklets) in Shaarli (default: `["ftp", "ftps", "magnet"]`). +### Formatter + +Single string value. Default available: + + - `default`: supports line breaks, URL and hashtag auto-links. + - `markdown`: supports [Markdown](https://daringfireball.net/projects/markdown/syntax). + - `markdownExtra`: adds [extra](https://michelf.ca/projects/php-markdown/extra/) flavor to Markdown. + +### Formatter Settings + +Additional settings applied to formatters. + +#### default + + - **autolink**: boolean to enable or disable automatic linkification of URL and hashtags. + ### Resources - **data_dir**: Data directory. diff --git a/inc/languages/fr/LC_MESSAGES/shaarli.po b/inc/languages/fr/LC_MESSAGES/shaarli.po index 60ea7a97..4c363fa8 100644 --- a/inc/languages/fr/LC_MESSAGES/shaarli.po +++ b/inc/languages/fr/LC_MESSAGES/shaarli.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Shaarli\n" -"POT-Creation-Date: 2020-10-27 19:44+0100\n" -"PO-Revision-Date: 2020-10-27 19:44+0100\n" +"POT-Creation-Date: 2020-11-05 16:47+0100\n" +"PO-Revision-Date: 2020-11-05 16:48+0100\n" "Last-Translator: \n" "Language-Team: Shaarli\n" "Language: fr_FR\n" @@ -189,9 +189,9 @@ msgstr "" #: application/bookmark/BookmarkInitializer.php:91 #: application/legacy/LegacyLinkDB.php:246 #: tmp/page.footer.b91ef64efc3688266305ea9b42e5017e.rtpl.php:15 -#: tmp/page.footer.b91ef64efc3688266305ea9b42e5017e.rtpl.php:49 +#: tmp/page.footer.b91ef64efc3688266305ea9b42e5017e.rtpl.php:50 #: tmp/page.footer.cedf684561d925457130839629000a81.rtpl.php:15 -#: tmp/page.footer.cedf684561d925457130839629000a81.rtpl.php:49 +#: tmp/page.footer.cedf684561d925457130839629000a81.rtpl.php:50 msgid "" "The personal, minimalist, super-fast, database free, bookmarking service" msgstr "" @@ -347,16 +347,6 @@ msgstr "" "le serveur web peut accepter (%s). Merci de l'envoyer en parties plus " "légères." -#: application/front/controller/admin/ManageShaareController.php:64 -#: application/front/controller/admin/ManageShaareController.php:95 -#: application/front/controller/admin/ManageShaareController.php:193 -#: application/front/controller/admin/ManageShaareController.php:262 -#: application/front/controller/admin/ManageShaareController.php:302 -#: application/front/controller/admin/ManageShaareController.php:181 -#: application/front/controller/admin/ManageShaareController.php:239 -#: application/front/controller/admin/ManageShaareController.php:247 -#: application/front/controller/admin/ManageShaareController.php:378 -#: application/front/controller/admin/ManageShaareController.php:381 #: application/front/controller/admin/ManageTagController.php:29 #: tmp/changetag.b91ef64efc3688266305ea9b42e5017e.rtpl.php:13 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:42 @@ -429,6 +419,20 @@ msgstr "Le cache des miniatures a été vidé." msgid "Shaarli's cache folder has been cleared!" msgstr "Le dossier de cache de Shaarli a été vidé !" +#: application/front/controller/admin/ShaareAddController.php:26 +#: tmp/addlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:13 +msgid "Shaare a new link" +msgstr "Partagez un nouveau lien" + +#: application/front/controller/admin/ShaareManageController.php:35 +#: application/front/controller/admin/ShaareManageController.php:93 +msgid "Invalid bookmark ID provided." +msgstr "L'ID du marque-page fourni n'est pas valide." + +#: application/front/controller/admin/ShaareManageController.php:47 +#: application/front/controller/admin/ShaareManageController.php:116 +#: application/front/controller/admin/ShaareManageController.php:156 +#: application/front/controller/admin/ShaarePublishController.php:82 #, php-format msgid "Bookmark with identifier %s could not be found." msgstr "Le lien avec l'identifiant %s n'a pas pu être trouvé." @@ -437,18 +441,18 @@ msgstr "Le lien avec l'identifiant %s n'a pas pu être trouvé." msgid "Invalid visibility provided." msgstr "Visibilité du lien non valide." -#: application/front/controller/admin/ShaarePublishController.php:154 +#: application/front/controller/admin/ShaarePublishController.php:168 #: tmp/linklist.b91ef64efc3688266305ea9b42e5017e.rtpl.php:171 msgid "Edit" msgstr "Modifier" -#: application/front/controller/admin/ShaarePublishController.php:157 +#: application/front/controller/admin/ShaarePublishController.php:171 #: tmp/page.header.b91ef64efc3688266305ea9b42e5017e.rtpl.php:28 #: tmp/page.header.cedf684561d925457130839629000a81.rtpl.php:28 msgid "Shaare" msgstr "Shaare" -#: application/front/controller/admin/ShaarePublishController.php:184 +#: application/front/controller/admin/ShaarePublishController.php:202 msgid "Note: " msgstr "Note : " @@ -905,7 +909,7 @@ msgstr "Mauvaise réponse du hub %s" msgid "Enable PubSubHubbub feed publishing." msgstr "Active la publication de flux vers PubSubHubbub." -#: plugins/qrcode/qrcode.php:73 plugins/wallabag/wallabag.php:70 +#: plugins/qrcode/qrcode.php:73 plugins/wallabag/wallabag.php:71 msgid "For each link, add a QRCode icon." msgstr "Pour chaque lien, ajouter une icône de QRCode." @@ -917,15 +921,15 @@ msgstr "" "Erreur de l'extension Wallabag : Merci de définir le paramètre « " "WALLABAG_URL » dans la page d'administration des extensions." -#: plugins/wallabag/wallabag.php:47 +#: plugins/wallabag/wallabag.php:48 msgid "Save to wallabag" msgstr "Sauvegarder dans Wallabag" -#: plugins/wallabag/wallabag.php:71 +#: plugins/wallabag/wallabag.php:72 msgid "Wallabag API URL" msgstr "URL de l'API Wallabag" -#: plugins/wallabag/wallabag.php:72 +#: plugins/wallabag/wallabag.php:73 msgid "Wallabag API version (1 or 2)" msgstr "Version de l'API Wallabag (1 ou 2)" @@ -1013,11 +1017,11 @@ msgstr "Renommer le tag" msgid "Delete tag" msgstr "Supprimer le tag" -#: tmp/changetag.b91ef64efc3688266305ea9b42e5017e.rtpl.php:39 +#: tmp/changetag.b91ef64efc3688266305ea9b42e5017e.rtpl.php:40 msgid "You can also edit tags in the" msgstr "Vous pouvez aussi modifier les tags dans la" -#: tmp/changetag.b91ef64efc3688266305ea9b42e5017e.rtpl.php:39 +#: tmp/changetag.b91ef64efc3688266305ea9b42e5017e.rtpl.php:40 msgid "tag list" msgstr "liste des tags" @@ -1165,7 +1169,7 @@ msgid "None" msgstr "Aucune" #: tmp/configure.b91ef64efc3688266305ea9b42e5017e.rtpl.php:355 -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:102 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:121 #: tmp/pluginsadmin.b91ef64efc3688266305ea9b42e5017e.rtpl.php:139 #: tmp/pluginsadmin.b91ef64efc3688266305ea9b42e5017e.rtpl.php:199 msgid "Save" @@ -1196,27 +1200,27 @@ msgid_plural "" msgstr[0] ":type suivant" msgstr[1] "" -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:21 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:30 msgid "Edit Shaare" msgstr "Modifier le Shaare" -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:21 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:30 msgid "New Shaare" msgstr "Nouveau Shaare" -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:29 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:38 msgid "Created:" msgstr "Création :" -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:32 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:41 msgid "URL" msgstr "URL" -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:38 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:47 msgid "Title" msgstr "Titre" -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:49 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:58 #: tmp/pluginsadmin.b91ef64efc3688266305ea9b42e5017e.rtpl.php:42 #: tmp/pluginsadmin.b91ef64efc3688266305ea9b42e5017e.rtpl.php:75 #: tmp/pluginsadmin.b91ef64efc3688266305ea9b42e5017e.rtpl.php:99 @@ -1224,21 +1228,19 @@ msgstr "Titre" msgid "Description" msgstr "Description" -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:58 -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:74 -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:80 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:89 msgid "Description will be rendered with" msgstr "La description sera générée avec" -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:82 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:91 msgid "Markdown syntax documentation" msgstr "Documentation sur la syntaxe Markdown" -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:83 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:92 msgid "Markdown syntax" msgstr "la syntaxe Markdown" -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:102 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:115 msgid "Cancel" msgstr "Annuler" @@ -1246,12 +1248,7 @@ msgstr "Annuler" msgid "Apply Changes" msgstr "Appliquer les changements" -#: tmp/editlink.batch.b91ef64efc3688266305ea9b42e5017e.rtpl.php:12 -#: tmp/editlink.batch.b91ef64efc3688266305ea9b42e5017e.rtpl.php:23 -msgid "Save all" -msgstr "Tout enregistrer" - -#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:107 +#: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:126 #: tmp/linklist.b91ef64efc3688266305ea9b42e5017e.rtpl.php:173 #: tmp/page.header.b91ef64efc3688266305ea9b42e5017e.rtpl.php:147 #: tmp/page.header.cedf684561d925457130839629000a81.rtpl.php:147 @@ -1259,6 +1256,11 @@ msgstr "Tout enregistrer" msgid "Delete" msgstr "Supprimer" +#: tmp/editlink.batch.b91ef64efc3688266305ea9b42e5017e.rtpl.php:21 +#: tmp/editlink.batch.b91ef64efc3688266305ea9b42e5017e.rtpl.php:32 +msgid "Save all" +msgstr "Tout enregistrer" + #: tmp/export.b91ef64efc3688266305ea9b42e5017e.rtpl.php:16 msgid "Export Database" msgstr "Exporter les données" @@ -1472,7 +1474,7 @@ msgstr "Afficher uniquement les liens publics" #: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:18 #: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:18 msgid "Filter untagged links" -msgstr "Filtrer par liens privés" +msgstr "Filtrer par liens sans tag" #: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:24 #: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:24 @@ -1500,9 +1502,9 @@ msgid "Remember me" msgstr "Rester connecté" #: tmp/page.footer.b91ef64efc3688266305ea9b42e5017e.rtpl.php:15 -#: tmp/page.footer.b91ef64efc3688266305ea9b42e5017e.rtpl.php:49 +#: tmp/page.footer.b91ef64efc3688266305ea9b42e5017e.rtpl.php:50 #: tmp/page.footer.cedf684561d925457130839629000a81.rtpl.php:15 -#: tmp/page.footer.cedf684561d925457130839629000a81.rtpl.php:49 +#: tmp/page.footer.cedf684561d925457130839629000a81.rtpl.php:50 msgid "by the Shaarli community" msgstr "par la communauté Shaarli" @@ -1523,6 +1525,11 @@ msgstr "Déplier tout" #: tmp/page.footer.b91ef64efc3688266305ea9b42e5017e.rtpl.php:47 #: tmp/page.footer.cedf684561d925457130839629000a81.rtpl.php:47 +msgid "Are you sure you want to delete this link?" +msgstr "Êtes-vous sûr de vouloir supprimer ce lien ?" + +#: tmp/page.footer.b91ef64efc3688266305ea9b42e5017e.rtpl.php:48 +#: tmp/page.footer.cedf684561d925457130839629000a81.rtpl.php:48 msgid "Are you sure you want to delete this tag?" msgstr "Êtes-vous sûr de vouloir supprimer ce tag ?" diff --git a/tests/formatter/BookmarkDefaultFormatterTest.php b/tests/formatter/BookmarkDefaultFormatterTest.php index 3fc6f8dc..4fcc5dd1 100644 --- a/tests/formatter/BookmarkDefaultFormatterTest.php +++ b/tests/formatter/BookmarkDefaultFormatterTest.php @@ -289,4 +289,24 @@ class BookmarkDefaultFormatterTest extends TestCase $link['taglist_html'] ); } + + /** + * Test default formatting with formatter_settings.autolink set to false: + * URLs and hashtags should not be transformed + */ + public function testFormatDescriptionWithoutLinkification(): void + { + $this->conf->set('formatter_settings.autolink', false); + $this->formatter = new BookmarkDefaultFormatter($this->conf, false); + + $bookmark = new Bookmark(); + $bookmark->setDescription('Hi!' . PHP_EOL . 'https://thisisaurl.tld #hashtag'); + + $link = $this->formatter->format($bookmark); + + static::assertSame( + 'Hi!
' . PHP_EOL . 'https://thisisaurl.tld  #hashtag', + $link['description'] + ); + } } diff --git a/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php b/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php index 770a16d7..a276d988 100644 --- a/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php +++ b/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php @@ -38,6 +38,8 @@ class DeleteBookmarkTest extends TestCase { $parameters = ['id' => '123']; + $this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/shaare/abcdef'; + $request = $this->createMock(Request::class); $request ->method('getParam') @@ -90,6 +92,8 @@ class DeleteBookmarkTest extends TestCase { $parameters = ['id' => '123 456 789']; + $this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/?searchtags=abcdef'; + $request = $this->createMock(Request::class); $request ->method('getParam') @@ -152,7 +156,7 @@ class DeleteBookmarkTest extends TestCase $result = $this->controller->deleteBookmark($request, $response); static::assertSame(302, $result->getStatusCode()); - static::assertSame(['/subfolder/'], $result->getHeader('location')); + static::assertSame(['/subfolder/?searchtags=abcdef'], $result->getHeader('location')); } /** diff --git a/tpl/default/changetag.html b/tpl/default/changetag.html index 89d08e2c..a5fbd31e 100644 --- a/tpl/default/changetag.html +++ b/tpl/default/changetag.html @@ -28,7 +28,8 @@
- +
diff --git a/tpl/default/page.footer.html b/tpl/default/page.footer.html index c153def0..964ffff1 100644 --- a/tpl/default/page.footer.html +++ b/tpl/default/page.footer.html @@ -28,12 +28,13 @@ {/loop} -