Skip to content

Commit

Permalink
Merge branch 'release/1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviocopes committed Aug 12, 2016
2 parents 8e22a05 + 7bec6fa commit 1ccc720
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v1.2.2
## 08/12/2016

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

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
26 changes: 15 additions & 11 deletions comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CommentsPlugin extends Plugin
protected $route = 'comments';
protected $enable = false;
protected $comments_cache_id;

/**
* @return array
*/
Expand Down Expand Up @@ -92,7 +92,7 @@ private function calculateEnable() {
public function initializeFrontend()
{
$this->calculateEnable();

if ($this->enable) {
$this->enable([
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
Expand All @@ -101,12 +101,14 @@ public function initializeFrontend()
'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
*/
Expand Down Expand Up @@ -136,7 +138,7 @@ public function initializeAdmin()
$this->grav['twig']->comments = $comments;
$this->grav['twig']->pages = $this->fetchPages();
}

/**
*/
public function onPluginsInitialized()
Expand Down Expand Up @@ -174,10 +176,12 @@ public function onFormProcessed(Event $event)
$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 */
Expand Down Expand Up @@ -323,7 +327,7 @@ private function fetchComments() {
if ($comments = $cache->fetch($this->comments_cache_id)) {
return $comments;
}

$lang = $this->grav['language']->getLanguage();
$filename = $lang ? '/' . $lang : '';
$filename .= $this->grav['uri']->path() . '.yaml';
Expand Down
21 changes: 21 additions & 0 deletions languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<p>Un nou comentariu a fost adăugat la %1$s de către %3$s (%4$s).</p><p>Pagină: %2$s</p><p>Text: %5$s</p>'
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!"

0 comments on commit 1ccc720

Please sign in to comment.