]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1207 from ArthurHoaro/feature/cors
authorArthurHoaro <arthur@hoa.ro>
Thu, 20 Sep 2018 21:34:59 +0000 (23:34 +0200)
committerGitHub <noreply@github.com>
Thu, 20 Sep 2018 21:34:59 +0000 (23:34 +0200)
Add CORS headers to REST API responses

assets/default/js/base.js
assets/default/scss/shaarli.scss
inc/languages/fr/LC_MESSAGES/shaarli.po
index.php
plugins/isso/comment.png [new file with mode: 0644]
plugins/isso/isso.php
plugins/isso/isso_button.html [new file with mode: 0644]
tests/plugins/PluginIssoTest.php

index 8bf79d3e4c612efac7e815ca421b3c2acff14023..1b8d8c36fa33d603a78232495e6e612d92eb6879 100644 (file)
@@ -548,7 +548,7 @@ function init(description) {
       event.preventDefault();
       const block = findParent(event.target, 'div', { class: 'tag-list-item' });
       const tag = block.getAttribute('data-tag');
-      const refreshedToken = document.getElementById('token');
+      const refreshedToken = document.getElementById('token').value;
 
       if (confirm(`Are you sure you want to delete the tag "${tag}"?`)) {
         const xhr = new XMLHttpRequest();
index 6b286f1ecdebdea0893f6a33ea04da1073472c52..b8578ea6869855b907c5d89ae963e938ecb864a0 100644 (file)
@@ -381,8 +381,6 @@ body,
   box-shadow: 0 1px 0 $light-shadow, 0 1px 4px $dark-shadow inset;
   background: $almost-white;
   padding: 5px 5px 3px 15px;
-  width: 20%;
-  height: 20px;
   color: $dark-grey;
 }
 
index 155eb52ee2de3c71c5ca8f0ca6d2689d09baba7c..5fd0f7755e01a79c51ca07f4893b580935cf70f2 100644 (file)
@@ -48,7 +48,7 @@ msgstr "le fichier n'est pas accessible en écriture"
 #: application/Cache.php:16
 #, php-format
 msgid "Cannot purge %s: no directory"
-msgstr "Impossible de purger %s: le répertoire n'existe pas"
+msgstr "Impossible de purger %s : le répertoire n'existe pas"
 
 #: application/FeedBuilder.php:151
 msgid "Direct link"
@@ -98,7 +98,7 @@ msgstr "Vous devez utiliser un entier comme clé."
 
 #: application/LinkDB.php:145
 msgid "Array offset and link ID must be equal."
-msgstr "La clé du tableau et l'ID du lien doivent être égaux."
+msgstr "La clé du tableau et l'ID du lien doivent être identiques."
 
 #: application/LinkDB.php:251
 #: tmp/page.footer.b91ef64efc3688266305ea9b42e5017e.rtpl.php:14
@@ -108,7 +108,7 @@ msgstr "La clé du tableau et l'ID du lien doivent être égaux."
 msgid ""
 "The personal, minimalist, super-fast, database free, bookmarking service"
 msgstr ""
-"Le gestionnaire de marque-page personnel, minimaliste, et sans base de "
+"Le gestionnaire de marque-pages personnel, minimaliste, et sans base de "
 "données"
 
 #: application/LinkDB.php:253
@@ -125,11 +125,11 @@ msgstr ""
 "Bienvenue sur Shaarli ! Ceci est votre premier marque-page public. Pour me "
 "modifier ou me supprimer, vous devez d'abord vous connecter.\n"
 "\n"
-"Pour apprendre comment utiliser Shaarli, consultez le lien « Documentation » "
+"Pour apprendre à utiliser Shaarli, consultez le lien « Documentation » "
 "en bas de page.\n"
 "\n"
 "Vous utilisez la version supportée par la communauté du projet original "
-"Shaarli, de Sébastien Sauvage."
+"Shaarli de Sébastien Sauvage."
 
 #: application/LinkDB.php:267
 msgid "My secret stuff... - Pastebin.com"
@@ -185,8 +185,8 @@ msgid ""
 "php-gd extension must be loaded to use thumbnails. Thumbnails are now "
 "disabled. Please reload the page."
 msgstr ""
-"php-gd extension must be loaded to use thumbnails. Thumbnails are now "
-"disabled. Please reload the page."
+"l'extension php-gd doit être chargée pour utiliser les miniatures. Les miniatures sont désormais "
+"désactivées. Rechargez la page."
 
 #: application/Updater.php:86
 msgid "Couldn't retrieve Updater class methods."
@@ -286,7 +286,7 @@ msgstr "NON. Vous êtes banni pour le moment. Revenez plus tard."
 
 #: index.php:273
 msgid "Wrong login/password."
-msgstr "Nom d'utilisateur ou mot de passe incorrects."
+msgstr "Nom d'utilisateur ou mot de passe incorrect(s)."
 
 #: index.php:483 tmp/page.header.b91ef64efc3688266305ea9b42e5017e.rtpl.php:46
 #: tmp/page.header.cedf684561d925457130839629000a81.rtpl.php:46
@@ -343,11 +343,11 @@ msgstr "Votre mot de passe a été modifié"
 #: tmp/changepassword.b91ef64efc3688266305ea9b42e5017e.rtpl.php:13
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:29
 msgid "Change password"
-msgstr "Modification du mot de passe"
+msgstr "Modifier le mot de passe"
 
 #: index.php:1043
 msgid "Configuration was saved."
-msgstr "La configuration a été sauvegardé."
+msgstr "La configuration a été sauvegardée."
 
 #: index.php:1068 tmp/configure.b91ef64efc3688266305ea9b42e5017e.rtpl.php:24
 msgid "Configure"
@@ -411,7 +411,7 @@ msgstr ""
 #: index.php:1471 tmp/pluginsadmin.b91ef64efc3688266305ea9b42e5017e.rtpl.php:26
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:22
 msgid "Plugin administration"
-msgstr "Administration des extensions"
+msgstr "Administration des plugins"
 
 #: index.php:1523 tmp/thumbnails.b91ef64efc3688266305ea9b42e5017e.rtpl.php:14
 msgid "Thumbnails update"
@@ -431,9 +431,9 @@ msgid ""
 "custom hostname without a dot causes cookie storage to fail. We recommend "
 "accessing your server via it's IP address or Fully Qualified Domain Name.<br>"
 msgstr ""
-"<pre>Les sesssions ne semble pas fonctionner sur ce serveur.<br>Assurez vous "
+"<pre>Les sesssions ne semblent pas fonctionner sur ce serveur.<br>Assurez vous "
 "que la variable « session.save_path » est correctement définie dans votre "
-"fichier de configuration PHP, et que vous y avez les droits d'écriture."
+"fichier de configuration PHP, et que vous avez les droits d'écriture dessus."
 "<br>Ce paramètre pointe actuellement sur %s.<br>Sur certains navigateurs, "
 "accéder à votre serveur depuis un nom d'hôte comme « localhost » ou autre "
 "nom personnalisé sans point '.' entraine l'échec de la sauvegarde des "
@@ -455,7 +455,7 @@ msgstr "Shaare"
 
 #: plugins/addlink_toolbar/addlink_toolbar.php:50
 msgid "Adds the addlink input on the linklist page."
-msgstr "Ajout le formulaire d'ajout de liens sur la page principale."
+msgstr "Ajoute le formulaire d'ajout de liens sur la page principale."
 
 #: plugins/archiveorg/archiveorg.php:23
 msgid "View on archive.org"
@@ -471,7 +471,7 @@ msgid ""
 "developers."
 msgstr ""
 "Une extension de démonstration couvrant tous les cas d'utilisation pour les "
-"designers et les développeurs."
+"designers de thèmes et les développeurs d'extensions."
 
 #: plugins/isso/isso.php:20
 msgid ""
@@ -484,7 +484,7 @@ msgstr ""
 #: plugins/isso/isso.php:63
 msgid "Let visitor comment your shaares on permalinks with Isso."
 msgstr ""
-"Permet aux visiteurs de commenter vos shaares sur les permaliens avec Isso."
+"Permettre aux visiteurs de commenter vos shaares sur les permaliens avec Isso."
 
 #: plugins/isso/isso.php:64
 msgid "Isso server URL (without 'http://')"
@@ -578,7 +578,7 @@ msgstr "Active la publication de flux vers PubSubHubbub."
 
 #: plugins/qrcode/qrcode.php:69 plugins/wallabag/wallabag.php:68
 msgid "For each link, add a QRCode icon."
-msgstr "Pour chaque liens, ajouter une icône de QRCode."
+msgstr "Pour chaque lien, ajouter une icône de QRCode."
 
 #: plugins/wallabag/wallabag.php:21
 msgid ""
@@ -752,7 +752,7 @@ msgstr "Activer l'API REST"
 #: tmp/install.b91ef64efc3688266305ea9b42e5017e.rtpl.php:170
 msgid "Allow third party software to use Shaarli such as mobile application"
 msgstr ""
-"Permets aux applications tierces d'utiliser Shaarli, par exemple les "
+"Permet aux applications tierces d'utiliser Shaarli, par exemple les "
 "applications mobiles"
 
 #: tmp/configure.b91ef64efc3688266305ea9b42e5017e.rtpl.php:263
@@ -854,7 +854,7 @@ msgstr "Privé"
 
 #: tmp/editlink.b91ef64efc3688266305ea9b42e5017e.rtpl.php:72
 msgid "Apply Changes"
-msgstr "Appliquer"
+msgstr "Appliquer les changements"
 
 #: tmp/export.b91ef64efc3688266305ea9b42e5017e.rtpl.php:16
 msgid "Export Database"
@@ -870,7 +870,7 @@ msgstr "Publics"
 
 #: tmp/export.b91ef64efc3688266305ea9b42e5017e.rtpl.php:52
 msgid "Prepend note permalinks with this Shaarli instance's URL"
-msgstr "Préfixer les liens de notes avec l'URL de l'instance de Shaarli"
+msgstr "Préfixer les liens de note avec l'URL de l'instance de Shaarli"
 
 #: tmp/export.b91ef64efc3688266305ea9b42e5017e.rtpl.php:53
 msgid "Useful to import bookmarks in a web browser"
@@ -1066,7 +1066,7 @@ msgstr "Liens par page"
 msgid ""
 "You have been banned after too many failed login attempts. Try again later."
 msgstr ""
-"Vous avez été banni après trop d'échec d'authentification. Merci de "
+"Vous avez été banni après trop d'échecs d'authentification. Merci de "
 "réessayer plus tard."
 
 #: tmp/loginform.b91ef64efc3688266305ea9b42e5017e.rtpl.php:41
@@ -1251,7 +1251,7 @@ msgstr "Changer les paramètres de Shaarli : titre, fuseau horaire, etc."
 
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:17
 msgid "Configure your Shaarli"
-msgstr "Conguration de Shaarli"
+msgstr "Configurer Shaarli"
 
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:21
 msgid "Enable, disable and configure plugins"
@@ -1259,19 +1259,19 @@ msgstr "Activer, désactiver et configurer les extensions"
 
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:28
 msgid "Change your password"
-msgstr "Modification du mot de passe"
+msgstr "Modifier le mot de passe"
 
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:35
 msgid "Rename or delete a tag in all links"
-msgstr "Rename or delete a tag in all links"
+msgstr "Renommer ou supprimer un tag dans tous les liens"
 
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:41
 msgid ""
 "Import Netscape HTML bookmarks (as exported from Firefox, Chrome, Opera, "
-"delicious...)"
+"delicious)"
 msgstr ""
 "Importer des marques pages au format Netscape HTML (comme exportés depuis "
-"Firefox, Chrome, Opera, delicious...)"
+"Firefox, Chrome, Opera, delicious)"
 
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:42
 msgid "Import links"
@@ -1280,10 +1280,10 @@ msgstr "Importer des liens"
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:47
 msgid ""
 "Export Netscape HTML bookmarks (which can be imported in Firefox, Chrome, "
-"Opera, delicious...)"
+"Opera, delicious)"
 msgstr ""
 "Exporter les marques pages au format Netscape HTML (comme exportés depuis "
-"Firefox, Chrome, Opera, delicious...)"
+"Firefox, Chrome, Opera, delicious)"
 
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:48
 msgid "Export database"
@@ -1298,13 +1298,13 @@ msgid ""
 "Drag one of these button to your bookmarks toolbar or right-click it and "
 "\"Bookmark This Link\""
 msgstr ""
-"Glisser un de ces bouttons dans votre barre de favoris ou cliquer droit "
+"Glisser un de ces boutons dans votre barre de favoris ou cliquer droit "
 "dessus et « Ajouter aux favoris »"
 
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:82
 msgid "then click on the bookmarklet in any page you want to share."
 msgstr ""
-"puis cliquer sur le marque page depuis un site que vous souhaitez partager."
+"puis cliquer sur le marque-page depuis un site que vous souhaitez partager."
 
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:86
 #: tmp/tools.b91ef64efc3688266305ea9b42e5017e.rtpl.php:110
@@ -1450,7 +1450,7 @@ msgstr ""
 #~ "\n"
 
 #~ msgid "Sessions do not seem to work correctly on your server."
-#~ msgstr "Les sessions ne semblent "
+#~ msgstr "Les sessions ne semblent pas fonctionner correctement sur votre serveur."
 
 #~ msgid "Tag was renamed in "
 #~ msgstr "Le tag a été renommé dans "
index 9c1e4999ed68ef717142b66b4511403918ed8eb6..0ef3363354e54f69a958092fafaf5d7ba619855f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1084,7 +1084,8 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
             die(t('Wrong token.'));
         }
 
