diff --git a/CHANGELOG.md b/CHANGELOG.md index aebb755..f49ee61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# v1.2.3 +## 09/15/2016 + +1. [](#improved) + * Added Croatian translation +1. [](#bugfix) + * Fix [#35](https://github.com/getgrav/grav-plugin-comments/issues/35) Allow comments to work fine on Form 2.0 too + # v1.2.2 ## 08/12/2016 diff --git a/blueprints.yaml b/blueprints.yaml index 8cb8efa..ea50097 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Comments -version: 1.2.2 +version: 1.2.3 description: Adds a commenting functionality to your site icon: comment author: diff --git a/comments.php b/comments.php index f8ae6f4..0058eff 100644 --- a/comments.php +++ b/comments.php @@ -31,6 +31,10 @@ class CommentsPlugin extends Plugin /** * Initialize form if the page has one. Also catches form processing if user posts the form. + * + * Used by Form plugin < 2.0, kept for backwards compatibility + * + * @deprecated */ public function onPageInitialized() { @@ -49,8 +53,26 @@ class CommentsPlugin extends Plugin } } + /** + * Add the comment form information to the page header dynamically + * + * Used by Form plugin >= 2.0 + */ + public function onFormPageHeaderProcessed(Event $event) + { + $header = $event['header']; + + if ($this->enable) { + if (!isset($header->form)) { + $header->form = $this->grav['config']->get('plugins.comments.form'); + } + } + + $event->header = $header; + } + public function onTwigSiteVariables() { - $this->grav['twig']->enable = $this->enable; + $this->grav['twig']->enable_comments_plugin = $this->enable; $this->grav['twig']->comments = $this->fetchComments(); } @@ -97,6 +119,7 @@ class CommentsPlugin extends Plugin $this->enable([ 'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0], 'onFormProcessed' => ['onFormProcessed', 0], + 'onFormPageHeaderProcessed' => ['onFormPageHeaderProcessed', 0], 'onPageInitialized' => ['onPageInitialized', 10], 'onTwigSiteVariables' => ['onTwigSiteVariables', 0] ]); @@ -406,4 +429,4 @@ class CommentsPlugin extends Plugin { $this->grav['admin']->dataTypesExcludedFromDataManagerPlugin[] = 'comments'; } -} +} \ No newline at end of file diff --git a/languages.yaml b/languages.yaml index a2c7297..61cc568 100644 --- a/languages.yaml +++ b/languages.yaml @@ -19,6 +19,7 @@ de: SUBMIT_COMMENT_BUTTON_TEXT: "Absenden" EMAIL_NEW_COMMENT_SUBJECT: "[Neuer Kommentar] von {{ form.value.name|e }}" THANK_YOU_MESSAGE: "Vielen Dank für den Kommentar!" + en: PLUGIN_COMMENTS: ADD_COMMENT: Add a comment @@ -62,7 +63,7 @@ es: SUBMIT_COMMENT_BUTTON_TEXT: "Enviar" EMAIL_NEW_COMMENT_SUBJECT: "[Nuevo comentario] de {{ form.value.name|e }}" THANK_YOU_MESSAGE: "Gracias por escribir su comentario!" - + fr: PLUGIN_COMMENTS: ADD_COMMENT: Ajouter un commentaire @@ -84,7 +85,29 @@ fr: SUBMIT_COMMENT_BUTTON_TEXT: "Envoyer" EMAIL_NEW_COMMENT_SUBJECT: "[Nouveau commentaire] de {{ form.value.name|e }}" THANK_YOU_MESSAGE: "Merci d'avoir rédigé votre commentaire !" - + +hr: + PLUGIN_COMMENTS: + ADD_COMMENT: Dodaj komentar + COMMENTS: Komentari + EMAIL_NOT_CONFIGURED: Email adresa nije podešena + NEW_COMMENT_EMAIL_SUBJECT: 'Novi komentar na %1$s' + NEW_COMMENT_EMAIL_BODY: '
Novi komentar je napisan na %1$s od %3$s (%4$s).
Stranica:: %2$s
Tekst: %5$s
' + EMAIL_FOOTER: '' + NAME: Ime: + EMAIL: Email: + WRITTEN_ON: Napisano je na + BY: od + NAME_LABEL: "Ime" + NAME_PLACEHOLDER: "Unesite ime" + EMAIL_LABEL: "Email adresa" + EMAIL_PLACEHOLDER: "Unesite email adresu" + MESSAGE_LABEL: "Komentar" + MESSAGE_PLACEHOLDER: "Unesite komentar" + SUBMIT_COMMENT_BUTTON_TEXT: "Pošalji" + EMAIL_NEW_COMMENT_SUBJECT: "[Novi komentar] od {{ form.value.name|e }}" + THANK_YOU_MESSAGE: "Hvala Vam što ste napisali svoj komentar!" + it: PLUGIN_COMMENTS: ADD_COMMENT: Aggiungi un commento @@ -106,7 +129,7 @@ it: SUBMIT_COMMENT_BUTTON_TEXT: "Invia" EMAIL_NEW_COMMENT_SUBJECT: "[Nuovo commento] da {{ form.value.name|e }}" THANK_YOU_MESSAGE: "Grazie per il tuo commento!" - + pl: PLUGIN_COMMENTS: ADD_COMMENT: Dodaj komentarz @@ -154,6 +177,7 @@ pt-br: SUBMIT_COMMENT_BUTTON_TEXT: "Enviar" EMAIL_NEW_COMMENT_SUBJECT: "[Novo comentário] de {{ form.value.name|e }}" THANK_YOU_MESSAGE: "Obrigada por enviar seu comentário!" + ro: PLUGIN_COMMENTS: ADD_COMMENT: 'Adăugați un comentariu' @@ -175,3 +199,25 @@ ro: SUBMIT_COMMENT_BUTTON_TEXT: "Trimiteți" EMAIL_NEW_COMMENT_SUBJECT: "[Comentariu nou] from {{ form.value.name|e }}" THANK_YOU_MESSAGE: "Vă mulțumim pentru comentariu!" + +no: + PLUGIN_COMMENTS: + ADD_COMMENT: Skriv en kommentar + COMMENTS: Kommentarer + EMAIL_NOT_CONFIGURED: Epost er ikke konfigurert + NEW_COMMENT_EMAIL_SUBJECT: 'Ny kommentar på %1$s' + NEW_COMMENT_EMAIL_BODY: 'En ny kommentar er skrevet på %1$s av %3$s (%4$s).
Side: %2$s
Tekst: %5$s
' + EMAIL_FOOTER: '' + NAME: Navn: + EMAIL: Epost: + WRITTEN_ON: Skrevet på + BY: av + NAME_LABEL: "Navn" + NAME_PLACEHOLDER: "Skriv ditt navn" + EMAIL_LABEL: "Epost" + EMAIL_PLACEHOLDER: "Skriv din epost adresse" + MESSAGE_LABEL: "Kommentar" + MESSAGE_PLACEHOLDER: "Skriv din kommentar" + SUBMIT_COMMENT_BUTTON_TEXT: "Send" + EMAIL_NEW_COMMENT_SUBJECT: "[Ny kommentar] fra {{ form.value.name|e }}" + THANK_YOU_MESSAGE: "Takk for din kommentar!" diff --git a/templates/partials/comments.html.twig b/templates/partials/comments.html.twig index d4d4493..6872180 100644 --- a/templates/partials/comments.html.twig +++ b/templates/partials/comments.html.twig @@ -1,4 +1,4 @@ -{% if grav.twig.enable %} +{% if grav.twig.enable_comments_plugin %}