From e3510fbf260f6f4caecfcc08596f7d32db9b1a0a Mon Sep 17 00:00:00 2001 From: Christian Hanne Date: Mon, 25 Jul 2016 17:06:35 +0200 Subject: [PATCH 1/5] Added check for user object to form submission. (#30) --- comments.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/comments.php b/comments.php index 00b9790..b3823f1 100644 --- a/comments.php +++ b/comments.php @@ -174,10 +174,12 @@ class CommentsPlugin extends Plugin $email = filter_var(urldecode($post['email']), FILTER_SANITIZE_STRING); $title = filter_var(urldecode($post['title']), FILTER_SANITIZE_STRING); - $user = $this->grav['user']; - if ($user->authenticated) { - $name = $user->fullname; - $email = $user->email; + if (isset($this->grav['user'])) { + $user = $this->grav['user']; + if ($user->authenticated) { + $name = $user->fullname; + $email = $user->email; + } } /** @var Language $language */ From ed82d259af3b066e1e08b3b6142e499a96ef472f Mon Sep 17 00:00:00 2001 From: John Mica Date: Mon, 1 Aug 2016 07:30:50 +0100 Subject: [PATCH 2/5] add Romanian language (#31) I have added the Romanian language to the file and also have added ' ' where I thought they are needed. hope this is fine. --- languages.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/languages.yaml b/languages.yaml index 490ebf0..a2c7297 100644 --- a/languages.yaml +++ b/languages.yaml @@ -154,3 +154,24 @@ 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' + COMMENTS: 'Comentarii' + EMAIL_NOT_CONFIGURED: 'Adresa de email nu este configurată' + NEW_COMMENT_EMAIL_SUBJECT: 'Comentariu nou pentru %1$s' + NEW_COMMENT_EMAIL_BODY: '

Un nou comentariu a fost adăugat la %1$s de către %3$s (%4$s).

Pagină: %2$s

Text: %5$s

' + EMAIL_FOOTER: '' + NAME: 'Nume:' + EMAIL: 'Adresă de email:' + WRITTEN_ON: 'Scris în data de' + BY: 'de către' + NAME_LABEL: "Numele" + NAME_PLACEHOLDER: "Introduceți numele Dvs." + EMAIL_LABEL: "Email" + EMAIL_PLACEHOLDER: "Introduceți adresa Dvs. de email" + MESSAGE_LABEL: "Comentariu" + MESSAGE_PLACEHOLDER: "Scrieți comentariul Dvs." + 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!" From c1fe1a6a326e84ab34cacf1805ada16e6165da71 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Mon, 1 Aug 2016 08:37:13 +0200 Subject: [PATCH 3/5] Changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 252e56e..8f48989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.x.x +## 08/xx/2016 + +1. [](#improved) + * Added Romanian translation + # v1.2.1 ## 07/19/2016 From e4e1c79d1ae163ecc1ac5e4bf20fd70514e58b30 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 12 Aug 2016 13:27:50 +0200 Subject: [PATCH 4/5] Fix issue in storing comments cache when cache is enabled #33 --- CHANGELOG.md | 2 ++ comments.php | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f48989..3174a06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ 1. [](#improved) * Added Romanian translation +1. [](#bugfix) + * Fix issue in storing comments cache when cache is enabled [#33](https://github.com/getgrav/grav-plugin-comments/issues/33) # v1.2.1 ## 07/19/2016 diff --git a/comments.php b/comments.php index b3823f1..f8ae6f4 100644 --- a/comments.php +++ b/comments.php @@ -18,7 +18,7 @@ class CommentsPlugin extends Plugin protected $route = 'comments'; protected $enable = false; protected $comments_cache_id; - + /** * @return array */ @@ -92,7 +92,7 @@ class CommentsPlugin extends Plugin public function initializeFrontend() { $this->calculateEnable(); - + if ($this->enable) { $this->enable([ 'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0], @@ -101,12 +101,14 @@ class CommentsPlugin extends Plugin 'onTwigSiteVariables' => ['onTwigSiteVariables', 0] ]); } - + $cache = $this->grav['cache']; + $uri = $this->grav['uri']; + //init cache id - $this->comments_cache_id = md5('comments-data' . $cache->getKey()); + $this->comments_cache_id = md5('comments-data' . $cache->getKey() . '-' . $uri->url()); } - + /** * Admin side initialization */ @@ -136,7 +138,7 @@ class CommentsPlugin extends Plugin $this->grav['twig']->comments = $comments; $this->grav['twig']->pages = $this->fetchPages(); } - + /** */ public function onPluginsInitialized() @@ -325,7 +327,7 @@ class CommentsPlugin extends Plugin if ($comments = $cache->fetch($this->comments_cache_id)) { return $comments; } - + $lang = $this->grav['language']->getLanguage(); $filename = $lang ? '/' . $lang : ''; $filename .= $this->grav['uri']->path() . '.yaml'; From 7bec6fa74a73c9d816cb96082c6b90a9edaf4d93 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 12 Aug 2016 13:29:27 +0200 Subject: [PATCH 5/5] Prepare release --- CHANGELOG.md | 4 ++-- blueprints.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3174a06..aebb755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -# v1.x.x -## 08/xx/2016 +# v1.2.2 +## 08/12/2016 1. [](#improved) * Added Romanian translation diff --git a/blueprints.yaml b/blueprints.yaml index a22ae37..8cb8efa 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Comments -version: 1.2.1 +version: 1.2.2 description: Adds a commenting functionality to your site icon: comment author: