add libravatar API

This commit is contained in:
Jean-Christian Denis 2021-10-30 22:42:09 +02:00
parent 3075293853
commit 679cc291c4
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
6 changed files with 30 additions and 122 deletions

View file

@ -2,6 +2,7 @@
- [ ] add cache system - [ ] add cache system
- [ ] add option for gravatar built in unknow avatar @see https://fr.gravatar.com/site/implement/images/ - [ ] add option for gravatar built in unknow avatar @see https://fr.gravatar.com/site/implement/images/
- use url handler for dynamic js and css - use url handler for dynamic js and css
- add libravatar API
0.7 - 2021.09.09 0.7 - 2021.09.09
- fix image directories - fix image directories

View file

@ -26,6 +26,9 @@ try {
$core->blog->settings->noodles->put( $core->blog->settings->noodles->put(
'noodles_active', false, 'boolean', 'Enable extension', false, true '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( $core->blog->settings->noodles->put(
'noodles_image', '', 'string', 'Image filename', false, true 'noodles_image', '', 'string', 'Image filename', false, true
); );

View file

@ -54,8 +54,6 @@ class publicNoodles
class urlNoodles extends dcUrlHandlers 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) public static function css($args)
{ {
global $core, $__noodles; global $core, $__noodles;
@ -153,6 +151,10 @@ class urlNoodles extends dcUrlHandlers
$d = $core->blog->settings->noodles->noodles_image ? $d = $core->blog->settings->noodles->noodles_image ?
urlencode(noodlesLibImagePath::getUrl($core, 'noodles')) : ''; urlencode(noodlesLibImagePath::getUrl($core, 'noodles')) : '';
$u = $core->blog->settings->noodles->noodles_api;
if (empty($u)) {
$u = 'http://www.gravatar.com/';
}
if (!$m) { if (!$m) {
$m = 'nobody@nowhere.tld'; $m = 'nobody@nowhere.tld';
} }
@ -166,7 +168,7 @@ class urlNoodles extends dcUrlHandlers
$m = md5(strtolower(trim( $m))); $m = md5(strtolower(trim( $m)));
$im = new xmlTag('noodle'); $im = new xmlTag('noodle');
$im->size = $s; $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->insertNode($im);
$rsp->status = 'ok'; $rsp->status = 'ok';

View file

@ -43,6 +43,11 @@ if (!is_array($default_images)) {
} }
$default_image = $s->noodles_image; $default_image = $s->noodles_image;
$combo_api = [
'gravatar' => 'http://www.gravatar.com/',
'libravatar' => 'http://cdn.libravatar.org/'
];
$combo_place = [ $combo_place = [
__('Begin') => 'prepend', __('Begin') => 'prepend',
__('End') => 'append', __('End') => 'append',
@ -71,6 +76,7 @@ if (!empty($_POST['save'])) {
try { try {
$public_file = $public_path . '/noodles-default-image.png'; $public_file = $public_path . '/noodles-default-image.png';
$s->put('noodles_active', !empty($_POST['noodles_active']), 'boolean'); $s->put('noodles_active', !empty($_POST['noodles_active']), 'boolean');
$s->put('noodles_api', $_POST['noodles_api'], 'string');
// user upload image // user upload image
if ($_POST['noodles_image'] == 'user' && !empty($public_path)) { if ($_POST['noodles_image'] == 'user' && !empty($public_path)) {
@ -146,8 +152,11 @@ dcPage::notices() . '
'" method="post" enctype="multipart/form-data"> '" method="post" enctype="multipart/form-data">
<h3>' . sprintf(__('Configure "%s"'), __('Noodles')) . '</h3> <h3>' . sprintf(__('Configure "%s"'), __('Noodles')) . '</h3>
<div class="fieldset"><h4>' . __('Activation') . '</h4> <div class="fieldset"><h4>' . __('Activation') . '</h4>
<p class="field">' . form::checkbox('noodles_active', 1, $s->noodles_active) . ' <p><label for="noodles_active">' .
<label for="noodles_active">' . __('Enable plugin') . '</label></p> form::checkbox('noodles_active', 1, $s->noodles_active) .
__('Enable plugin noodles on this blog') . '</label></p>
<p><label for="noodles_api" class="classic">' . __('API:') . ' </label>' .
form::combo('noodles_api', $combo_api, $s->noodles_api) . '</p>
</div> </div>
<div class="fieldset"><h4>' . __('Avatar') . '</h4> <div class="fieldset"><h4>' . __('Avatar') . '</h4>
<p>' . __('Select default avatar to display on unknown users.') . '</p>'; <p>' . __('Select default avatar to display on unknown users.') . '</p>';
@ -209,7 +218,7 @@ if (!empty($public_path)) {
echo ' echo '
<div class="fieldset box"> <div class="fieldset box">
<p>'. form::radio(['noodles_image', 'com_image'], 'gravatar.com', empty($default_image)) . ' <p>'. form::radio(['noodles_image', 'com_image'], 'gravatar.com', empty($default_image)) . '
<label class="classic">' . __('gravatar.com default image').'</label></p> <label class="classic">' . __('API default image').'</label></p>
</div>'; </div>';
if (empty($public_path)) { if (empty($public_path)) {

View file

@ -1,80 +0,0 @@
<?php
// Language: Français
// Module: noodles - 0.6.1
// Date: 2021-09-09 20:44:35
// Translated with dcTranslater - 2021.09.02.1
#inc/_default_noodles.php:38
$GLOBALS['__l10n']['Entries titles'] = 'Titres des billets';
#inc/_default_noodles.php:68
$GLOBALS['__l10n']['Authors widget'] = 'Widgets des auteurs';
#index.php:47
$GLOBALS['__l10n']['Begin'] = 'Début';
#index.php:48
$GLOBALS['__l10n']['End'] = 'Fin';
#index.php:49
$GLOBALS['__l10n']['Before'] = 'Avant';
#index.php:50
$GLOBALS['__l10n']['After'] = 'Après';
#index.php:78
$GLOBALS['__l10n']['Maximum file size exceeded'] = 'Taille maximum de fichier dépassée';
#index.php:81
$GLOBALS['__l10n']['Something went wrong while download file'] = 'Une erreur est survenue lors du téléchargement de l\'image';
#index.php:84
$GLOBALS['__l10n']['Image must be in png format'] = 'L\'image doit être au format png';
#index.php:89
$GLOBALS['__l10n']['Failed to save image'] = 'Impossible de sauvegarder l\'image';
#index.php:104
$GLOBALS['__l10n']['Something went wrong while search file'] = 'Une erreur est survenue pendant la recherche de fichier';
#index.php:150
$GLOBALS['__l10n']['Enable plugin'] = 'Activer le plugin';
#index.php:153
$GLOBALS['__l10n']['Select default avatar to display on unknown users.'] = 'Selectionner l\'avatar par défaut à afficher pour les utilisateurs inconnus.';
#index.php:190
$GLOBALS['__l10n']['Blog default image'] = 'Image du blog';
#index.php:203
$GLOBALS['__l10n']['Upload a new avatar'] = 'Téléverser un nouvel avatar';
#index.php:206
$GLOBALS['__l10n']['Image must be in "png" format and have a maximum file size of 30Ko'] = 'L\'image doit être au format "png" et avoir une taille maximum de 30Ko';
#index.php:212
$GLOBALS['__l10n']['gravatar.com default image'] = 'Image par défaut de gravatar.com';
#index.php:216
$GLOBALS['__l10n']['Public directory is not writable, you can not use custom gravatar.'] = 'Le répertoire public n\'est pas accissble en écriture, vous ne pouvez pas utiliser les avatars customisés';
#index.php:224
$GLOBALS['__l10n']['Search area'] = 'Zone de recherche';
#index.php:225
$GLOBALS['__l10n']['Size'] = 'Taille';
#index.php:226
$GLOBALS['__l10n']['Rating'] = 'Évaluation';
#index.php:229
$GLOBALS['__l10n']['Target'] = 'Cible';
#index.php:230
$GLOBALS['__l10n']['Place'] = 'Emplacement';
#index.php:231
$GLOBALS['__l10n']['Adjust avatar CSS'] = 'Ajuster la CSS de l\'image';
#index.php:254
$GLOBALS['__l10n']['Target and Place are for javascript.'] = 'Les cible et emplacement sont utilisés par les scripts javascript.';

View file

@ -1,117 +1,90 @@
# Language: Français
# Module: noodles - 0.6.1
# Date: 2021-09-09 20:44:35
# Translated with translater 2021.09.02.1
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: noodles 0.6.1\n" "Project-Id-Version: noodles 0.7.1\n"
"POT-Creation-Date: \n" "POT-Creation-Date: \n"
"PO-Revision-Date: 2021-09-09T20:44:35+00:00\n" "PO-Revision-Date: 2021-10-30T20:41:09+00:00\n"
"Last-Translator: Jean-Christian Denis\n" "Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: inc/_default_noodles.php:38
msgid "Entries titles" msgid "Entries titles"
msgstr "Titres des billets" msgstr "Titres des billets"
#: inc/_default_noodles.php:68
msgid "Authors widget" msgid "Authors widget"
msgstr "Widgets des auteurs" msgstr "Widgets des auteurs"
#: index.php:47
msgid "Begin" msgid "Begin"
msgstr "Début" msgstr "Début"
#: index.php:48
msgid "End" msgid "End"
msgstr "Fin" msgstr "Fin"
#: index.php:49
msgid "Before" msgid "Before"
msgstr "Avant" msgstr "Avant"
#: index.php:50
msgid "After" msgid "After"
msgstr "Après" msgstr "Après"
#: index.php:78
msgid "Maximum file size exceeded" msgid "Maximum file size exceeded"
msgstr "Taille maximum de fichier dépassée" msgstr "Taille maximum de fichier dépassée"
#: index.php:81
msgid "Something went wrong while download file" msgid "Something went wrong while download file"
msgstr "Une erreur est survenue lors du téléchargement de l'image" msgstr "Une erreur est survenue lors du téléchargement de l'image"
#: index.php:84
msgid "Image must be in png format" msgid "Image must be in png format"
msgstr "L'image doit être au format png" msgstr "L'image doit être au format png"
#: index.php:89
msgid "Failed to save image" msgid "Failed to save image"
msgstr "Impossible de sauvegarder l'image" msgstr "Impossible de sauvegarder l'image"
#: index.php:104
msgid "Something went wrong while search file" msgid "Something went wrong while search file"
msgstr "Une erreur est survenue pendant la recherche de fichier" msgstr "Une erreur est survenue pendant la recherche de fichier"
#: index.php:150 msgid "Enable plugin noodles on this blog"
msgid "Enable plugin" msgstr "Activer le plugin Noodles sur ce blog"
msgstr "Activer le plugin"
#: index.php:153
msgid "Select default avatar to display on unknown users." msgid "Select default avatar to display on unknown users."
msgstr "Selectionner l'avatar par défaut à afficher pour les utilisateurs inconnus." msgstr "Selectionner l'avatar par défaut à afficher pour les utilisateurs inconnus."
#: index.php:190
msgid "Blog default image" msgid "Blog default image"
msgstr "Image du blog" msgstr "Image du blog"
#: index.php:203
msgid "Upload a new avatar" msgid "Upload a new avatar"
msgstr "Téléverser un nouvel 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" 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" msgstr "L'image doit être au format \"png\" et avoir une taille maximum de 30Ko"
#: index.php:212 msgid "API default image"
msgid "gravatar.com default image" msgstr "Image par défaut de l'API"
msgstr "Image par défaut de gravatar.com"
#: index.php:216
msgid "Public directory is not writable, you can not use custom gravatar." 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" 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" msgid "Search area"
msgstr "Zone de recherche" msgstr "Zone de recherche"
#: index.php:225
msgid "Size" msgid "Size"
msgstr "Taille" msgstr "Taille"
#: index.php:226
msgid "Rating" msgid "Rating"
msgstr "Évaluation" msgstr "Évaluation"
#: index.php:229
msgid "Target" msgid "Target"
msgstr "Cible" msgstr "Cible"
#: index.php:230
msgid "Place" msgid "Place"
msgstr "Emplacement" msgstr "Emplacement"
#: index.php:231
msgid "Adjust avatar CSS" msgid "Adjust avatar CSS"
msgstr "Ajuster la CSS de l'image" msgstr "Ajuster la CSS de l'image"
#: index.php:254
msgid "Target and Place are for javascript." msgid "Target and Place are for javascript."
msgstr "Les cible et emplacement sont utilisés par les scripts javascript." msgstr "Les cible et emplacement sont utilisés par les scripts javascript."
msgid "Add users gravatars everywhere"
msgstr "Ajouter les avatars partout"