]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1626 from ArthurHoaro/fix/vintage-webpack
authorArthurHoaro <arthur@hoa.ro>
Thu, 5 Nov 2020 16:54:14 +0000 (17:54 +0100)
committerGitHub <noreply@github.com>
Thu, 5 Nov 2020 16:54:14 +0000 (17:54 +0100)
Webpack: fix vintage theme images include

application/bookmark/LinkUtils.php
application/formatter/BookmarkDefaultFormatter.php
application/front/controller/admin/ShaareManageController.php
assets/default/js/base.js
doc/md/Shaarli-configuration.md
inc/languages/fr/LC_MESSAGES/shaarli.po
tests/formatter/BookmarkDefaultFormatterTest.php
tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php
tpl/default/changetag.html
tpl/default/page.footer.html

index faf5dbfd4fe24906bf980d8f4cc72e0472b7e008..17c379796cd39b239be09459d78e3cad22fdfb0b 100644 (file)
@@ -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));
 }
 
 /**
index d58a5e39dde46ca5f5f0c71ac80e1f60fde8e55b..149a3eb9fc854fed6404859eb6b51083b995703a 100644 (file)
@@ -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);
     }
 
     /**
index 7ceb8d8a3584e046c94c51c6999e39a5974bf3dc..2ed298f5e4cefb163371bf372df7eeb5c7241c7e 100644 (file)
@@ -66,8 +66,8 @@ class ShaareManageController extends ShaarliAdminController
             return $response->write('<script>self.close();</script>');
         }
 
-        // 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/']);
     }
 
     /**
index 4163577d0da527d3d1d7b91c3c1eb830bfda4cea..66badfb265eeacbe3acfcadf292b63701506a407 100644 (file)
@@ -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();
       }
     });
index dbfc3da953fc220bfccaa86bb8fc33454933c123..9908472804d889d3e375aac1ed02ba0355f3e223 100644 (file)
@@ -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.
index 60ea7a970660161050c1df4cbd1faa2c11446112..4c363fa8669a5f46f6317de81de6a41cb2170d12 100644 (file)
@@ -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 ?"
 
index 3fc6f8dc58f4c8f38e877f1c49c18d2d083cbcde..4fcc5dd19cc35356498f6acc7270b80ad4aef9bc 100644 (file)
@@ -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!<br />' . PHP_EOL . 'https://thisisaurl.tld &nbsp;#hashtag',
+            $link['description']
+        );
+    }
 }
index 770a16d7c543b70c1265ec90d85b2348e969661e..a276d988f0d1993c7278cbbf30debdab02055e17 100644 (file)
@@ -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'));
     }
 
     /**
index 89d08e2cab7e16c9a2658a17b6093e72476d896c..a5fbd31e4952ff723900b837dd81d0c2978c8020 100644 (file)
@@ -28,7 +28,8 @@
       <input type="hidden" name="token" value="{$token}">
       <div>
         <input type="submit" value="{'Rename tag'|t}" name="renametag">
-        <input type="submit" value="{'Delete tag'|t}" name="deletetag" class="button button-red confirm-delete">
+        <input type="submit" value="{'Delete tag'|t}" name="deletetag"
+               class="button button-red confirm-delete" data-type="tag">
       </div>
     </form>
 
index c153def0450419477dccc8c56cf19c3f146f35e8..964ffff110b210f12a77fe588ddddd05b4bf5588 100644 (file)
        <script src="{$root_path}/{$value}#"></script>
 {/loop}
 
-<div id="js-translations" class="hidden">
+<div id="js-translations" class="hidden" aria-hidden="true">
   <span id="translation-fold">{'Fold'|t}</span>
   <span id="translation-fold-all">{'Fold all'|t}</span>
   <span id="translation-expand">{'Expand'|t}</span>
   <span id="translation-expand-all">{'Expand all'|t}</span>
-  <span id="translation-delete-link">{'Are you sure you want to delete this tag?'|t}</span>
+  <span id="translation-delete-link">{'Are you sure you want to delete this link?'|t}</span>
+  <span id="translation-delete-tag">{'Are you sure you want to delete this tag?'|t}</span>
   <span id="translation-shaarli-desc">
     {'The personal, minimalist, super-fast, database free, bookmarking service'|t} {'by the Shaarli community'|t}
   </span>