-        $alteredLinks = $LINKSDB->renameTag(escape($_POST['fromtag']), escape($_POST['totag']));
+        $toTag = isset($_POST['totag']) ? escape($_POST['totag']) : null;
+        $alteredLinks = $LINKSDB->renameTag(escape($_POST['fromtag']), $toTag);
         $LINKSDB->save($conf->get('resource.page_cache'));
         foreach ($alteredLinks as $link) {
             $history->updateLink($link);
@@ -1236,10 +1237,10 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
             $id = (int) escape($id);
             $link = $LINKSDB[$id];
             $pluginManager->executeHooks('delete_link', $link);
+            $history->deleteLink($link);
             unset($LINKSDB[$id]);
         }
         $LINKSDB->save($conf->get('resource.page_cache')); // save to disk
-        $history->deleteLink($link);
 
         // If we are called from the bookmarklet, we must close the popup:
         if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
diff --git a/plugins/isso/comment.png b/plugins/isso/comment.png
new file mode 100644 (file)
index 0000000..0158c03
Binary files /dev/null and b/plugins/isso/comment.png differ
index 5bc1cce26e79d1be3cc64fa3bda9109a12c2ea3f..378c11af3bfb526b57e22e76c88aa06f4408c2bd 100644 (file)
@@ -46,9 +46,36 @@ function hook_isso_render_linklist($data, $conf)
 
         $isso = sprintf($issoHtml, $issoUrl, $issoUrl, $link['id'], $link['id']);
         $data['plugin_end_zone'][] = $isso;
