Cleaning up a little, reorganizing. Was Trying to look into recatpcha
support, but decided not to bother, keep things simple with verification server side for now with no added javascript.
This commit is contained in:
parent
9bff3a3397
commit
3632251cea
|
@ -59,16 +59,7 @@ form:
|
|||
0: PLUGIN_ADMIN.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
recaptcha:
|
||||
type: toggle
|
||||
label: PLUGIN_COMMENTS.RECAPTCHA
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.ENABLED
|
||||
0: PLUGIN_ADMIN.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
akismet:
|
||||
type: toggle
|
||||
label: PLUGIN_COMMENTS.AKISMET
|
||||
|
@ -79,19 +70,14 @@ form:
|
|||
0: PLUGIN_ADMIN.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
akismet_apikey:
|
||||
akismet_key_api:
|
||||
type: text
|
||||
label: PLUGIN_COMMENTS.AKISMET_APIKEY
|
||||
label: PLUGIN_COMMENTS.AKISMET_KEY_API
|
||||
highlight: 1
|
||||
default:
|
||||
options:
|
||||
1: PLUGIN_ADMIN.ENABLED
|
||||
0: PLUGIN_ADMIN.DISABLED
|
||||
akismet_site:
|
||||
type: text
|
||||
label: PLUGIN_COMMENTS.AKISMET_SITE_OVERRIDE
|
||||
highlight: 1
|
||||
default:
|
||||
options:
|
||||
1: PLUGIN_ADMIN.ENABLED
|
||||
0: PLUGIN_ADMIN.DISABLED
|
||||
|
|
30
comments.php
30
comments.php
|
@ -89,7 +89,7 @@ class CommentsPlugin extends Plugin
|
|||
$this->grav['twig']->pingbacks_enabled = $this->pingbacks_enabled;
|
||||
$this->grav['twig']->comments = $this->fetchComments();
|
||||
$this->grav['twig']->pingbacks = $this->fetchPingbacks();
|
||||
$this->grav['twig']->akismet_enabled = $this->grav['config']->get('plugins.comments.akismet');
|
||||
$this->grav['twig']->akismet_enabled = $this->akismet_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,10 +116,6 @@ class CommentsPlugin extends Plugin
|
|||
}
|
||||
}
|
||||
|
||||
#$blueprint = $this->getBlueprint();
|
||||
#$this->commenting_enabled = $blueprint->get('form/fields/commenting', false, '/');
|
||||
#$this->pingbacks_enabled = $blueprint->get('form/fields/pingbacks' , false, '/');
|
||||
|
||||
$this->commenting_enabled = $this->grav['config']->get('plugins.comments.commenting');
|
||||
$this->pingbacks_enabled = $this->grav['config']->get('plugins.comments.pingbacks');
|
||||
|
||||
|
@ -240,7 +236,7 @@ class CommentsPlugin extends Plugin
|
|||
$lang = $language->getLanguage();
|
||||
|
||||
if ($this->akismet_enabled) {
|
||||
$key = $this->grav['config']->get('plugins.comments.akismet_apikey');
|
||||
$key = $this->grav['config']->get('plugins.comments.akismet_key_api');
|
||||
$url_override = $this->grav['config']->get('plugins.comments.akismet_site');
|
||||
$url = !empty($url_override) ? $url_override : $_SERVER['HTTP_HOST'];
|
||||
|
||||
|
@ -250,12 +246,14 @@ class CommentsPlugin extends Plugin
|
|||
$akismet->setCommentAuthorURL($site);
|
||||
$akismet->setCommentContent($text);
|
||||
//$akismet->setPermalink($comment->post->permalink);
|
||||
//try {
|
||||
try {
|
||||
$spam = ($akismet->isCommentSpam()) ? 'spam' : 'ham';
|
||||
//return;
|
||||
//} catch (Exception $e) {
|
||||
// EventLog::log($e->getMessage(), 'notice', 'comment', 'HabariAkismet');
|
||||
//}
|
||||
} catch (Exception $e) {
|
||||
//EventLog::log($e->getMessage(), 'notice', 'comment', 'HabariAkismet');
|
||||
// TODO: admin needs to approve comment
|
||||
$spam = "pending";
|
||||
}
|
||||
}
|
||||
|
||||
$filename = DATA_DIR . 'comments';
|
||||
|
@ -292,9 +290,11 @@ class CommentsPlugin extends Plugin
|
|||
$file->save(Yaml::dump($data));
|
||||
|
||||
//clear cache
|
||||
$this->grav['cache']->delete($this->comments_cache_id);
|
||||
$this->grav['cache']->delete($this->pingbacks_cache_id);
|
||||
|
||||
if (!isset($spam) || $spam == 'ham')
|
||||
{
|
||||
$this->grav['cache']->delete($this->comments_cache_id);
|
||||
$this->grav['cache']->delete($this->pingbacks_cache_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ class CommentsPlugin extends Plugin
|
|||
$this->grav['twig']->akismet_enabled = $this->akismet_enabled;
|
||||
|
||||
if ($this->akismet_enabled) {
|
||||
$key = $this->grav['config']->get('plugins.comments.akismet_apikey');
|
||||
$key = $this->grav['config']->get('plugins.comments.akismet_key_api');
|
||||
$url_override = $this->grav['config']->get('plugins.comments.akismet_site');
|
||||
$url = !empty($url_override) ? $url_override : $_SERVER['HTTP_HOST'];
|
||||
|
||||
|
@ -501,8 +501,6 @@ class CommentsPlugin extends Plugin
|
|||
public function onAdminMenu()
|
||||
{
|
||||
$this->grav['twig']->plugins_hooked_nav['PLUGIN_COMMENTS.COMMENTS'] = ['route' => $this->route, 'icon' => 'fa-file-text'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@ de:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: Kommentar hinzufügen
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: Kommentare
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -22,7 +22,6 @@ de:
|
|||
EMAIL_PLACEHOLDER: "Email-Adresse eingeben"
|
||||
MESSAGE_LABEL: "Kommentar"
|
||||
MESSAGE_PLACEHOLDER: "Kommentar eingeben"
|
||||
RECAPTCHA: reCAPTCHA
|
||||
SITE_LABEL: Site
|
||||
SUBMIT_COMMENT_BUTTON_TEXT: "Absenden"
|
||||
EMAIL_NEW_COMMENT_SUBJECT: "[Neuer Kommentar] von {{ form.value.name|e }}"
|
||||
|
@ -33,7 +32,7 @@ en:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: Add a comment
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: Comments
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -53,7 +52,6 @@ en:
|
|||
EMAIL_PLACEHOLDER: "Enter your email address"
|
||||
MESSAGE_LABEL: "Comment"
|
||||
MESSAGE_PLACEHOLDER: "Enter your comment"
|
||||
RECAPTCHA: reCAPTCHA
|
||||
SITE_LABEL: Site
|
||||
SUBMIT_COMMENT_BUTTON_TEXT: "Submit"
|
||||
EMAIL_NEW_COMMENT_SUBJECT: "[New Comment] from {{ form.value.name|e }}"
|
||||
|
@ -64,7 +62,7 @@ es:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: Agregar un comentario
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: Comentarios
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -84,7 +82,6 @@ es:
|
|||
EMAIL_PLACEHOLDER: "Escriba su email"
|
||||
MESSAGE_LABEL: "Comentario"
|
||||
MESSAGE_PLACEHOLDER: "Escriba su comentario"
|
||||
RECAPTCHA: reCAPTCHA
|
||||
SITE_LABEL: Site
|
||||
SUBMIT_COMMENT_BUTTON_TEXT: "Enviar"
|
||||
EMAIL_NEW_COMMENT_SUBJECT: "[Nuevo comentario] de {{ form.value.name|e }}"
|
||||
|
@ -95,7 +92,7 @@ fr:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: Ajouter un commentaire
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: Commentaires
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -115,7 +112,6 @@ fr:
|
|||
EMAIL_PLACEHOLDER: "Indiquez votre adresse e-mail"
|
||||
MESSAGE_LABEL: "Commentaire"
|
||||
MESSAGE_PLACEHOLDER: "Rédigez votre commentaire"
|
||||
RECAPTCHA: reCAPTCHA
|
||||
SITE_LABEL: Site
|
||||
SUBMIT_COMMENT_BUTTON_TEXT: "Envoyer"
|
||||
EMAIL_NEW_COMMENT_SUBJECT: "[Nouveau commentaire] de {{ form.value.name|e }}"
|
||||
|
@ -126,7 +122,7 @@ hr:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: Dodaj komentar
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: Komentari
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -146,7 +142,6 @@ hr:
|
|||
EMAIL_PLACEHOLDER: "Unesite email adresu"
|
||||
MESSAGE_LABEL: "Komentar"
|
||||
MESSAGE_PLACEHOLDER: "Unesite komentar"
|
||||
RECAPTCHA: reCAPTCHA
|
||||
SITE_LABEL: Site
|
||||
SUBMIT_COMMENT_BUTTON_TEXT: "Pošalji"
|
||||
EMAIL_NEW_COMMENT_SUBJECT: "[Novi komentar] od {{ form.value.name|e }}"
|
||||
|
@ -157,7 +152,7 @@ it:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: Aggiungi un commento
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: Commenti
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -177,7 +172,6 @@ it:
|
|||
EMAIL_PLACEHOLDER: "Inserisci il tuo indirizzo email"
|
||||
MESSAGE_LABEL: "Messaggio"
|
||||
MESSAGE_PLACEHOLDER: "Inserisci il tuo commento"
|
||||
RECAPTCHA: reCAPTCHA
|
||||
SITE_LABEL: Site
|
||||
SUBMIT_COMMENT_BUTTON_TEXT: "Invia"
|
||||
EMAIL_NEW_COMMENT_SUBJECT: "[Nuovo commento] da {{ form.value.name|e }}"
|
||||
|
@ -188,7 +182,7 @@ ja:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: コメントを追加する
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: コメント
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -208,7 +202,6 @@ ja:
|
|||
EMAIL_PLACEHOLDER: "ご自分のメールアドレスをここに..."
|
||||
MESSAGE_LABEL: "コメント"
|
||||
MESSAGE_PLACEHOLDER: "コメントをここに"
|
||||
RECAPTCHA: reCAPTCHA
|
||||
SITE_LABEL: Site
|
||||
SUBMIT_COMMENT_BUTTON_TEXT: "送信する"
|
||||
EMAIL_NEW_COMMENT_SUBJECT: "[新しいコメント]、 {{ form.value.name|e }}から"
|
||||
|
@ -219,7 +212,7 @@ pl:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: Dodaj komentarz
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: Komentarzy
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -238,7 +231,7 @@ ru:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: Добавить комментарий
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: Комментарии
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -257,7 +250,7 @@ pt-br:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: Escreva um comentário
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: Comentários
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -277,7 +270,6 @@ pt-br:
|
|||
EMAIL_PLACEHOLDER: "Escreva seu e-mail. Ex.: seunome@provedor.com.br"
|
||||
MESSAGE_LABEL: "Comentário"
|
||||
MESSAGE_PLACEHOLDER: "Escreva seu comentário"
|
||||
RECAPTCHA: reCAPTCHA
|
||||
SITE_LABEL: Site
|
||||
SUBMIT_COMMENT_BUTTON_TEXT: "Enviar"
|
||||
EMAIL_NEW_COMMENT_SUBJECT: "[Novo comentário] de {{ form.value.name|e }}"
|
||||
|
@ -288,7 +280,7 @@ ro:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: 'Adăugați un comentariu'
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: 'Comentarii'
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -308,7 +300,6 @@ ro:
|
|||
EMAIL_PLACEHOLDER: "Introduceți adresa Dvs. de email"
|
||||
MESSAGE_LABEL: "Comentariu"
|
||||
MESSAGE_PLACEHOLDER: "Scrieți comentariul Dvs."
|
||||
RECAPTCHA: reCAPTCHA
|
||||
SITE_LABEL: Site
|
||||
SUBMIT_COMMENT_BUTTON_TEXT: "Trimiteți"
|
||||
EMAIL_NEW_COMMENT_SUBJECT: "[Comentariu nou] from {{ form.value.name|e }}"
|
||||
|
@ -319,7 +310,7 @@ no:
|
|||
PLUGIN_COMMENTS:
|
||||
ADD_COMMENT: Skriv en kommentar
|
||||
AKISMET: Akismet
|
||||
AKISMET_APIKEY: Akismet API Key
|
||||
AKISMET_KEY_API: Akismet API Key
|
||||
AKISMET_SITE_OVERRIDE: Akismet Site Override
|
||||
COMMENTS: Kommentarer
|
||||
COMMENTS_NESTED: Nested Comments
|
||||
|
@ -339,7 +330,6 @@ no:
|
|||
EMAIL_PLACEHOLDER: "Skriv din epost adresse"
|
||||
MESSAGE_LABEL: "Kommentar"
|
||||
MESSAGE_PLACEHOLDER: "Skriv din kommentar"
|
||||
RECAPTCHA: reCAPTCHA
|
||||
SITE_LABEL: Site
|
||||
SUBMIT_COMMENT_BUTTON_TEXT: "Send"
|
||||
EMAIL_NEW_COMMENT_SUBJECT: "[Ny kommentar] fra {{ form.value.name|e }}"
|
||||
|
|
Loading…
Reference in New Issue