Skip to content

Commit

Permalink
Merge branch 'release/1.2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Sep 10, 2020
2 parents 11807f5 + b21707d commit c04ddbc
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 21 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# v1.2.8
## 09/10/2020

1. [](#improved)
* Improved some translations
1. [](#bugfix)
* Fix for PHP 7.4 [#81](https://github.com/getgrav/grav-plugin-comments/issues/81)
* Fix for allowing path in form submission [#86](https://github.com/getgrav/grav-plugin-comments/issues/86) [#80](https://github.com/getgrav/grav-plugin-comments/issues/80)

# v1.2.7
## 05/12/2017

Expand Down
4 changes: 3 additions & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Comments
version: 1.2.7
type: plugin
slug: comments
version: 1.2.8
description: Adds a commenting functionality to your site
icon: comment
author:
Expand Down
19 changes: 15 additions & 4 deletions comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,17 @@ public function onFormPageHeaderProcessed(Event $event)
}

public function onTwigSiteVariables() {
$this->grav['twig']->enable_comments_plugin = $this->enable;
$this->grav['twig']->comments = $this->fetchComments();
// Old way
$enabled = $this->enable;
$comments = $this->fetchComments();

$this->grav['twig']->enable_comments_plugin = $enabled;
$this->grav['twig']->comments = $comments;

// New way
$this->grav['twig']->twig_vars['enable_comments_plugin'] = $enabled;
$this->grav['twig']->twig_vars['comments'] = $comments;

}

/**
Expand Down Expand Up @@ -189,8 +198,9 @@ public function onFormProcessed(Event $event)
case 'addComment':
$post = isset($_POST['data']) ? $_POST['data'] : [];

$path = $this->grav['uri']->path();

$lang = filter_var(urldecode($post['lang']), FILTER_SANITIZE_STRING);
$path = filter_var(urldecode($post['path']), FILTER_SANITIZE_STRING);
$text = filter_var(urldecode($post['text']), FILTER_SANITIZE_STRING);
$name = filter_var(urldecode($post['name']), FILTER_SANITIZE_STRING);
$email = filter_var(urldecode($post['email']), FILTER_SANITIZE_STRING);
Expand Down Expand Up @@ -347,7 +357,8 @@ private function fetchComments() {
$filename = $lang ? '/' . $lang : '';
$filename .= $this->grav['uri']->path() . '.yaml';

$comments = $this->getDataFromFilename($filename)['comments'];
$data = $this->getDataFromFilename($filename);
$comments = isset($data['comments']) ? $data['comments'] : null;
//save to cache if enabled
$cache->save($this->comments_cache_id, $comments);
return $comments;
Expand Down
37 changes: 23 additions & 14 deletions languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,25 @@ it:

ja:
PLUGIN_COMMENTS:
ADD_COMMENT: コメントを追加する
ADD_COMMENT: コメントする
COMMENTS: コメント
EMAIL_NOT_CONFIGURED: メールアドレスは設定さていません
NEW_COMMENT_EMAIL_SUBJECT: '%1$sについて新しいコメント'
NEW_COMMENT_EMAIL_BODY: '<p>新しいコメントが%1$sについて%3$sから(%4$s)書かれた.</p><p>ページー : %2$s</p><p>文書 : %5$s</p>'
EMAIL_NOT_CONFIGURED: メールアドレスが設定さていません
NEW_COMMENT_EMAIL_SUBJECT: '%1$sの新しいコメント'
NEW_COMMENT_EMAIL_BODY: '<p>%1$sに新しいコメントが%3$sから(%4$s)に書かれました。</p><p>ページ : %2$s</p><p>内容 : %5$s</p>'
EMAIL_FOOTER: ''
NAME: 名前 :
EMAIL: メールアドレス :
WRITTEN_ON: に書かれた
BY:
WRITTEN_ON: 投稿日時
BY: By
NAME_LABEL: "名前"
NAME_PLACEHOLDER: "お名前を"
EMAIL_LABEL: "メールアドレスを"
EMAIL_PLACEHOLDER: "ご自分のメールアドレスをここに..."
NAME_PLACEHOLDER: "名前を入力してください"
EMAIL_LABEL: "メールアドレス"
EMAIL_PLACEHOLDER: "メールアドレスを入力してください"
MESSAGE_LABEL: "コメント"
MESSAGE_PLACEHOLDER: "コメントをここに"
SUBMIT_COMMENT_BUTTON_TEXT: "送信する"
EMAIL_NEW_COMMENT_SUBJECT: "[新しいコメント] {{ form.value.name|e }}から"
THANK_YOU_MESSAGE: "コメントを書いてくださいましてありがとうございました"
MESSAGE_PLACEHOLDER: "コメントを入力してください"
SUBMIT_COMMENT_BUTTON_TEXT: "送信"
EMAIL_NEW_COMMENT_SUBJECT: "[新しいコメント] {{ form.value.name|e }}から"
THANK_YOU_MESSAGE: "コメントありがとうございます"

nl:
PLUGIN_COMMENTS:
Expand Down Expand Up @@ -193,12 +193,21 @@ ru:
COMMENTS: Комментарии
EMAIL_NOT_CONFIGURED: Email не настроен
NEW_COMMENT_EMAIL_SUBJECT: 'Новый комментарий к %1$s'
NEW_COMMENT_EMAIL_BODY: '<p>Новый комментарий был сделан на %1$s by %3$s (%4$s).</p><p>Страница: %2$s</p><p>Текст: %5$s</p>'
NEW_COMMENT_EMAIL_BODY: '<p>Новый комментарий на %1$s от %3$s (%4$s).</p><p>Страница: %2$s</p><p>Текст: %5$s</p>'
EMAIL_FOOTER: ''
NAME: Имя:
EMAIL: Email:
WRITTEN_ON: Написан в
BY: от
NAME_LABEL: "Имя"
NAME_PLACEHOLDER: "Введите свое имя"
EMAIL_LABEL: "Email"
EMAIL_PLACEHOLDER: "Введите свой email адрес"
MESSAGE_LABEL: "Комментарий"
MESSAGE_PLACEHOLDER: "Введите свой комментарий"
SUBMIT_COMMENT_BUTTON_TEXT: "Отправить"
EMAIL_NEW_COMMENT_SUBJECT: "[Новый комментарий] от {{ form.value.name|e }}"
THANK_YOU_MESSAGE: "Благодарим за ваш комментарий!"

pt-br:
PLUGIN_COMMENTS:
Expand Down
4 changes: 2 additions & 2 deletions templates/partials/comments.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if grav.twig.enable_comments_plugin %}
{% if enable_comments_plugin %}
{% set scope = scope ?: 'data.' %}

<h3>{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}</h3>
Expand Down Expand Up @@ -46,7 +46,7 @@
<h3>{{'PLUGIN_COMMENTS.COMMENTS'|t}}</h3>

<table>
{% for comment in grav.twig.comments|array_reverse %}
{% for comment in comments|array_reverse %}
<tr>
<td>
{{comment.text}}
Expand Down

0 comments on commit c04ddbc

Please sign in to comment.