+    } else {
+        $button = '<span><a href="?%s#isso-thread">';
+        // For the default theme we use a FontAwesome icon which is better than an image
+        if ($conf->get('resource.theme') === 'default') {
+            $button .= '<i class="linklist-plugin-icon fa fa-comment"></i>';
+        } else {
+            $button .= '<img class="linklist-plugin-icon" src="plugins/isso/comment.png" ';
+            $button .= 'title="Comment on this shaare" alt="Comments" />';
+        }
+        $button .= '</a></span>';
+        foreach ($data['links'] as &$value) {
+            $commentLink = sprintf($button, $value['shorturl']);
+            $value['link_plugin'][] = $commentLink;
+        }
+    }
 
-        // Hackish way to include this CSS file only when necessary.
-        $data['plugins_includes']['css_files'][] = PluginManager::$PLUGINS_PATH . '/isso/isso.css';
+    return $data;
+}
+
+/**
+ * When linklist is displayed, include isso CSS file.
+ *
+ * @param array $data - header data.
+ *
+ * @return mixed - header data with isso CSS file added.
+ */
+function hook_isso_render_includes($data)
+{
+    if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) {
+        $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/isso/isso.css';
     }
 
     return $data;
diff --git a/plugins/isso/isso_button.html b/plugins/isso/isso_button.html
new file mode 100644 (file)
index 0000000..3f82848
--- /dev/null
@@ -0,0 +1,5 @@
+<span>
+  <a href="?%s#isso-thread">
+    <img class="linklist-plugin-icon" src="plugins/archiveorg/internetarchive.png" title="%s" alt="archive.org" />
+  </a>
+</span>
index 0ae73183808666ec74bf7ef7ea64e50f63b73c94..2c9efbcde4292a221392a725d73d488dd26c2c9e 100644 (file)
@@ -21,7 +21,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
     /**
      * Test Isso init without errors.
      */
