Compare commits

...

114 Commits

Author SHA1 Message Date
leetNightshade 43ae3a78a6 Added nested comment image.
Added nested comment image.
2019-01-04 04:09:38 +00:00
leetNightshade 4698549b88 Changed it so you can only nest on comments with an ID, which means old
comments can't be replied to. OH, I reverted the change from using
CompiledYamlFile because I don't like how the RocketTheme Yaml dump is
setup, it breaks comments up onto multiple lines. Thus, I also removed
the reply button on those comments. You can still attempt to reply to a
comment if you're hacking around the frontend, but as long as the
comment doesn't have an ID it shouldn't work. TODO: Make the backend
comment panel work again.
2019-01-03 19:49:02 -08:00
leetNightshade be0eca0ff5 Merge https://github.com/codeshell/grav-plugin-comments into develop 2019-01-03 16:13:23 -08:00
leetNightshade 94134e2575 Adding gravatar support and nice time display, and classes and div's for
customizing comment formatting.
2018-06-29 17:06:21 -07:00
Ernst 43a70fe64a Merge branch 'develop' of https://github.com/leetNightshade/grav-plugin-comments into develop 2017-12-06 12:59:51 -08:00
Ernst 3632251cea Cleaning up a little, reorganizing. Was Trying to look into recatpcha
support, but decided not to bother, keep things simple with verification
server side for now with no added javascript.
2017-12-06 12:58:44 -08:00
Brian b56c5927f7
Minor readme update. 2017-12-05 17:08:25 -08:00
Brian f6a4204ed2
Akismet support.
Stood up Akismet support.
2017-12-05 17:06:23 -08:00
Ernst 9bff3a3397 Merge branch 'develop' of https://github.com/leetNightshade/grav-plugin-comments into develop 2017-12-05 17:04:27 -08:00
Ernst 6a6b1973a1 Adding basic Akismet stuff. Seems to work. Still working on it, make
sure it's okay.
2017-12-05 17:03:12 -08:00
Brian 19d5ef9f1f
Added screenshot, updated readme.
Other forks don't update readme or show what they did, so I thought I'd take the first [rough] step.
2017-12-04 18:17:55 -08:00
Ernst 607e0fa6d4 Format was messed up. 2017-12-01 17:54:29 -08:00
Ernst a52c1b2f6d Imported Pingbacks can display or be toggled off. You can also display
comments but have adding new ones disabled. TODO: allow disabling
comments on a per page basis.
2017-12-01 17:53:07 -08:00
codeshell ee89c2bdca fix ajax display when posting first comment on a page 2017-10-30 12:53:13 +01:00
codeshell bd1799cc7e add recent comments widget as plugin template (partials/recentcomments.html.twig) 2017-10-30 12:18:50 +01:00
codeshell 9179453c85 fix absolute class path
add recent comments widget as twig function
add save authentication and admin status with comments
2017-10-29 01:49:09 +02:00
Thorsten Witteler 905c04937c + ajax-delete comments via front end (if logged in with super admin priviledges) 2017-10-25 02:58:07 +02:00
Thorsten Witteler b4ab9a5111 finish nested comment implementation 2017-10-24 02:57:44 +02:00
Thorsten Witteler 0936de7c1d remove sorting from twig template (breaks nested comments) 2017-10-23 16:56:13 +02:00
Thorsten Witteler d70f109776 validate ajax input 2017-10-23 13:39:49 +02:00
Thorsten Witteler cace16f606 change nonce action from "form" to "comments" 2017-10-23 13:39:31 +02:00
Thorsten Witteler 868d7b1231 add built in css 2017-10-23 13:37:52 +02:00
Thorsten Witteler de3a683cbe prepare ajax 2017-10-20 15:08:26 +02:00
Thorsten Witteler 0c00764ef5 Merge branch 'ajax-nested-comments' into develop 2017-10-20 14:09:02 +02:00
Thorsten Witteler 7d153816f9 prepare ajax 2017-10-20 14:06:02 +02:00
Thorsten Witteler 6d458f8fa4 add level calculation 2017-10-19 23:06:47 +02:00
Thorsten Witteler 018a42a3dc add level calculation 2017-10-19 22:00:00 +02:00
Thorsten Witteler 1bc97a31e7 nested template 2017-10-19 19:40:02 +02:00
Thorsten Witteler 9387fba6ed nested template 2017-10-19 18:53:40 +02:00
Thorsten Witteler e8417c6a0e add index file to user data
add data files to page folder
2017-10-19 17:42:20 +02:00
Flavio Copes 563d7af096 Merge branch 'release/1.2.7' into develop 2017-05-12 14:55:56 +02:00
Flavio Copes 0a5a7a2e9c Prepare release 2017-05-12 14:55:49 +02:00
Flavio Copes 42ff556420 Fix issue with scope for autofilled values 2017-05-12 14:40:51 +02:00
Flavio Copes 228ac73ba8 Fix comment form processing 2017-05-11 19:42:43 +02:00
Flavio Copes f1b1f74348 Fix type in example config 2017-04-14 16:19:33 +02:00
Flavio Copes fac87e9bb5 Move captcha over email, fix #45 2017-02-26 22:05:26 +01:00
Flavio Copes b3da8123a9 Changelog 2017-02-07 14:01:07 +01:00
tidiview d8e1e2dfe2 created a japanese translation ♪ (#43) 2017-02-07 13:59:35 +01:00
Flavio Copes 57089be565 Merge branch 'release/1.2.6' into develop 2017-01-09 10:13:34 +01:00
Flavio Copes cf3284e540 Prepare release 2017-01-09 10:13:13 +01:00
Flavio Copes 4e88431863 Fix #41 using Comments in a Gantry-powered theme did not escape the comment form token correctly 2017-01-09 10:12:23 +01:00
Andy Miller fbf7ee0bc8 Use existing `Utils::startsWith()` method 2016-09-28 09:39:53 -06:00
Flavio Copes e5e254b1a5 Merge branch 'release/1.2.5' into develop 2016-09-16 09:51:53 +02:00
Flavio Copes 201ffedd18 Prepare release 2016-09-16 09:51:44 +02:00
Flavio Copes 7b4f3a4e8d Fix showing comments older than one week in the "latest comments" view 2016-09-16 09:51:01 +02:00
Flavio Copes c1e3f69a96 Merge branch 'release/1.2.4' into develop 2016-09-15 18:36:45 +02:00
Flavio Copes d2d8e68943 Prepare release 2016-09-15 18:36:33 +02:00
Flavio Copes f945d98cfb Fix missing Twig template error if route is excluded but twig is loaded 2016-09-15 18:08:52 +02:00
Flavio Copes cf31dcefe8 Merge branch 'release/1.2.3' into develop 2016-09-15 16:47:41 +02:00
Flavio Copes e699df4430 Prepare release 2016-09-15 16:47:33 +02:00
Flavio Copes 9ade9bb637 Allow comments to work fine on Form 2.0 too 2016-09-15 15:18:14 +02:00
Teknix 61b7cd43d1 Added Norwegian translation (#36)
Also fixed some padding between the language groups
2016-09-15 11:50:09 +02:00
Flavio Copes 18b3150132 Changelog 2016-08-25 14:52:22 +02:00
Saša Janiška 35a1ac159d add Croatian translation (#34) 2016-08-25 14:51:41 +02:00
Flavio Copes d574f063cc Merge branch 'release/1.2.2' into develop 2016-08-12 13:29:53 +02:00
Flavio Copes 7bec6fa74a Prepare release 2016-08-12 13:29:27 +02:00
Flavio Copes e4e1c79d1a Fix issue in storing comments cache when cache is enabled #33 2016-08-12 13:27:50 +02:00
Flavio Copes c1fe1a6a32 Changelog 2016-08-01 08:37:13 +02:00
John Mica ed82d259af 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.
2016-08-01 08:30:50 +02:00
Christian Hanne e3510fbf26 Added check for user object to form submission. (#30) 2016-07-25 17:06:35 +02:00
Flavio Copes 6d10e0c054 Merge branch 'release/1.2.1' into develop 2016-07-19 12:06:20 +02:00
Flavio Copes 4def8b6226 Prepare release 2016-07-19 12:05:55 +02:00
Flavio Copes 6a846da4e3 Merge branch 'master' into develop 2016-07-19 12:05:21 +02:00
Flavio Copes 3a09f47bc6 Fix #28 Check if Login plugin is installed before checking for user object 2016-07-19 12:04:17 +02:00
Flavio Copes 706cd6b778 Merge branch 'release/1.2.0' into develop 2016-07-14 21:53:04 +02:00
Flavio Copes b7b109b67c Merge branch 'release/1.2.0' 2016-07-14 21:53:00 +02:00
Flavio Copes ee89137f81 Prepare release 2016-07-14 21:52:54 +02:00
Flavio Copes ee608539d4 Handle logged in users by not requiring username/email
Still post them as hidden to overcome validation, but still overwrite
the values in backend to avoid manipulation
2016-06-30 14:08:59 +02:00
Flavio Copes 0cf90a74d7 Reset comments form after submit 2016-06-30 11:41:12 +02:00
Flavio Copes 60c8d091e6 Rework a bit the organization of the code. Added cache for comments 2016-06-29 18:56:06 +02:00
gitname 04078ba7e0 Fix typos (#26) 2016-06-03 10:26:16 +02:00
Flavio Copes c0265d5524 Fill changelog 2016-05-30 11:19:22 +02:00
Flavio Copes a95d0abd84 Prevent a missing template problem on ignored routes 2016-05-30 11:16:08 +02:00
Raul E Watson 6a70718fc9 Add Spanish (es) translation (#25) 2016-05-30 10:18:16 +02:00
Renata fd106be103 Add Brazilian Portuguese (pt-br) translation (#23) 2016-05-05 12:56:44 +02:00
Flavio Copes 0605e9450e Merge pull request #21 from janklostermann/patch-1
Enhanced German translation
2016-04-25 20:13:42 +02:00
janklostermann 6b64dcf800 Enhanced German translation 2016-04-25 16:12:30 +02:00
Flavio Copes 75ddc791d4 Merge pull request #20 from MATsxm/patch-2
🇫🇷 update + arranged alphabetically
2016-04-11 17:55:40 +02:00
Marc-Antoine Thevenet 570467430a 🇫🇷 update + arranged alphabetically
🇫🇷 update + arranged alphabetically
2016-04-11 11:40:51 -04:00
Flavio Copes 7014a07879 Drop beta message 2016-03-31 11:10:16 +02:00
Flavio Copes 9d38761d44 Allow translating the comments form 2016-03-24 09:03:28 +01:00
Flavio Copes 3919f7d764 Merge pull request #18 from MATsxm/patch-1
🇫🇷 typos
2016-03-16 20:45:23 +01:00
Marc-Antoine Thevenet afd22bea5b 🇫🇷 typos
🇫🇷 typos
2016-03-16 15:04:47 -04:00
Andy Miller f764c0f8c0 Merge branch 'release/1.1.4' 2016-02-05 14:22:04 -07:00
Andy Miller 8ad309d157 Merge branch 'release/1.1.4' into develop 2016-02-05 14:22:04 -07:00
Andy Miller ee8a0f127a version update 2016-02-05 14:21:55 -07:00
Andy Miller e786144ba3 changelog updated 2016-02-05 13:46:12 -07:00
Flavio Copes acb0b42354 Merge pull request #17 from geraldhansen/develop
add german translation
2016-01-30 10:40:56 +01:00
Gerald Hansen ed101387d4 add german translation 2016-01-30 02:27:02 +01:00
Flavio Copes bacbbd1b57 Use common language strings in blueprints 2016-01-21 14:41:22 +01:00
Karol Orzeł ad9ae0a0c0 Polish translation 2016-01-20 09:44:17 +01:00
Flavio Copes cdee9fa1fa Avoid adding the onTwigTemplatePaths if it's not enabled on this page 2016-01-10 14:59:12 +01:00
Andy Miller 47ee19d48b Merge branch 'release/1.1.3' 2016-01-06 12:36:53 -07:00
Andy Miller 87c6d7eb95 Merge branch 'release/1.1.3' into develop 2016-01-06 12:36:53 -07:00
Andy Miller 440c57434e version update 2016-01-06 12:36:44 -07:00
Flavio Copes 1f46ce7e8b Fix year! 2016-01-06 09:44:42 +01:00
Flavio Copes 9c20e4f6e5 Update changelog 2016-01-06 09:44:23 +01:00
Flavio Copes 44e64c50a1 Merge pull request #15 from khanduras/patch-1
Update README.md
2015-12-21 09:06:18 +01:00
khanduras 7aabf397f6 Update README.md
Minor edit for email plugin
2015-12-20 23:20:04 -08:00
Flavio Copes a6476ab527 Increase priority for onPageInitialized in the comments plugin over the form plugin one 2015-12-20 10:14:51 +01:00
Flavio Copes f25fbd7e20 Disable captcha by default, add instructions on how to add it 2015-12-12 14:28:10 +01:00
Flavio Copes aa551e9cea Merge remote-tracking branch 'origin/develop' into develop 2015-12-11 21:46:40 +01:00
Andy Miller a88f5e053f Merge branch 'release/1.1.1' 2015-12-11 13:15:16 -07:00
Andy Miller af9322b00f Merge branch 'release/1.1.1' into develop 2015-12-11 13:15:16 -07:00
Andy Miller b3c1a1c750 Fix changelog format 2015-12-11 13:15:07 -07:00
Flavio Copes 501ce930a1 Merge branch 'release/1.1.2' into develop 2015-12-11 12:21:35 +01:00
Flavio Copes 6629b505f2 Prepare release 2015-12-11 12:21:11 +01:00
Flavio Copes 825cfe1b1b Fix #12 Avoid double encoding comment text output and author name, already filtered and escaped when stored 2015-12-11 12:19:55 +01:00
Flavio Copes 7b8d4048b1 Merge branch 'release/1.1.1' into develop 2015-12-10 20:37:34 +01:00
Flavio Copes 7858289def Prepare release 2015-12-10 20:36:26 +01:00
Flavio Copes 897451312c Drop autofocus on comments form 2015-12-10 10:49:09 +01:00
Flavio Copes 1a6bb46f86 Merge branch 'release/1.1.0' into develop 2015-11-24 15:35:55 +01:00
Flavio Copes 42ede280e9 Merge branch 'release/1.1.0' 2015-11-24 15:30:21 +01:00
Andy Miller 884049ff22 Merge branch 'release/1.0.0' 2015-10-21 16:34:32 -06:00
14 changed files with 2078 additions and 315 deletions

View File

@ -1,14 +1,106 @@
# v1.2.7
## 05/12/2017
1. [](#improved)
* Added Japanese translation
* Move captcha over email [#45](https://github.com/getgrav/grav-plugin-comments/issues/45)
1. [](#bugfix)
* Fix comment form processing
* Fix issue with scope for autofilled values
# v1.2.6
## 01/09/2017
1. [](#improved)
* Use existing `Utils::startsWith()` method
1. [](#bugfix)
* Fix [#41](https://github.com/getgrav/grav-plugin-comments/issues/41) using Comments in a Gantry-powered theme did not escape the comment form token correctly
# v1.2.5
## 09/16/2016
1. [](#bugfix)
* Fix [#37](https://github.com/getgrav/grav-plugin-comments/issues/37) showing comments older than one week in the "latest comments" view
# v1.2.4
## 09/15/2016
1. [](#bugfix)
* Fix missing Twig template error if route is excluded but twig is loaded
# 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
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
1. [](#bugfix)
* Check if Login plugin is installed before checking for user object [#28](https://github.com/getgrav/grav-plugin-comments/issues/28)
# v1.2.0
## 07/14/2016
1. [](#improved)
* Prevent a missing template problem on ignored routes
* Allow to translate the comments form
* Added spanish and brazilian portuguese translations
* Enhanced german, russian and french translations
* Added cache for comments
* Handle logged in users by not requiring username/email
* Reset the comments form after a comment is submitted
# v1.1.4
## 02/05/2016
1. [](#improved)
* Added german and polish
* Avoid listening on onTwigTemplatePaths if not enabled
# v1.1.3
## 01/06/2016
1. [](#improved)
* Disable captcha by default, added instructions on how to enable it
1. [](#bugfix)
* Increase priority for onPageInitialized in the comments plugin over the form plugin one to prevent an issue when saving comments
# v1.1.2
## 12/11/2015
1. [](#improved)
Fix double escaping comments text and author
# v1.1.1
## 12/11/2015
1. [](#improved)
* Drop the autofocus on the comment form
1. [](#bugfix)
* Fix double encoding (#12)
# v1.1.0
## 11/24/2015
1. [](#improved)
Use date instead of gmdate to respect the server local time (thanks @bovisp)
1. [](#improved)
Now works with multilang (thanks @bovisp)
1. [](#new)
Added french (@codebee-fr) and russian (@joomline) languages
1. [](#new)
Takes advantage of the new nonce support provided by the Form plugin
* Added french (@codebee-fr) and russian (@joomline) languages
* Takes advantage of the new nonce support provided by the Form plugin
1. [](#improved)
* Use date instead of gmdate to respect the server local time (thanks @bovisp)
* Now works with multilang (thanks @bovisp)
# v1.0.2
## 11/13/2015
@ -21,10 +113,11 @@
# v1.0.1
## 11/11/2015
1. [](#bugfix)
* Fix error when user/data/comments does not exist
1. [](#improved)
* Use onAdminMenu instead of the deprecated onAdminTemplateNavPluginHook
1. [](#bugfix)
* Fix error when user/data/comments does not exist
# v1.0.0
## 10/21/2015

View File

@ -1,9 +1,21 @@
# Grav Comments Plugin
# Grav Comments Plugin \[Fork\]
This plugin adds support for displaying pingbacks, toggling the display of pingbacks. I'm not yet sure how pingbacks work, so this may not include support for adding new pingbacks though I attempted to patch the php file so it could work in theory; if it won't take too much work I'll add more support for them. Also added support for user entered URLs, though I haven't gotten the form input to show up yet.
This fork adds support for Akismet, which is now basically working. Consider it alpha. Also has admin panel functionality, can toggle it, add api key, shows error on comment page if api key doesn't match site. Going to add amin panel checkbox for recaptcha.
Preview with commenting disabled but comment plugin still enabled:
![](http://git.leetnightshade.com/leetNightshade/git.leetnightshade.com/raw/branch/master/grav-plugin-comments/Screenshots/blog.default-theme.png)
Preview with nested commenting:
![](http://git.leetnightshade.com/leetNightshade/git.leetnightshade.com/raw/branch/master/grav-plugin-comments/Screenshots/nested.png)
---
The **Comments Plugin** for [Grav](http://github.com/getgrav/grav) adds the ability to add comments to pages, and moderate them.
| IMPORTANT!!! This plugin is currently in development as is to be considered a **beta release**. As such, use this in a production environment **at your own risk!**. More features will be added in the future.
# Installation
The Comments plugin is easy to install with GPM.
@ -16,8 +28,6 @@ Or clone from GitHub and put in the `user/plugins/comments` folder.
# Usage
Edit the
Add `{% include 'partials/comments.html.twig' with {'page': page} %}` to the template file where you want to add comments.
For example, in Antimatter, in `templates/item.html.twig`:
@ -49,13 +59,16 @@ The comment form will appear on the blog post items matching the enabled routes.
To set the enabled routes, create a `user/config/plugins/comments.yaml` file, copy in it the contents of `user/plugins/comments/comments.yaml` and edit the `enable_on_routes` and `disable_on_routes` options according to your needs.
> Make sure you configured the "Email from" and "Email to" email addresses in the Email plugin with your email address!
# Enabling Recaptcha
The plugin comes with Recaptcha integration. To make it work, add your own Recaptcha `site` and `secret` keys the the plugin yaml config file.
The plugin comes with Recaptcha integration. To make it work, create a `user/config/plugins/comments.yaml` file, copy in it the contents of `user/plugins/comments/comments.yaml` and uncomment the captcha form field and the captcha validation process.
Make sure you add your own Recaptcha `site` and `secret` keys too.
# Where are the comments stored?
In the `user/data/comments` folder. They're organized by page route, so every page with a comment has a corresponding file. This enabled a quick load of all the page comments.
In the `user/data/comments` folder. They're organized by page route, so every page with a comment has a corresponding file. This enables a quick load of all the page comments.
# Visualize comments
@ -72,4 +85,4 @@ The plugin interacts with the Email plugin to send emails upon receiving a comme
- Allow to delete comments from the Admin Plugin
- Ability to see all comments of a page in the Admin Plugin
- Ability to reply to a comment from the Admin Plugin
- Auto-fill the comment form when a user is logged in
- Auto-fill the comment form when a user is logged in

View File

@ -75,6 +75,13 @@
});
</script>
{% if grav.twig.warning_message|length %}
<div class="admin-block">
<h1>{{ "PLUGIN_COMMENTS.WARNINGS"|tu }}</h1>
<p class="center">{{ grav.twig.warning_message }}</p>
</div>
{% endif %}
<h1>Comments in the last 7 days</h1>
<div class="admin-block">

86
assets/comments.css Normal file
View File

@ -0,0 +1,86 @@
/*
===============================================================================================================================
Comments Plugin Styles
===============================================================================================================================
*/
.comment {
margin-top: 0px;
width:100%;
}
.comment:first-child {
margin-top: 0px;
}
.comment,
.comment-body {
zoom: 1;
}
.comment-body {
overflow: hidden;
margin-left: 10px;
}
.comment-object {
display: block;
}
.comment-right,
.comment > .pull-right {
padding-left: 10px;
}
.comment-left,
.comment > .pull-left {
padding-right: 10px;
}
.comment-middle {
vertical-align: middle;
}
.comment-bottom {
vertical-align: bottom;
}
.comment-heading {
margin-top: 0px;
margin-bottom: 5px;
}
.comment-meta {
font-size: small;
}
.comment-text {
clear: both;
}
.comment-list {
padding-left: 0px;
list-style: none;
}
.comment-flag-new {
background-color: lightcyan;
}
.comment-wrapper {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
.comment-avatar {
width: 20px;
height: 20px;
margin-left: -10px;
margin-right:5px;
vertical-align: middle;
}
/*.comment-thread-line:hover {
border-left:3px solid #1BB3E9;
}*/
.comment-thread-top {
margin-top:20px;
}
.comment-thread {
float: left;
border-left:3px solid #444;
margin-left:10px;
}
.comment-footer {
font-size: small;
}
.comment-reply {
display: inline;
}

216
assets/comments.js Normal file
View File

@ -0,0 +1,216 @@
function escapeRegExp(str) {
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
jQuery(document).ready(function() {
var commentForm = $('#comments-form'); //$(document).find('.comments-form').first();
var commentSection = $('#comments-section'); //$(document).find('.comments').first();
var commentAlert = $('#comments-alert'); //$(document).find('.alert').first();
//hide form, show link
commentForm.hide();
$(document).find('.comment-add-new').show();
//show comment form above comments section (new comment thread)
$('body').on('click', '.comment-add-new', function(e) {
e.preventDefault();
if ($(this).prev().filter('#comments-form').length > 0) {
//form is already in the right place.
//just make sure it is visible.
commentForm.show();
return;
}
commentForm.hide(); //hide it to make sure that it is not shown after move to make "show" transition work.
$(this).before(commentForm);
commentForm.show('slow');
commentAlert.empty().slideUp();
});
//show comment form below selected comment (reply to existing comment)
$('body').on('click', '.comment-add-reply', function(e) {
e.preventDefault();
var comment = $(this).closest('.comment');
if (comment.find('#comments-form').length > 0) {
//form is already in the right place.
//just make sure it is visible.
commentForm.show();
return;
}
commentForm.hide();
comment.find('.comment-body').last().append(commentForm);
commentForm.show('slow');
commentAlert.empty().slideUp();
});
//delete comment (authorized user only)
$('body').on('click', '.comment-delete', function(e) {
e.preventDefault();
var comment = $(this).closest('.comment');
var id = parseInt(comment.attr('data-id'), 10);
var level = parseInt(comment.attr('data-level'), 10);
var nonce = commentForm.find("input[name='form-nonce']").val();
if (comment.next().filter(".comment[data-level='" + (level + 1) + "']").length > 0) {
alert('Deletion not allowed. There are replies to this comment. Please delete them first.');
return;
}
var url = commentForm.attr("action");
var posting = $.post(url, {
action: 'delete',
id: id,
nonce: nonce
}, null, 'json');
// Register events to ajax call
posting.done(function(response) {
//make sure that commentForm is definitely not within the deleted DOM part.
//hide
//temporary move it outside the comment selected for deletion. (this definitely exists, not taking any chances here)
//finally move back to start of commentSection. (preferred target)
//Hint: Don't forget commentAlert as it is not inside the form.
commentAlert.empty().hide();
commentForm.hide();
comment.before(commentForm);
comment.before(commentAlert);
commentSection.prepend(commentAlert);
commentSection.prepend(commentForm);
//remove the comment and all content from DOM.
//detach would be a soft delete but as there is no reason to reuse the deleted comment, means should not be provided.
comment.remove();
});
posting.fail(function(status, error, title) {
//alert('error');
//console.log("Response Data (fail)", JSON.parse(JSON.stringify(status)));
commentForm.after(commentAlert);
commentAlert.show();
commentAlert.empty().append("<p>Error: </p>");
commentAlert.append("<p>" + JSON.stringify(status) + "</p>");
commentAlert.append("<p>" + JSON.stringify(error) + "</p>");
commentAlert.append("<p>" + JSON.stringify(title) + "</p>");
});
posting.always(function() {
//alert("finished, be it successful or not");
});
});
// Attach a submit handler to the form
$(commentForm).on('submit', function(event) {
event.preventDefault();
// Get form data:
var data = $(this).serialize();
//console.log("Form Data (submit)", JSON.parse(JSON.stringify(data)));
var url = $(this).attr("action");
//var url = '/nested-comments';
var parent = 0;
var ownLevel = 0;
if ($(this).parents('.comment').length > 0) {
parent = $(this).closest('.comment').attr('data-id');
ownLevel = parseInt($(this).closest('.comment').attr('data-level'), 10) + 1;
}
// Send the data using post
//var posting = $.post(url, { parent: parent, data: data }, null, 'json');
var posting = $.post(url, data + '&parent=' + parent, null, 'json');
// Register events to ajax call
posting.done(function(response) {
//alert('success');
//console.log("Response Data (done)", JSON.parse(JSON.stringify(response)));
//response = JSON.parse(response); //not needed, post was done using json
commentForm.after(commentAlert);
if (!response.status) {
//should not trigger at all, if all bad requests return the right http status code
//i.e. <> 200 success => thus triggering posting.fail()
//leave this check just in case
commentAlert.stop().css('opacity', 1).text('Error: ' + response.message).fadeIn(30).fadeOut(5000);
return;
}
if (response.status) {
commentAlert.css('color', 'green').empty().append(document.createTextNode(response.message)).fadeIn(30);
/*var newMedia = "<div class='comment comment-level-{{comment.level|e}} comment-flag-new' data-level='{{comment.level}}' data-id='{{comment.id}}' >" +
"<div class='comment-left'>" +
"<img class='comment-object' src='https://www.gravatar.com/avatar/{{comment.email|trim|lower|md5}}?d=identicon' alt='user icon'>" +
"</div>" +
"<div class='comment-body'>" +
"<div class='comment-heading'>" +
"<div class='comment-title'><h4>{{comment.title}}</h4></div>" +
"<div class='comment-reply'><a class='comment-add-reply' href='#'><i class='fa fa-reply' title='{{'PLUGIN_COMMENTS.ADD_REPLY'|t}}'></i> {{'PLUGIN_COMMENTS.REPLY'|t}}</a></div>" +
"<div class='comment-meta'>{{'PLUGIN_COMMENTS.WRITTEN_ON'|t}} {{comment.date|e}} {{'PLUGIN_COMMENTS.BY'|t}} {{comment.author}}</div>" +
"</div>" +
"<div class='comment-text' >" +
"{{comment.text}}" +
"</div>" +
"{{nested}}" +
"</div>" +
"</div>";*/
var newMedia = `<div id="comment-{{comment.id}}" class="comment comment-level-{{comment.level|e}}" data-id="{{comment.id}}" itemtype="http://schema.org/UserComments">
<header class="comment-heading">
<img class="comment-avatar" src="https://www.gravatar.com/avatar/{{comment.email|trim|lower|md5}}?size=20&d=identicon" alt="user icon">
<span class="comment-meta">
{% if comment.site %}
<a href="{{comment.site}}">{{comment.author}}</a>
{% else %}
{{comment.author}}
{% endif %}
<a href="{{uri.url(true)}}#comment-{{comment.id}}" title="Link to this comment" itemprop="url">
<time class="comment-date" datetime="{{comment.date|e}}" itemprop="commentTime">
{{comment.date|nicetime(false)}}
</time>
</a>
</span>
</header>
<div class="comment-body">
<div class="comment-text" >
{{comment.text}}
</div>
{{nested}}
<div class="comment-footer">
<span class="comment-reply">
{% if grav.twig.commenting_enabled %}
<a class="comment-add-reply" href="#"><i class="fa fa-reply" title="{{'PLUGIN_COMMENTS.ADD_REPLY'|t}}"></i> {{'PLUGIN_COMMENTS.REPLY'|t}}</a>
{% endif %}
{% if grav.user.access.admin.super %}
<a class="comment-delete" href="#"><i class="fa fa-trash" title="{{'PLUGIN_COMMENTS.DELETE_COMMENT'|t}}"></i> {{'PLUGIN_COMMENTS.DELETE'|t}}</a>
{% endif %}
</span>
</div>
</div>
</div>`;
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{comment.id}}"), 'g'), response.data.id);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{comment.level|e}}"), 'g'), ownLevel);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{comment.level}}"), 'g'), ownLevel);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{comment.email|trim|lower|md5}}"), 'g'), response.data.hash);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{parent}}"), 'g'), response.data.parent);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{comment.title}}"), 'g'), response.data.title);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{comment.text}}"), 'g'), response.data.text);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{comment.author}}"), 'g'), response.data.name);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{comment.site}}"), 'g'), response.data.site);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{comment.date|e}}"), 'g'), response.data.date);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{nested}}"), 'g'), '');
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{'PLUGIN_COMMENTS.ADD_REPLY'|t}}"), 'g'), response.data.ADD_REPLY);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{'PLUGIN_COMMENTS.REPLY'|t}}"), 'g'), response.data.REPLY);
newMedia = newMedia.replace(new RegExp(escapeRegExp("{{'PLUGIN_COMMENTS.WRITTEN_ON'|t}}"), 'g'), response.data.WRITTEN_ON);
if ($("div[data-id='" + response.data.parent + "']").length > 0) {
$("div[data-id='" + response.data.parent + "']").first().after(newMedia);
} else {
$("#comments").prepend(newMedia);
}
}
setTimeout(function() {
commentForm.slideUp();
commentAlert.fadeOut(5000);
}, 5000);
});
posting.fail(function(status, error, title) {
//alert('error');
//console.log("Response Data (fail)", JSON.parse(JSON.stringify(status)));
commentForm.after(commentAlert);
commentAlert.show();
commentAlert.empty().append("<p>Error: </p>");
commentAlert.append("<p>" + JSON.stringify(status) + "</p>");
commentAlert.append("<p>" + JSON.stringify(error) + "</p>");
commentAlert.append("<p>" + JSON.stringify(title) + "</p>");
});
posting.always(function() {
//alert("finished, be it successful or not");
});
});
});

View File

@ -1,5 +1,5 @@
name: Comments
version: 1.1.0
version: 1.2.8
description: Adds a commenting functionality to your site
icon: comment
author:
@ -21,11 +21,63 @@ form:
fields:
enabled:
type: toggle
label: Plugin status
label: PLUGIN_ADMIN.PLUGIN_STATUS
highlight: 1
default: 0
options:
1: Enabled
0: Disabled
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
commenting:
type: toggle
label: PLUGIN_COMMENTS.COMMENTS
highlight: 1
default: 0
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
nested:
type: toggle
label: PLUGIN_COMMENTS.COMMENTS_NESTED
highlight: 1
default: 0
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
pingbacks:
type: toggle
label: PLUGIN_COMMENTS.COMMENTS_PINGBACKS
highlight: 1
default: 0
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
akismet:
type: toggle
label: PLUGIN_COMMENTS.AKISMET
highlight: 1
default: 0
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
akismet_key_api:
type: text
label: PLUGIN_COMMENTS.AKISMET_KEY_API
highlight: 1
default:
options:
akismet_site:
type: text
label: PLUGIN_COMMENTS.AKISMET_SITE_OVERRIDE
highlight: 1
default:

44
class/Comment.php Normal file
View File

@ -0,0 +1,44 @@
<?php
namespace Grav\Plugin;
class Comment
{
private $id = 0;
private $value = array();
private $parent = null;
private $children = array();
public function __construct($id, $content) {
$this->id = $id;
$this->value = $content;
}
public function addItem($obj, $key = null) {
}
public function deleteItem($key) {
}
public function getItem($key) {
}
public function getContent($level = 0) {
$this->value['level'] = $level;
$comments[] = $this->value;
foreach($this->children as $child) {
//$comments[] = $child->getContent($level + 1); //produces nested result array.
$comments = array_merge($comments, $child->getContent($level + 1)); //produces flat result array.
}
return $comments;
}
public function setParent($parent) {
$this->parent = $parent;
}
public function addSubComment($obj) {
$this->children[] = $obj;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +1,43 @@
enabled: true
pingbacks: true
commenting: true
akismet_enabled: true
warning_message: ""
built_in_css: true
ajax_callback: /nested-comments
enable_on_routes:
- '/blog'
disable_on_routes:
- /blog/blog-post-to-ignore
- /ignore-this-route
#- '/blog/daring-fireball-link'
form:
name: comments
fields:
- name: name
label: Name
placeholder: Enter your name
autofocus: on
label: PLUGIN_COMMENTS.NAME_LABEL
placeholder: PLUGIN_COMMENTS.NAME_PLACEHOLDER
autocomplete: on
type: text
validate:
required: true
- name: email
label: Email
placeholder: Enter your email address
label: PLUGIN_COMMENTS.EMAIL_LABEL
placeholder: PLUGIN_COMMENTS.EMAIL_PLACEHOLDER
type: email
validate:
required: true
- name: site
label: PLUGIN_COMMENTS.SITE_LABEL
placeholder:
type: text
validate:
required: false
- name: text
label: Message
placeholder: Enter your message
label: PLUGIN_COMMENTS.MESSAGE_LABEL
placeholder: PLUGIN_COMMENTS.MESSAGE_PLACEHOLDER
type: textarea
validate:
required: true
@ -39,10 +47,6 @@ form:
process:
fillWithCurrentDateTime: true
- name: title
type: hidden
evaluateDefault: grav.page.header.title
- name: lang
type: hidden
evaluateDefault: grav.language.getLanguage
@ -51,27 +55,31 @@ form:
type: hidden
evaluateDefault: grav.uri.path
- name: g-recaptcha-response
label: Captcha
type: captcha
recatpcha_site_key: e32iojeoi32jeoi32jeoij32oiej32oiej3
recaptcha_not_validated: 'Captcha not valid!'
validate:
required: true
process:
ignore: true
- name: blockme
type: honeypot
# - name: g-recaptcha-response
# label: Captcha
# type: captcha
# recaptcha_site_key: e32iojeoi32jeoi32jeoij32oiej32oiej3
# recaptcha_not_validated: 'Captcha not valid!'
# validate:
# required: true
# process:
# ignore: true
buttons:
- type: submit
value: Submit
value: PLUGIN_COMMENTS.SUBMIT_COMMENT_BUTTON_TEXT
process:
# - captcha:
# recaptcha_secret: ej32oiej23oiej32oijeoi32jeio32je
- email:
subject: "[New Comment] from {{ form.value.name|e }}"
subject: PLUGIN_COMMENTS.EMAIL_NEW_COMMENT_SUBJECT
body: "{% include 'forms/data.html.twig' %}"
- captcha:
recatpcha_secret: ej32oiej23oiej32oijeoi32jeio32je
- addComment:
- message: Thank you for writing your comment!
- message: PLUGIN_COMMENTS.THANK_YOU_MESSAGE
- reset: true

392
extern/akismet/Akismet.class.php vendored Normal file
View File

@ -0,0 +1,392 @@
<?php
/**
* Akismet anti-comment spam service
*
* The class in this package allows use of the {@link http://akismet.com Akismet} anti-comment spam service in any PHP5 application.
*
* This service performs a number of checks on submitted data and returns whether or not the data is likely to be spam.
*
* Please note that in order to use this class, you must have a vaild {@link http://wordpress.com/api-keys/ WordPress API key}. They are free for non/small-profit types and getting one will only take a couple of minutes.
*
* For commercial use, please {@link http://akismet.com/commercial/ visit the Akismet commercial licensing page}.
*
* Please be aware that this class is PHP5 only. Attempts to run it under PHP4 will most likely fail.
*
* See the Akismet class documentation page linked to below for usage information.
*
* @package akismet
* @author Alex Potsides, {@link http://www.achingbrain.net http://www.achingbrain.net}
* @version 0.4
* @copyright Alex Potsides, {@link http://www.achingbrain.net http://www.achingbrain.net}
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* The Akismet PHP5 Class
*
* This class takes the functionality from the Akismet WordPress plugin written by {@link http://photomatt.net/ Matt Mullenweg} and allows it to be integrated into any PHP5 application or website.
*
* The original plugin is {@link http://akismet.com/download/ available on the Akismet website}.
*
* <b>Usage:</b>
* <code>
* $akismet = new Akismet('http://www.example.com/blog/', 'aoeu1aoue');
* $akismet->setCommentAuthor($name);
* $akismet->setCommentAuthorEmail($email);
* $akismet->setCommentAuthorURL($url);
* $akismet->setCommentContent($comment);
* $akismet->setPermalink('http://www.example.com/blog/alex/someurl/');
* if($akismet->isCommentSpam())
* // store the comment but mark it as spam (in case of a mis-diagnosis)
* else
* // store the comment normally
* </code>
*
* Optionally you may wish to check if your WordPress API key is valid as in the example below.
*
* <code>
* $akismet = new Akismet('http://www.example.com/blog/', 'aoeu1aoue');
*
* if($akismet->isKeyValid()) {
* // api key is okay
* } else {
* // api key is invalid
* }
* </code>
*
* @package akismet
* @name Akismet
* @version 0.4
* @author Alex Potsides
* @link http://www.achingbrain.net/
*/
class Akismet
{
private $version = '0.4';
private $wordPressAPIKey;
private $blogURL;
private $comment;
private $apiPort;
private $akismetServer;
private $akismetVersion;
// This prevents some potentially sensitive information from being sent accross the wire.
private $ignore = array('HTTP_COOKIE',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED_HOST',
'HTTP_MAX_FORWARDS',
'HTTP_X_FORWARDED_SERVER',
'REDIRECT_STATUS',
'SERVER_PORT',
'PATH',
'DOCUMENT_ROOT',
'SERVER_ADMIN',
'QUERY_STRING',
'PHP_SELF' );
/**
* @param string $blogURL The URL of your blog.
* @param string $wordPressAPIKey WordPress API key.
*/
public function __construct($blogURL, $wordPressAPIKey) {
$this->blogURL = $blogURL;
$this->wordPressAPIKey = $wordPressAPIKey;
// Set some default values
$this->apiPort = 80;
$this->akismetServer = 'rest.akismet.com';
$this->akismetVersion = '1.1';
// Start to populate the comment data
$this->comment['blog'] = $blogURL;
$this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
if(isset($_SERVER['HTTP_REFERER'])) {
$this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
}
/*
* This is necessary if the server PHP5 is running on has been set up to run PHP4 and
* PHP5 concurently and is actually running through a separate proxy al a these instructions:
* http://www.schlitt.info/applications/blog/archives/83_How_to_run_PHP4_and_PHP_5_parallel.html
* and http://wiki.coggeshall.org/37.html
* Otherwise the user_ip appears as the IP address of the PHP4 server passing the requests to the
* PHP5 one...
*/
$this->comment['user_ip'] = $_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR') ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR');
}
/**
* Makes a request to the Akismet service to see if the API key passed to the constructor is valid.
*
* Use this method if you suspect your API key is invalid.
*
* @return bool True is if the key is valid, false if not.
*/
public function isKeyValid() {
// Check to see if the key is valid
$response = $this->sendRequest('key=' . $this->wordPressAPIKey . '&blog=' . $this->blogURL, $this->akismetServer, '/' . $this->akismetVersion . '/verify-key');
return $response[1] == 'valid';
}
// makes a request to the Akismet service
private function sendRequest($request, $host, $path) {
$http_request = "POST " . $path . " HTTP/1.0\r\n";
$http_request .= "Host: " . $host . "\r\n";
$http_request .= "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n";
$http_request .= "Content-Length: " . strlen($request) . "\r\n";
$http_request .= "User-Agent: Akismet PHP5 Class " . $this->version . " | Akismet/1.11\r\n";
$http_request .= "\r\n";
$http_request .= $request;
$socketWriteRead = new SocketWriteRead($host, $this->apiPort, $http_request);
$socketWriteRead->send();
return explode("\r\n\r\n", $socketWriteRead->getResponse(), 2);
}
// Formats the data for transmission
private function getQueryString() {
foreach($_SERVER as $key => $value) {
if(!in_array($key, $this->ignore)) {
if($key == 'REMOTE_ADDR') {
$this->comment[$key] = $this->comment['user_ip'];
} else {
$this->comment[$key] = $value;
}
}
}
$query_string = '';
foreach($this->comment as $key => $data) {
if(!is_array($data)) {
$query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
}
}
return $query_string;
}
/**
* Tests for spam.
*
* Uses the web service provided by {@link http://www.akismet.com Akismet} to see whether or not the submitted comment is spam. Returns a boolean value.
*
* @return bool True if the comment is spam, false if not
* @throws Will throw an exception if the API key passed to the constructor is invalid.
*/
public function isCommentSpam() {
$response = $this->sendRequest($this->getQueryString(), $this->wordPressAPIKey . '.' . $this->akismetServer, '/' . $this->akismetVersion . '/comment-check');
if($response[1] == 'invalid' && !$this->isKeyValid()) {
throw new exception('The Wordpress API key passed to the Akismet constructor is invalid. Please obtain a valid one from http://wordpress.com/api-keys/');
}
return ($response[1] == 'true');
}
/**
* Submit spam that is incorrectly tagged as ham.
*
* Using this function will make you a good citizen as it helps Akismet to learn from its mistakes. This will improve the service for everybody.
*/
public function submitSpam() {
$this->sendRequest($this->getQueryString(), $this->wordPressAPIKey . '.' . $this->akismetServer, '/' . $this->akismetVersion . '/submit-spam');
}
/**
* Submit ham that is incorrectly tagged as spam.
*
* Using this function will make you a good citizen as it helps Akismet to learn from its mistakes. This will improve the service for everybody.
*/
public function submitHam() {
$this->sendRequest($this->getQueryString(), $this->wordPressAPIKey . '.' . $this->akismetServer, '/' . $this->akismetVersion . '/submit-ham');
}
/**
* To override the user IP address when submitting spam/ham later on
*
* @param string $userip An IP address. Optional.
*/
public function setUserIP($userip) {
$this->comment['user_ip'] = $userip;
}
/**
* To override the referring page when submitting spam/ham later on
*
* @param string $referrer The referring page. Optional.
*/
public function setReferrer($referrer) {
$this->comment['referrer'] = $referrer;
}
/**
* A permanent URL referencing the blog post the comment was submitted to.
*
* @param string $permalink The URL. Optional.
*/
public function setPermalink($permalink) {
$this->comment['permalink'] = $permalink;
}
/**
* The type of comment being submitted.
*
* May be blank, comment, trackback, pingback, or a made up value like "registration" or "wiki".
*/
public function setCommentType($commentType) {
$this->comment['comment_type'] = $commentType;
}
/**
* The name that the author submitted with the comment.
*/
public function setCommentAuthor($commentAuthor) {
$this->comment['comment_author'] = $commentAuthor;
}
/**
* The email address that the author submitted with the comment.
*
* The address is assumed to be valid.
*/
public function setCommentAuthorEmail($authorEmail) {
$this->comment['comment_author_email'] = $authorEmail;
}
/**
* The URL that the author submitted with the comment.
*/
public function setCommentAuthorURL($authorURL) {
$this->comment['comment_author_url'] = $authorURL;
}
/**
* The comment's body text.
*/
public function setCommentContent($commentBody) {
$this->comment['comment_content'] = $commentBody;
}
/**
* Defaults to 80
*/
public function setAPIPort($apiPort) {
$this->apiPort = $apiPort;
}
/**
* Defaults to rest.akismet.com
*/
public function setAkismetServer($akismetServer) {
$this->akismetServer = $akismetServer;
}
/**
* Defaults to '1.1'
*/
public function setAkismetVersion($akismetVersion) {
$this->akismetVersion = $akismetVersion;
}
}
/**
* Utility class used by Akismet
*
* This class is used by Akismet to do the actual sending and receiving of data. It opens a connection to a remote host, sends some data and the reads the response and makes it available to the calling program.
*
* The code that makes up this class originates in the Akismet WordPress plugin, which is {@link http://akismet.com/download/ available on the Akismet website}.
*
* N.B. It is not necessary to call this class directly to use the Akismet class. This is included here mainly out of a sense of completeness.
*
* @package akismet
* @name SocketWriteRead
* @version 0.1
* @author Alex Potsides
* @link http://www.achingbrain.net/
*/
class SocketWriteRead {
private $host;
private $port;
private $request;
private $response;
private $responseLength;
private $errorNumber;
private $errorString;
/**
* @param string $host The host to send/receive data.
* @param int $port The port on the remote host.
* @param string $request The data to send.
* @param int $responseLength The amount of data to read. Defaults to 1160 bytes.
*/
public function __construct($host, $port, $request, $responseLength = 1160) {
$this->host = $host;
$this->port = $port;
$this->request = $request;
$this->responseLength = $responseLength;
$this->errorNumber = 0;
$this->errorString = '';
}
/**
* Sends the data to the remote host.
*
* @throws An exception is thrown if a connection cannot be made to the remote host.
*/
public function send() {
$this->response = '';
$fs = fsockopen($this->host, $this->port, $this->errorNumber, $this->errorString, 3);
if($this->errorNumber != 0) {
throw new Exception('Error connecting to host: ' . $this->host . ' Error number: ' . $this->errorNumber . ' Error message: ' . $this->errorString);
}
if($fs !== false) {
@fwrite($fs, $this->request);
while(!feof($fs)) {
$this->response .= fgets($fs, $this->responseLength);
}
fclose($fs);
}
}
/**
* Returns the server response text
*
* @return string
*/
public function getResponse() {
return $this->response;
}
/**
* Returns the error number
*
* If there was no error, 0 will be returned.
*
* @return int
*/
public function getErrorNumner() {
return $this->errorNumber;
}
/**
* Returns the error string
*
* If there was no error, an empty string will be returned.
*
* @return string
*/
public function getErrorString() {
return $this->errorString;
}
}
?>

View File

@ -1,48 +1,355 @@
de:
PLUGIN_COMMENTS:
ADD_NEW: Kommentar hinzufügen
ADD_REPLY: Auf Kommentar antworten
ADD_COMMENT: Kommentar hinzufügen
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
DELETE_COMMENT: Kommentar löschen
REPLY: Antworten
DELETE: Löschen
SUCCESS: "Der Kommentar wurde erfolgreich gespeichert."
COMMENTS: Kommentare
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
COMMENTS_STATS: Kommentare
RECENT_COMMENTS: Neue Kommentare
RECENT_PAGES: Kommentierte Seiten
EMAIL_NOT_CONFIGURED: Email nicht konfiguriert
NEW_COMMENT_EMAIL_SUBJECT: 'Neuer Kommentar für %1$s'
NEW_COMMENT_EMAIL_BODY: '<p>Ein neuer Kommentar am %1$s von %3$s (%4$s).</p><p>Seite: %2$s</p><p>Text: %5$s</p>'
EMAIL_FOOTER: ''
NAME: Name:
EMAIL: Email:
WRITTEN_ON: am
BY: Von
NAME_LABEL: "Name"
NAME_PLACEHOLDER: "Namen eingeben"
EMAIL_LABEL: "Email"
EMAIL_PLACEHOLDER: "Email-Adresse eingeben"
MESSAGE_LABEL: "Kommentar"
MESSAGE_PLACEHOLDER: "Kommentar eingeben"
SITE_LABEL: Site
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!"
WARNINGS: Warnings
en:
PLUGIN_COMMENTS:
ADD_NEW: Add a comment
ADD_REPLY: Reply to comment
ADD_COMMENT: Add a comment
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
DELETE_COMMENT: Delete comment
REPLY: Reply
DELETE: Delete
SUCCESS: "Comment has been saved successfully."
COMMENTS: Comments
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
COMMENTS_STATS: Comments
RECENT_COMMENTS: Recent comments
RECENT_PAGES: Commented pages
EMAIL_NOT_CONFIGURED: Email not configured
NEW_COMMENT_EMAIL_SUBJECT: 'New comment on %1$s'
NEW_COMMENT_EMAIL_BODY: '<p>A new comment was made on %1$s by %3$s (%4$s).</p><p>Page: %2$s</p><p>Text: %5$s</p>'
EMAIL_FOOTER: ''
NAME: Name:
EMAIL: Email:
WRITTEN_ON: Written on
BY: by
WRITTEN_ON: on
BY: By
NAME_LABEL: "Name"
NAME_PLACEHOLDER: "Enter your name"
EMAIL_LABEL: "Email"
EMAIL_PLACEHOLDER: "Enter your email address"
MESSAGE_LABEL: "Comment"
MESSAGE_PLACEHOLDER: "Enter your comment"
SITE_LABEL: Site
SUBMIT_COMMENT_BUTTON_TEXT: "Submit"
EMAIL_NEW_COMMENT_SUBJECT: "[New Comment] from {{ form.value.name|e }}"
THANK_YOU_MESSAGE: "Thank you for writing your comment!"
WARNINGS: Warnings
es:
PLUGIN_COMMENTS:
ADD_COMMENT: Agregar un comentario
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
COMMENTS: Comentarios
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
EMAIL_NOT_CONFIGURED: El Email no está configurado
NEW_COMMENT_EMAIL_SUBJECT: 'Nuevo comentario en %1$s'
NEW_COMMENT_EMAIL_BODY: '<p>Un nuevo comentario se hizo en %1$s por %3$s (%4$s).</p><p>Page: %2$s</p><p>Text: %5$s</p>'
EMAIL_FOOTER: ''
NAME: Nombre:
EMAIL: Email:
WRITTEN_ON: en
BY: Por
NAME_LABEL: "Nombre"
NAME_PLACEHOLDER: "Escriba su nombre"
EMAIL_LABEL: "Email"
EMAIL_PLACEHOLDER: "Escriba su email"
MESSAGE_LABEL: "Comentario"
MESSAGE_PLACEHOLDER: "Escriba su comentario"
SITE_LABEL: Site
SUBMIT_COMMENT_BUTTON_TEXT: "Enviar"
EMAIL_NEW_COMMENT_SUBJECT: "[Nuevo comentario] de {{ form.value.name|e }}"
THANK_YOU_MESSAGE: "Gracias por escribir su comentario!"
WARNINGS: Warnings
fr:
PLUGIN_COMMENTS:
ADD_COMMENT: Ajouter un commentaire
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
COMMENTS: Commentaires
EMAIL_NOT_CONFIGURED: Email non configurée
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
EMAIL_NOT_CONFIGURED: E-mail non configuré
NEW_COMMENT_EMAIL_SUBJECT: 'Nouveau commentaire sur %1$s'
NEW_COMMENT_EMAIL_BODY: '<p>Un nouveau commentaire a été posté sur %1$s par %3$s (%4$s).</p><p>Page: %2$s</p><p>Texte: %5$s</p>'
NEW_COMMENT_EMAIL_BODY: '<p>Un nouveau commentaire a été publié sur %1$s par %3$s (%4$s).</p><p>Page : %2$s</p><p>Texte : %5$s</p>'
EMAIL_FOOTER: ''
NAME: Nom:
NAME: Nom :
EMAIL: E-mail :
WRITTEN_ON: le
BY: Par
NAME_LABEL: "Nom"
NAME_PLACEHOLDER: "Indiquez votre nom"
EMAIL_LABEL: "E-mail"
EMAIL_PLACEHOLDER: "Indiquez votre adresse e-mail"
MESSAGE_LABEL: "Commentaire"
MESSAGE_PLACEHOLDER: "Rédigez votre commentaire"
SITE_LABEL: Site
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 !"
WARNINGS: Warnings
hr:
PLUGIN_COMMENTS:
ADD_COMMENT: Dodaj komentar
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
COMMENTS: Komentari
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
EMAIL_NOT_CONFIGURED: Email adresa nije podešena
NEW_COMMENT_EMAIL_SUBJECT: 'Novi komentar na %1$s'
NEW_COMMENT_EMAIL_BODY: '<p>Novi komentar je napisan na %1$s od %3$s (%4$s).</p><p>Stranica:: %2$s</p><p>Tekst: %5$s</p>'
EMAIL_FOOTER: ''
NAME: Ime:
EMAIL: Email:
WRITTEN_ON: Ecrit le
BY: par
WRITTEN_ON: 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"
SITE_LABEL: Site
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!"
WARNINGS: Warnings
it:
PLUGIN_COMMENTS:
ADD_COMMENT: Aggiungi un commento
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
COMMENTS: Commenti
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
EMAIL_NOT_CONFIGURED: Email non configurata
NEW_COMMENT_EMAIL_SUBJECT: 'Nuovo commento su %1$s'
NEW_COMMENT_EMAIL_BODY: '<p>Un nuovo commento è stato postato su %1$s da %3$s (%4$s).</p><p>Pagina: %2$s</p><p>Testo: %5$s</p>'
EMAIL_FOOTER: ''
NAME: Nome:
EMAIL: Email:
WRITTEN_ON: Scritto il
BY: da
WRITTEN_ON: il
BY: Da
NAME_LABEL: "Nome"
NAME_PLACEHOLDER: "Inserisci il tuo nome"
EMAIL_LABEL: "Email"
EMAIL_PLACEHOLDER: "Inserisci il tuo indirizzo email"
MESSAGE_LABEL: "Messaggio"
MESSAGE_PLACEHOLDER: "Inserisci il tuo commento"
SITE_LABEL: Site
SUBMIT_COMMENT_BUTTON_TEXT: "Invia"
EMAIL_NEW_COMMENT_SUBJECT: "[Nuovo commento] da {{ form.value.name|e }}"
THANK_YOU_MESSAGE: "Grazie per il tuo commento!"
WARNINGS: Warnings
ja:
PLUGIN_COMMENTS:
ADD_COMMENT: コメントを追加する
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
COMMENTS: コメント
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
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:
NAME_LABEL: "名前"
NAME_PLACEHOLDER: "お名前を"
EMAIL_LABEL: "メールアドレスを"
EMAIL_PLACEHOLDER: "ご自分のメールアドレスをここに..."
MESSAGE_LABEL: "コメント"
MESSAGE_PLACEHOLDER: "コメントをここに"
SITE_LABEL: Site
SUBMIT_COMMENT_BUTTON_TEXT: "送信する"
EMAIL_NEW_COMMENT_SUBJECT: "[新しいコメント]、 {{ form.value.name|e }}から"
THANK_YOU_MESSAGE: "コメントを書いてくださいましてありがとうございました!"
WARNINGS: Warnings
pl:
PLUGIN_COMMENTS:
ADD_COMMENT: Dodaj komentarz
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
COMMENTS: Komentarzy
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
EMAIL_NOT_CONFIGURED: Email jest nie skofigurowany
NEW_COMMENT_EMAIL_SUBJECT: 'Nowy komentarz %1$s'
NEW_COMMENT_EMAIL_BODY: '<p>Pojawił się nowy komentarz, napisany %1$s przez %3$s (%4$s).</p><p>Strona: %2$s</p><p>Treść: %5$s</p>'
EMAIL_FOOTER: ''
NAME: Imię:
EMAIL: Email:
WRITTEN_ON: na
BY: Przez
ru:
PLUGIN_COMMENTS:
ADD_COMMENT: Добавить комментарий
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
COMMENTS: Комментарии
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
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>'
EMAIL_FOOTER: ''
NAME: Имя:
EMAIL: Email:
WRITTEN_ON: Написан в
BY: от
WRITTEN_ON: на
BY: От
pt-br:
PLUGIN_COMMENTS:
ADD_COMMENT: Escreva um comentário
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
COMMENTS: Comentários
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
EMAIL_NOT_CONFIGURED: E-mail não configurado
NEW_COMMENT_EMAIL_SUBJECT: 'Novo comentário em %1$s'
NEW_COMMENT_EMAIL_BODY: '<p>Um novo comentário foi feito em %1$s por %3$s (%4$s).</p><p>Página: %2$s</p><p>Texto: %5$s</p>'
EMAIL_FOOTER: ''
NAME: Name:
EMAIL: Email:
WRITTEN_ON: em
BY: Por
NAME_LABEL: "Nome"
NAME_PLACEHOLDER: "Escreva seu nome"
EMAIL_LABEL: "E-mail"
EMAIL_PLACEHOLDER: "Escreva seu e-mail. Ex.: seunome@provedor.com.br"
MESSAGE_LABEL: "Comentário"
MESSAGE_PLACEHOLDER: "Escreva seu comentário"
SITE_LABEL: Site
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!"
WARNINGS: Warnings
ro:
PLUGIN_COMMENTS:
ADD_COMMENT: 'Adăugați un comentariu'
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
COMMENTS: 'Comentarii'
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
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: 'pe'
BY: 'De'
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."
SITE_LABEL: Site
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!"
WARNINGS: Warnings
no:
PLUGIN_COMMENTS:
ADD_COMMENT: Skriv en kommentar
AKISMET: Akismet
AKISMET_KEY_API: Akismet API Key
AKISMET_SITE_OVERRIDE: Akismet Site Override
COMMENTS: Kommentarer
COMMENTS_NESTED: Nested Comments
COMMENTS_NONE: There are no comments yet.
COMMENTS_PINGBACKS: Pingbacks
EMAIL_NOT_CONFIGURED: Epost er ikke konfigurert
NEW_COMMENT_EMAIL_SUBJECT: 'Ny kommentar på %1$s'
NEW_COMMENT_EMAIL_BODY: '<p>En ny kommentar er skrevet på %1$s av %3$s (%4$s).</p><p>Side: %2$s</p><p>Tekst: %5$s</p>'
EMAIL_FOOTER: ''
NAME: Navn:
EMAIL: Epost:
WRITTEN_ON:
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"
SITE_LABEL: Site
SUBMIT_COMMENT_BUTTON_TEXT: "Send"
EMAIL_NEW_COMMENT_SUBJECT: "[Ny kommentar] fra {{ form.value.name|e }}"
THANK_YOU_MESSAGE: "Takk for din kommentar!"
WARNINGS: Warnings

View File

@ -0,0 +1,37 @@
<form id="comments-form" name="{{ grav.config.plugins.comments.form.name }}" class="comments-form"
action="{{ grav.config.plugins.comments.form.action ? base_url ~ grav.config.plugins.comments.form.action : page.url }}"
method="{{ grav.config.plugins.comments.form.method|upper|default('POST') }}">
{% for field in grav.config.plugins.comments.form.fields %}
{% set value = form.value(field.name) %}
{% if field.evaluateDefault %}
{% set value = evaluate(field.evaluateDefault) %}
{% endif %}
{% if config.plugins.login.enabled and grav.user.authenticated %}
{% if field.name == 'name' %}
<input type="hidden" name="{{ (scope ~ field.name)|fieldName }}" value="{{grav.user.fullname}}">
{% elseif field.name == 'email' %}
<input type="hidden" name="{{ (scope ~ field.name)|fieldName }}" value="{{grav.user.email}}">
{% else %}
<div>
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
</div>
{% endif %}
{% else %}
<div>
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
</div>
{% endif %}
{% endfor %}
{% include "forms/fields/formname/formname.html.twig" %}
<div class="buttons">
{% for button in grav.config.plugins.comments.form.buttons %}
<button class="button" type="{{ button.type|default('submit') }}">{{ button.value|t|default('Submit') }}</button>
{% endfor %}
</div>
{{ nonce_field('comments', 'form-nonce')|raw }}
</form>
<div id="comments-alert" class="alert">{{ form.message }}</div>

View File

@ -1,46 +1,75 @@
{% if grav.twig.enable %}
{% if grav.twig.enable_comments_plugin %}
{% set scope = scope ?: 'data.' %}
<section id="comments-section">
<h2>{{'PLUGIN_COMMENTS.COMMENTS'|t}}</h2>
<h3>{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}</h3>
{% if grav.twig.commenting_enabled %}
<a class="comment-add-new" href="#"><i class="fa fa-plus" title="{{'PLUGIN_COMMENTS.ADD_NEW'|t}}"></i> {{'PLUGIN_COMMENTS.ADD_NEW'|t}}</a>
{% endif %}
<form name="{{ grav.config.plugins.comments.form.name }}"
action="{{ grav.config.plugins.comments.form.action ? base_url ~ grav.config.plugins.comments.form.action : page.url }}"
method="{{ grav.config.plugins.comments.form.method|upper|default('POST') }}">
{% for field in grav.config.plugins.comments.form.fields %}
{% include 'partials/comments.form.html.twig' %}
{% set value = form.value(field.name) %}
{% if field.evaluateDefault %}
{% set value = evaluate(field.evaluateDefault) %}
{% endif %}
<div>
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
</div>
{% endfor %}
<div id="comments" class="row comments">
{% if grav.twig.comments|length %}
{% set comments_visible = false %}
{% for comment in grav.twig.comments %}
{% if comment.approved == "true" %}
<div class="comment-wrapper">
{% set comments_visible = true %}
{% for level in range(0, comment.level|e) %}
{% if level == comment.level|e %}
<div id="thread-{{level}}" class="comment-thread-top comment-thread">
</div>
{% else %}
<div id="thread-{{level}}" class="comment-thread">
</div>
{% endif %}
{% endfor %}
<div id="comment-{{comment.id}}" class="comment comment-level-{{comment.level|e}}" data-id="{{comment.id}}" itemtype="http://schema.org/UserComments">
<header class="comment-heading">
<img class="comment-avatar" src="https://www.gravatar.com/avatar/{{comment.email|trim|lower|md5}}?size=20&d=identicon" alt="user icon">
<span class="comment-meta">
{% if comment.site %}
<a href="{{comment.site}}">{{comment.author}}</a>
{% else %}
{{comment.author}}
{% endif %}
<a href="{{uri.url(true)}}#comment-{{comment.id}}" title="Link to this comment" itemprop="url">
<time class="comment-date" datetime="{{comment.date|e}}" itemprop="commentTime">
{{comment.date|nicetime(false)}}
</time>
</a>
</span>
</header>
<div class="comment-body">
<div class="comment-text" >
{{comment.text}}
</div>
{{nested}}
<div class="comment-footer">
<span class="comment-reply">
{% if grav.twig.commenting_enabled and comment.id %}
<a class="comment-add-reply" href="#"><i class="fa fa-reply" title="{{'PLUGIN_COMMENTS.ADD_REPLY'|t}}"></i> {{'PLUGIN_COMMENTS.REPLY'|t}}</a>
{% endif %}
{% if grav.user.access.admin.super %}
<a class="comment-delete" href="#"><i class="fa fa-trash" title="{{'PLUGIN_COMMENTS.DELETE_COMMENT'|t}}"></i> {{'PLUGIN_COMMENTS.DELETE'|t}}</a>
{% endif %}
</span>
</div>
</div>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
<div class="buttons">
{% for button in grav.config.plugins.comments.form.buttons %}
<button class="button" type="{{ button.type|default('submit') }}">{{ button.value|default('Submit') }}</button>
{% endfor %}
</div>
{{ nonce_field('form', 'form-nonce') }}
</form>
<div class="alert">{{ form.message }}</div>
{% if grav.twig.comments|length %}
<h3>{{'PLUGIN_COMMENTS.COMMENTS'|t}}</h3>
<table>
{% for comment in grav.twig.comments|array_reverse %}
<tr>
<td>
{{comment.text|e}}
<br />
{{'PLUGIN_COMMENTS.WRITTEN_ON'|t}} {{comment.date|e}} {{'PLUGIN_COMMENTS.BY'|t}} {{comment.author|e}}
</td>
</tr>
{% endfor %}
</table>
{% endif %}
{% if not comments_visible %}
<tr>
<td>
{{'PLUGIN_COMMENTS.COMMENTS_NONE'|t}}
</td>
</tr>
{% endif %}
</div>
</section>
{% endif %}

View File

@ -0,0 +1,54 @@
{# you may set options when using this partial. Example: include 'partials/recentcomments.html.twig' with {'limit': 5, 'pages_limit': 3} #}
{% if grav.twig.enable_comments_plugin %}
<h1>{{'PLUGIN_COMMENTS.COMMENTS_STATS'|t}}</h1>
{% set stats = recent_comments(limit|default(5), pages_limit|default(3)) %}
{% if stats.global_stats.active_entries %}
<i class="fa fa-comments" title="active_entries"></i> {{stats.global_stats.active_entries}}
(<i class="fa fa-trash" title="deleted_entries"></i> {{stats.global_stats.deleted_entries}})
- <i class="fa fa-comment" title="active_comments"></i>{{stats.global_stats.active_comments}}
(<i class="fa fa-trash" title="deleted_comments"></i> {{stats.global_stats.deleted_comments}})
- <i class="fa fa-commenting" title="active_replies"></i>{{stats.global_stats.active_replies}}
(<i class="fa fa-trash" title="deleted_replies"></i> {{stats.global_stats.deleted_replies}})
- <i class="fa fa-files-o" title="pages_with_active_entries"></i> {{stats.global_stats.pages_with_active_entries}}
{% endif %}
{% for key, entry in stats.pages %}
{% if loop.first %}
<h2>{{'PLUGIN_COMMENTS.RECENT_PAGES'|t}} (limit {{stats.options.pages_limit}})</h2>
<ul class="fa-ul">
{% endif %}
<li><i class="fa-li fa fa-file" title="{{entry.route}}"></i>
{% if entry.route %}
<a href="{{entry.route}}#comments">
{% endif %}
{{entry.active_entries}}
{% if entry.route %}
</a>
{% endif %}
</li>
{% if loop.last %}
</ul>
{% endif %}
{% endfor %}
{% for key, entry in stats.comments %}
{% if loop.first %}
<h2>{{'PLUGIN_COMMENTS.RECENT_COMMENTS'|t}} (limit {{stats.options.comments_limit}})</h2>
<ul class="fa-ul">
{% endif %}
{% set entry_icon = 'fa-comment' %}
{% if not empty(entry.parent) %}
{% set entry_icon = 'fa-commenting' %}
{% endif %}
<li><i class="fa-li fa {{entry_icon}}" title="{{key}}: {{entry.id}}, {{entry.parent}}"></i>
{% if entry.route %}
<a href="{{entry.route}}#comments">
{% endif %}
{{entry.date}}, {{entry.author}}, {{entry.text|truncate(15)}}
{% if entry.route %}
</a>
{% endif %}
</li>
{% if loop.last %}
</ul>
{% endif %}
{% endfor %}
{% endif %}