getgrav / grav-plugin-comments Goto Github PK
View Code? Open in Web Editor NEWGrav Comments Plugin
Home Page: http://getgrav.org
Grav Comments Plugin
Home Page: http://getgrav.org
Hi,
I had problems with the comments not being translated into Brazilian Portuguese. I found out that the code in the languages.yaml file is 'pt-br'. The usual language code for Brasilian Portuguese in all system is pt-BR. So, correcting that language code in the file gets translation working for this plugin too. I did in my website, and suggest it gets done in there too. I did not do it now because I have no access.
Version 1.0.1 as installed with ./bin/gpm
is missing the nonce field in the template file:
{{ nonce_field('form', 'form-nonce') }}
Which causes all submitted comments to receive the response "ops there was a problem, please check your input and submit the form again."
The fixed template is already in the repository, its just not in a release. Users can fix the system by updating the local copy of the template at user/plugins/comments/templates/partials/comments.html.twig
with the one from
https://github.com/getgrav/grav-plugin-comments/blob/develop/templates/partials/comments.html.twig or add the above nonce field just before the closing </form>
tag
Hi.
I'm new and do not have any Grav experience. As theme I'm using Hydrogen v5.4.1. Unfortunately comments (v1.2.5) aren't working with this theme. When I switch to Antimatter, then comments are usable.
When I submit a comment, it will show an error message like:
Ups, es gibt da ein Problem. Eingabewerte bitte noch mal prüfen und das Formular erneut absenden.
German for: Houston, we have a problem.
Furthermore there is a strange line below the submit button:
<input type="hidden" id="form-nonce" name="form-nonce" value="c9563c67d98411fd8bdda80f5d4fac29" />
Is this fixable?
kind regards,
vitalitas
I am having trouble getting the comments module to work reliably. Site is hosted on Wirenine (Apache, PHP 7.0) . I have cache_enable: false
configured in the page header. I adjusted the process order to post before sending mail and I have tried it default too. It works sporadically. It does send mail, but not every time either. Last time I tried to get it working, it would work after I did a clear-cache for the the site, but only once. This time I cannot get it to post at all.
Here is my config file:
enabled: true
enable_on_routes:
- '/wallpapers'
disable_on_routes:
- /blog/blog-post-to-ignore
- /ignore-this-route
#- '/blog/daring-fireball-link'
form:
name: comments
fields:
- name: name
label: Name
placeholder: PLUGIN_COMMENTS.NAME_PLACEHOLDER
classes: form-control
autocomplete: on
type: text
validate:
required: true
- name: email
label: Email
placeholder: PLUGIN_COMMENTS.EMAIL_PLACEHOLDER
classes: form-control
type: email
validate:
required: true
- name: text
label: Comment
placeholder: PLUGIN_COMMENTS.MESSAGE_PLACEHOLDER
type: textarea
classes: form-control
validate:
required: true
- name: date
type: hidden
process:
fillWithCurrentDateTime: true
- name: title
type: hidden
evaluateDefault: grav.page.header.title
- name: lang
type: hidden
evaluateDefault: grav.language.getLanguage
- name: path
type: hidden
evaluateDefault: grav.uri.path
buttons:
- type: submit
value: PLUGIN_COMMENTS.SUBMIT_COMMENT_BUTTON_TEXT
classes: 'btn btn-md btn-black'
process:
- addComment:
- message: PLUGIN_COMMENTS.THANK_YOU_MESSAGE
- email:
subject: PLUGIN_COMMENTS.EMAIL_NEW_COMMENT_SUBJECT
body: "{% include 'forms/data.html.twig' %}"
- reset: true
I get zero comments on a page, but plenty of attempts in my mail.
It's a great and necessary plugin for any blog-style site.
But where is Flaviocopes ...?
Please come back :(
hi! loving your plugin so far. having a problem with the routes - I copied contents of comments.yaml to my user/config/plugins folder and set an enabled route, and a disabled route. I added the include to my docs template.
when I go to my enabled route it works great! but when I go to any disabled route, either the exact route or its subroute, I get this:
Server Error
Sorry, something went terribly wrong!
400 - Template "partials/comments.html.twig" is not defined in "docs.html.twig" at line 23.
For further details please review your logs/ folder, or enable displaying of errors in your system configuration.
this is entered in logs:
[2016-05-27 16:18:50] grav.CRITICAL: Template "partials/comments.html.twig" is not defined in "docs.html.twig" at line 23. - Trace: #0 /var/www/html/system/src/Grav/Common/Grav.php(186): Grav\Common\Twig\Twig->processSite(NULL) #1 /var/www/html/vendor/pimple/pimple/src/Pimple/Container.php(113): Grav\Common\Grav::Grav\Common\{closure}(Object(Grav\Common\Grav)) #2 /var/www/html/system/src/Grav/Common/Grav.php(288): Pimple\Container->offsetGet('output') #3 /var/www/html/index.php(38): Grav\Common\Grav->process() #4 {main} [] []
what do you think?
I created a page template of item-comments
for blog entries I want comments on.
I changed 4 pages from item
to item-comment
, Adding a comment on "page2" seems to work correctly, however that comment appears on the other pages instead of the correct comments. If I clear cache then all pages get the comments from "page1".
The data under user/data/comments/blog
is correct so I believe this is purely a caching issue.
Hello,
When a comment is made the mail received is showing code not interpreted.
Mail object : PLUGIN_COMMENTS.EMAIL_NEW_COMMENT_SUBJECT
Mail body :
<div>
<strong>PLUGIN_COMMENTS.NAME_LABEL</strong>:
name
</div>
<div>
<strong>PLUGIN_COMMENTS.EMAIL_LABEL</strong>:
[email protected]
</div>
<div>
<strong>PLUGIN_COMMENTS.MESSAGE_LABEL</strong>:
bla bla message
</div>
<div>
<strong></strong>:
</div>
<div>
<strong></strong>:
xxxx post title
</div>
<div>
<strong></strong>:
fr
</div>
<div>
<strong></strong>:
/blog/xxx-xxxxx-xxx
</div>
Do I have to do something in the config or is it a bug ?
Thank you in advance.
UnexpectedValueException thrown with message "RecursiveDirectoryIterator::__construct(D:/OpenServer/domains/graw/user/data/comments,D:/OpenServer/domains/graw/user/data/comments): "
Stacktrace:
#10 UnexpectedValueException in D:\OpenServer\domains\graw\user\plugins\comments\comments.php:207
#9 RecursiveDirectoryIterator:__construct in D:\OpenServer\domains\graw\user\plugins\comments\comments.php:207
#8 Grav\Plugin\CommentsPlugin:getFilesOrderedByModifiedDate in D:\OpenServer\domains\graw\user\plugins\comments\comments.php:250
#7 Grav\Plugin\CommentsPlugin:getLastComments in D:\OpenServer\domains\graw\user\plugins\comments\comments.php:126
#6 Grav\Plugin\CommentsPlugin:onPluginsInitialized in <#unknown>:0
#5 call_user_func in D:\OpenServer\domains\graw\vendor\symfony\event-dispatcher\EventDispatcher.php:164
#4 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in D:\OpenServer\domains\graw\vendor\symfony\event-dispatcher\EventDispatcher.php:53
#3 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in D:\OpenServer\domains\graw\vendor\rockettheme\toolbox\Event\src\EventDispatcher.php:23
#2 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in D:\OpenServer\domains\graw\system\src\Grav\Common\Grav.php:377
#1 Grav\Common\Grav:fireEvent in D:\OpenServer\domains\graw\system\src\Grav\Common\Grav.php:208
#0 Grav\Common\Grav:process in D:\OpenServer\domains\graw\index.php:37
Comments v1.0.0
I've installed the comments plugin, version 1.1.2, and followed the instructions to display the form on all blog pages. However, when I submit the form, it doesn't save any comments. As a sanity check, I added this to comments.php:
public function onFormProcessed(Event $event)
{
$form = $event['form'];
$action = $event['action'];
$params = $event['params'];
$grav['log']->info("here"); // Debug statement
if (!$this->active) {
return;
}
The message does not show up in tail -f logs/grav.log
. I have configured my permissions using the following script:
#!/bin/sh
chown www-data:www-data .
chown -R www-data:www-data *
find . -type f -not -name "fix-permissions.sh" | xargs chmod 664
find ./bin -type f | xargs chmod 775
find . -type d | xargs chmod 775
find . -type d | xargs chmod +s
umask 0002
Are there any tricks to figure out why onFormProcessed
doesn't seem to be called? Is the debug statement a valid check?
I know this is in the pipeline, and would just like to add my support for this as a much-needed enhancement.
https://en.wikipedia.org/wiki/Linkback
Refback, trackback, pingback and webmention
I would expect to see the newest post at the bottom, not on the top. How could i change that?
In the comments.yaml
section on routes, some of the values seem to be set as strings, others not.
enable_on_routes:
- '/blog'
disable_on_routes:
- /blog/blog-post-to-ignore
- /ignore-this-route
#- '/blog/daring-fireball-link'
Does it make any difference?
On the name input field, the autofocus
attribute is set. I think this is why when my pages with the comments template load, they scroll to the bottom and focus the name input. Is this something that can be disabled, or is this intended behavior?
The subject line does not display wildcard text, but "PLUGIN_COMMENTS.EMAIL_NEW_COMMENT_SUBJECT"
I successfully added the comment plugin and I can add comments to my page.
However, the comment section shows up twice:
I'm using the antimatter theme and Grav 1.3.1
You can see what I mean here: http://whiskeybravo.art/a-good-old-friend
I used the original code from the plugin's readme file:
{% embed 'partials/base.html.twig' %}
{% block content %}
{% if config.plugins.breadcrumbs.enabled %}
{% include 'partials/breadcrumbs.html.twig' %}
{% endif %}
<div class="blog-content-item grid pure-g-r">
<div id="item" class="block pure-u-2-3">
{% include 'partials/blog_item.html.twig' with {'blog':page.parent, 'truncate':false} %}
</div>
<div id="sidebar" class="block size-1-3 pure-u-1-3">
{% include 'partials/sidebar.html.twig' with {'blog':page.parent} %}
</div>
</div>
{% include 'partials/comments.html.twig' with {'page': page} %}
{% endblock %}
{% endembed %}
I installed grav 1.0.0 RC6 and then the comments plugin. I took a look at the 'Usage' section on this github page and did what was described:
Add the line to templates/item.html.twig
item.html.twig.zip
Copy comments.yaml
from user/plugins/comments/
to user/config/plugins/
Since i have a blog page with a child post and the comments.yaml
already mentioned - '/blog'
under the 'enable_on_routes:' section, i did't change anything there - only removed every entry under disable_on_routes:
because i want to show comments on every blog post.
comments.yaml.zip
But i still can't add comments to my example blog post. Here is the page structure so far:
Can someone please point me in the right direction and show me what i did wrong?
Hello,
When I have comments with a date more than 7 days ago the comments page in the admin plugin (at admin/comments) is broken.
I would like to precise that I'm trying to migrate an old site into grav that's why I'm entering the comments with an old date.
Could you help ?
Thanks
Here's a list of features that would help to make Comments plugin even better!
I removed the email form from my comments.yaml config.
Because I was getting
Address in mailbox given [] does not comply with RFC 2822, 3.6.2
Maybe somehow related to this issue: getgrav/grav-plugin-form#27
Anyway, when I remove the email form, I get following error:
Undefined index: email
Hi!
How does one translate the frontmatter defined in /users/plugins/comments/comments.yaml
? The translations as defined in /users/plugins/comments/languages.yaml
show up just fine:
and I guess I could also translate the submit button text in my languages theme file. The form labels and placeholders as defined in /users/plugins/comments/comments.yaml
, as far as I can see, cannot be translated.
Is there a way to do this?
At multiple places in the code and the config file "recatpcha" is used instead of "recaptcha".
While it might work, it feels wrong ;-).
Hello,
I created this issue in order to know what's next for this plugin?
It's a great plugin but we could add several features to make it even better:
In fact, something like the Wordress comment system + this plugin.
Thanks and keep up the good work!
I use this plugin in its 1.2.7 version with Grav 1.3.4. And it does not work (blank result).
Try 1.2.2 and the comment form appears, but no comments are added after submit.
Anyone can confirm me that does it works with the grav latest version?
Hello. I'm working on an migration script to import my posts and comments from Google Blogger to Grav. Everything working fine, the comments are also rendered normally on the live pages.
But when try to view the latest comments on "localhost/grav/admin/comments/", I get an error like this: "Call to a member function getTimestamp() on boolean".
The comment.yaml files are imported like this:
title: 'Xposed Installer APK Fix Android 4.4.4 by Solarwarez Application Download'
lang: false
comments:
- {"text":"gan saya pake cyanogenMod 12.1 beta cocoknya pake xposed installer apa","date":"2016-03-30T03:31:10.200+07:00","author":"Hendry Wijayanto","email":"[email protected]","uri":"https://www.blogger.com/profile/16304488146178401806"}
- {"text":"Hmm... Kalo gak salah ada xposed khusus buat Android Lollipop, cari aja di repo.xposed.info","date":"2016-03-30T11:41:36.355+07:00","author":"iday raD","email":"[email protected]","uri":"https://www.blogger.com/profile/13765705053643369839"}
- {"text":"ok makasih gan.blognya bagus selalu update","date":"2016-03-31T02:12:50.493+07:00","author":"Hendry Wijayanto","email":"[email protected]","uri":"https://www.blogger.com/profile/16304488146178401806"}
Is there a way to approve comments before they are published?
Hi,
I face a strange problem. I installed the plugin and grav (current developer versions) delivers different page content on reloads concerning the comment plugin. The comment block is missing. The rest of the page is ok.
I cleared all caches. I tried on two different host environments (nginx, apache with different php variants).
So I thought it might be connected to {% if grav.twig.enable %} in the template file. If I remove it I can see that the comment block is always printed on reloads, but now sometimes entered comments are instead missing from time to time.
It seems to be some sort of race condition.
Any advice what I might try?
Best regards,
Form v1.3.0-rc.4
Comments 1.1.4
Grav 1.1.0-rc.3
Found a bug. Fixed it.
I don't really know how to use github... so I'll write here and then try to suggest the edit.
Within comments.php line 192
the post variable grabbing lines should be updated from:
$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);
$title = filter_var(urldecode($post['title']), FILTER_SANITIZE_STRING);
to
$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);
$title = filter_var(urldecode($_POST['title']), FILTER_SANITIZE_STRING);
This was breaking the functionality of almost the whole plugin.
at qwyk.ly (using learn2 template) I always receive an error when I enter a comment:
Oops there was a problem, please check your input and submit the form again.
I am unable to find where this error is coming from - any help gratefully received
Hi,
In the Configuration - System of Grav, you can modify the short and long date format. However, it seems grav-plugin-comments does not use this function. (I put both with short date, but my comments are still using long date)
Any way to fix it?
Thank you
This is the first time I try Comments plugin. The form is shown but comment is not saved.
I have tried on both localhost and a live site (email is working) but the problem still exists.
I have uploaded the site at https://github.com/tranduyhung/grav-skeleton-blog-site, I really appreciate if you can take a look and let me know what I am doing wrong.
I have also tried to modify the form from
form:
name: comments
fields:
to
forms:
comments:
fields:
but still the same.
As I have debugged, onFormProcessed function is never called.
Thank you!
With every comment, an email gets sent. Can we have options to turn off emailing for specific routes, similar to enable_on_routes:
and disable_on_routes:
?
suggesting email_on_routes
or no_email_on_routes
When a page is deleted (from the admin panel or otherwise), its associated comments file remains in place. For most people that's probably not a problem visible in the front-end, but it creates some clutter. Not a big deal considering the likely size of the files involved. For me it's a bit more of a problem because I show the most recent comments in a sidebar, so they'll keep showing up even if their article is deleted or made invisible.
Would it be useful to have something in the plugin's admin page that checks for orphaned comments and offers to purge them? It could also offer to reroute comments for pages that have been moved or renamed.
user can post comments (comment email sent) without a need of verification (Google)!
after the last grav update, comments have disappeared!
it seems the comments plugin is interpreting the enable_on_routes variable differently now.
i always had it as
enable_on_routes:
- '/blog'
(this is still the default currently)
changing it to
enable_on_routes:
- '/'
makes the comments re-appear.
my interpretation:
in my system.yaml, i'm telling grav to hide the ‘/blog’ route in urls.
it would seem that after the grav update, this is also internally applied to the twig environment?
am i correct?
also see here
here's a working option for comments.yaml
this way the email form is not shown and an email address is not required
name: email
label: optional
placeholder: email
type: email
type: hidden
validate
required: false
If I'm not mistaken, I see that the plugin already checks if a commenter is logged in through the Login plugin and replaces their name and e-mail with those of their account if a match is found:
if (isset($this->grav['user'])) {
$user = $this->grav['user'];
if ($user->authenticated) {
$name = $user->fullname;
$email = $user->email;
}
}
However there is no check in place to verify that a comment was posted by a logged in user, and notably by the admin, so any guest can post with the same name and e-mail with the same result. Would it be difficult to add such a parameter to each comment in a format like {{comment.author.level}} (guest/.../admin) so one could differentiate them in the output? This would let me avoid commenters usurping other people's names by using specific CSS and markings on authenticated comments and allow me to integrate an avatar system into it.
Is there something like $this->grav['userlevel']
that I can simply plug into onFormProcessed()
where it will be picked up seamlessly by the rest of the system?
The sample comments.html.twig shows:
{% if grav.twig.enable %}
Which never is set even when twig is enabled in config/system.yaml
33 process:
34 markdown: true
35 twig: true
I was able to make the comments come up by deleting the {% if grav.twig.enable %}
and it's corresponding {% endif %}
Hi
After a recent update I'm finding the comments plug-in is no longer working.
To remove misconfiguration issues within my theme I have downloaded the "Helium Site" theme (https://github.com/gantry/gantry5), added in the grav-plugin-comments plugin and updated its configuration file to be enabled on the '/pages/blog' route.
The plugin appears correctly, but when POSTing a comment to the blog post nothing appears to happen.
By adding a liberal smattering of trace statements through the code it appears the function onFormProcessed within grav-plugins-conmments is never getting called. The same appears to be true for the form plugin as well.
I have obviously got some major misconfigraton going on... but can't figure out what, especially as the only change I made to the "Helium Site" theme was to download the grav-plugin-comments plugin and update its comments.yaml to enable on the appropriate route.
Any ideas what I may be doing wrong?
I am running grav v1.1.1 with comment plugin v1.2.1 (git commit c1fe1a6). The commenting works except when the user submits they get an error page that says "Class 'Grav\Plugin\Utils' not found"
In the top right box it shows /var/www/grav/grav-plugin-form/form.php with lines 123,124, 125 highlighted:
case 'reset':
if (Utils::isPositive($params)) {
$this->form->reset();
Reloading the page shows the comment, and I receive the notification email.
Thanks for your work so far.
I just tried to install the plugin on Grav v1.1.1, PHP 5.5.26
No matter where I add the include line of the twig-template I always get the following error.
0 - An exception has been thrown during the rendering of a template ("Undefined property: Grav\Common\Grav::$user") in "partials/comments.html.twig" at line 14.
Seems like the problem was introduced in commit ee60853. If I remove the check in this commit, the problem is gone (also the feature you introduced in this commit no longer works).
Hi,
I'm using continue_link: false
in frontmatter for some of my blog posts (because the continue_link is always visible regardless of summary settings). This frontmatter disables the comment form.
I've worked around the issue by tweaking my blog_item.html.twig to include the comment partial after the {% if not truncate %}
line.
I admit I haven't researched the issue much, because it's very late and I just noticed it, but I can provide more info/QA as needed.
I would like a latest comments widget that could be placed in the sidebar to pull from all articles/pages. I went and hacked something together based on the admin panel display, but it could use someone more knowledgeable bringing it in line with Grav's standards and generally making it less hacky.
Also, one missing feature is that I would like to link to each comment's post/page, and I don't know how to safely derive the URLs from the filePath.
I added this bit to function initializeFrontend() in comments.php (~line 130):
EDIT: SEE UPDATED CODE BELOW
I created a new function based on getLastComments(); essentially the same with irrelevant parts removed and a limit to the array size:
EDIT: SEE UPDATED CODE BELOW
Example output (you could also show the date):
EDIT: SEE UPDATED CODE BELOW
I hope posting it like this isn't too inconvenient. Any help would be appreciated!
Hello!! i installed the plugin and it appears on my page. i mention that i still didn't fill the email plugin infos, is this the reason why when i click the " submit" the comments doesn"t go to data==>comments?
If like me you have no language set, then this plugin doesn't work.
You must go to Configuration and add "en" as an acceptable language. Do this and everything works.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.