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 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

View file

@ -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
);

View file

@ -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';

View file

@ -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">
<h3>' . sprintf(__('Configure "%s"'), __('Noodles')) . '</h3>
<div class="fieldset"><h4>' . __('Activation') . '</h4>
<p class="field">' . form::checkbox('noodles_active', 1, $s->noodles_active) . '
<label for="noodles_active">' . __('Enable plugin') . '</label></p>
<p><label for="noodles_active">' .
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 class="fieldset"><h4>' . __('Avatar') . '</h4>
<p>' . __('Select default avatar to display on unknown users.') . '</p>';
@ -209,7 +218,7 @@ if (!empty($public_path)) {
echo '
<div class="fieldset box">
<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>';
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 ""
msgstr ""
"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"
"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"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 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"