From 679cc291c491630a52738412a9dd117e87115b3b Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 30 Oct 2021 22:42:09 +0200 Subject: [PATCH] add libravatar API --- CHANGELOG.md | 1 + _install.php | 3 ++ _public.php | 8 ++-- index.php | 15 ++++++-- locales/fr/main.lang.php | 80 ---------------------------------------- locales/fr/main.po | 45 +++++----------------- 6 files changed, 30 insertions(+), 122 deletions(-) delete mode 100644 locales/fr/main.lang.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 099ee1c..afb7693 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - [ ] add cache system - [ ] add option for gravatar built in unknow avatar @see https://fr.gravatar.com/site/implement/images/ - use url handler for dynamic js and css +- add libravatar API 0.7 - 2021.09.09 - fix image directories diff --git a/_install.php b/_install.php index 730d346..c545581 100644 --- a/_install.php +++ b/_install.php @@ -26,6 +26,9 @@ try { $core->blog->settings->noodles->put( 'noodles_active', false, 'boolean', 'Enable extension', false, true ); + $core->blog->settings->noodles->put( + 'noodles_api', 'http://www.gravatar.com/', 'string', 'external API to use', false, true + ); $core->blog->settings->noodles->put( 'noodles_image', '', 'string', 'Image filename', false, true ); diff --git a/_public.php b/_public.php index 4a21065..9a6d91f 100644 --- a/_public.php +++ b/_public.php @@ -54,8 +54,6 @@ class publicNoodles class urlNoodles extends dcUrlHandlers { - public static $api_url = 'http://www.gravatar.com/avatar/%s?s=%s&r=%s&d=%s'; - public static function css($args) { global $core, $__noodles; @@ -153,6 +151,10 @@ class urlNoodles extends dcUrlHandlers $d = $core->blog->settings->noodles->noodles_image ? urlencode(noodlesLibImagePath::getUrl($core, 'noodles')) : ''; + $u = $core->blog->settings->noodles->noodles_api; + if (empty($u)) { + $u = 'http://www.gravatar.com/'; + } if (!$m) { $m = 'nobody@nowhere.tld'; } @@ -166,7 +168,7 @@ class urlNoodles extends dcUrlHandlers $m = md5(strtolower(trim( $m))); $im = new xmlTag('noodle'); $im->size = $s; - $im->src = sprintf(self::$api_url, $m, $s, $r, $d); + $im->src = sprintf('%savatar/%s?s=%s&r=%s&d=%s', $u, $m, $s, $r, $d); $rsp->insertNode($im); $rsp->status = 'ok'; diff --git a/index.php b/index.php index 30986e3..8ad87c1 100644 --- a/index.php +++ b/index.php @@ -43,6 +43,11 @@ if (!is_array($default_images)) { } $default_image = $s->noodles_image; +$combo_api = [ + 'gravatar' => 'http://www.gravatar.com/', + 'libravatar' => 'http://cdn.libravatar.org/' +]; + $combo_place = [ __('Begin') => 'prepend', __('End') => 'append', @@ -71,6 +76,7 @@ if (!empty($_POST['save'])) { try { $public_file = $public_path . '/noodles-default-image.png'; $s->put('noodles_active', !empty($_POST['noodles_active']), 'boolean'); + $s->put('noodles_api', $_POST['noodles_api'], 'string'); // user upload image if ($_POST['noodles_image'] == 'user' && !empty($public_path)) { @@ -146,8 +152,11 @@ dcPage::notices() . ' '" method="post" enctype="multipart/form-data">

' . sprintf(__('Configure "%s"'), __('Noodles')) . '

' . __('Activation') . '

-

' . form::checkbox('noodles_active', 1, $s->noodles_active) . ' -

+

+

' . +form::combo('noodles_api', $combo_api, $s->noodles_api) . '

' . __('Avatar') . '

' . __('Select default avatar to display on unknown users.') . '

'; @@ -209,7 +218,7 @@ if (!empty($public_path)) { echo '

'. form::radio(['noodles_image', 'com_image'], 'gravatar.com', empty($default_image)) . ' -

+

'; if (empty($public_path)) { diff --git a/locales/fr/main.lang.php b/locales/fr/main.lang.php deleted file mode 100644 index 881ccdb..0000000 --- a/locales/fr/main.lang.php +++ /dev/null @@ -1,80 +0,0 @@ - 1);\n" -#: inc/_default_noodles.php:38 msgid "Entries titles" msgstr "Titres des billets" -#: inc/_default_noodles.php:68 msgid "Authors widget" msgstr "Widgets des auteurs" -#: index.php:47 msgid "Begin" msgstr "Début" -#: index.php:48 msgid "End" msgstr "Fin" -#: index.php:49 msgid "Before" msgstr "Avant" -#: index.php:50 msgid "After" msgstr "Après" -#: index.php:78 msgid "Maximum file size exceeded" msgstr "Taille maximum de fichier dépassée" -#: index.php:81 msgid "Something went wrong while download file" msgstr "Une erreur est survenue lors du téléchargement de l'image" -#: index.php:84 msgid "Image must be in png format" msgstr "L'image doit être au format png" -#: index.php:89 msgid "Failed to save image" msgstr "Impossible de sauvegarder l'image" -#: index.php:104 msgid "Something went wrong while search file" msgstr "Une erreur est survenue pendant la recherche de fichier" -#: index.php:150 -msgid "Enable plugin" -msgstr "Activer le plugin" +msgid "Enable plugin noodles on this blog" +msgstr "Activer le plugin Noodles sur ce blog" -#: index.php:153 msgid "Select default avatar to display on unknown users." msgstr "Selectionner l'avatar par défaut à afficher pour les utilisateurs inconnus." -#: index.php:190 msgid "Blog default image" msgstr "Image du blog" -#: index.php:203 msgid "Upload a new avatar" msgstr "Téléverser un nouvel avatar" -#: index.php:206 msgid "Image must be in \"png\" format and have a maximum file size of 30Ko" msgstr "L'image doit être au format \"png\" et avoir une taille maximum de 30Ko" -#: index.php:212 -msgid "gravatar.com default image" -msgstr "Image par défaut de gravatar.com" +msgid "API default image" +msgstr "Image par défaut de l'API" -#: index.php:216 msgid "Public directory is not writable, you can not use custom gravatar." msgstr "Le répertoire public n'est pas accissble en écriture, vous ne pouvez pas utiliser les avatars customisés" -#: index.php:224 msgid "Search area" msgstr "Zone de recherche" -#: index.php:225 msgid "Size" msgstr "Taille" -#: index.php:226 msgid "Rating" msgstr "Évaluation" -#: index.php:229 msgid "Target" msgstr "Cible" -#: index.php:230 msgid "Place" msgstr "Emplacement" -#: index.php:231 msgid "Adjust avatar CSS" msgstr "Ajuster la CSS de l'image" -#: index.php:254 msgid "Target and Place are for javascript." msgstr "Les cible et emplacement sont utilisés par les scripts javascript." +msgid "Add users gravatars everywhere" +msgstr "Ajouter les avatars partout" +