-    public function testWallabagInitNoError()
+    public function testIssoInitNoError()
     {
         $conf = new ConfigManager('');
         $conf->set('plugins.ISSO_SERVER', 'value');
@@ -32,7 +32,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
     /**
      * Test Isso init with errors.
      */
-    public function testWallabagInitError()
+    public function testIssoInitError()
     {
         $conf = new ConfigManager('');
         $errors = isso_init($conf);
@@ -96,19 +96,22 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
                 array(
                     'id' => 12,
                     'url' => $str,
+                    'shorturl' => $short1 = 'abcd',
                     'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date1),
                 ),
                 array(
                     'id' => 13,
                     'url' => $str . '2',
+                    'shorturl' => $short2 = 'efgh',
                     'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date2),
                 ),
             )
         );
 
         $processed = hook_isso_render_linklist($data, $conf);
-        // data shouldn't be altered
-        $this->assertEquals($data, $processed);
+        // link_plugin should be added for the icon
+        $this->assertContains('<a href="?'. $short1 .'#isso-thread">', $processed['links'][0]['link_plugin'][0]);
+        $this->assertContains('<a href="?'. $short2 .'#isso-thread">', $processed['links'][1]['link_plugin'][0]);
     }
 
     /**
@@ -127,6 +130,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
                 array(
                     'id' => 12,
                     'url' => $str,
+                    'shorturl' => $short1 = 'abcd',
                     'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date),
                 )
             ),
@@ -135,8 +139,8 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
 
         $processed = hook_isso_render_linklist($data, $conf);
 
-        // data shouldn't be altered
-        $this->assertEquals($data, $processed);
+        // link_plugin should be added for the icon
+        $this->assertContains('<a href="?'. $short1 .'#isso-thread">', $processed['links'][0]['link_plugin'][0]);
     }
 
     /**