Skip to content

Commit 1841ef5

Browse files
committed
feat: auto disable komments after n days
1 parent 9d25b8a commit 1841ef5

File tree

12 files changed

+179
-50
lines changed

12 files changed

+179
-50
lines changed

README.md

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ A Kirby comment plugin
1919
- Dashboard for komments in moderation/spam
2020
- Moderate komments on your page
2121
- Disable/enable komments per page
22+
- ✅ Disable komments after a certain number of dates in relation to the publish date
2223

2324
![the dashboard](doc-assets/komments-dashboard.png)
2425
(The komment dashboard)
@@ -75,34 +76,50 @@ Add this to every blueprint you wish to enable komments on. This will allow you
7576

7677
You can fine tune the komments to behave as you whish, use this options in `config.php` file.
7778

78-
| Option | Default | Description |
79-
| ----------------------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------- |
80-
| `debug` | `false` | Enables debug mode and logs all webmentions to a file |
81-
| `enable-webmention-support` | `true` | Listen to Webmentions and save them as komment |
82-
| `webmention-auto-publish` | `true` | When you receive a webmention set status to published |
83-
| `komment-auto-publish` | `false` | When you receive a komment set status to published |
84-
| `send-mention-on-update` | `true` | Detect urls in your pages and send webmentions |
85-
| `send-limit-to-templates` | `[]` | An array of template names (strings). When set webmentions will be sent only when this pages are updated |
86-
| `send-mention-url-fields` | `['text']` | An array of fieldnames in which the plugin will search for urls |
87-
| `send-to-mastodon-on-publish` | `false` | Send a post to mastodon when publishing a page |
88-
| `mastodon-bearer` | - | Your Mastodon bearer Token |
89-
| `mastodon-instance-url` | `https://mastodon.social/api/v1/statuses` | Your Mastodon API Endpoint |
90-
| `mastodon-text-field` | `mastodonTeaser` | The fieldname of the field you write your mastodon msg in, otherwise the title is used |
91-
| `ping-archiveorg` | `false` | Enable if you want to inform archive.org when you update a page |
92-
| `auto-delete-spam` | `true` | When comment spam is detected it will be rejected, set to false to just mark the comment as SPAM |
93-
| `komment-icon-like` | ❤️ | The icon for likes in your komment list |
94-
| `komment-icon-reply` | 💬 | The icon for replies/comments in your komment list |
95-
| `komment-icon-repost` | ♻️ | The icon for reposts in your komment list |
96-
| `komment-icon-mention` | ♻️ | The icon for mention in your komment list |
79+
| Option | Default | Description |
80+
| --------------------------------- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
81+
| `debug` | `false` | Enables debug mode and logs all webmentions to a file |
82+
| `enable-webmention-support` | `true` | Listen to Webmentions and save them as komment |
83+
| `webmention-auto-publish` | `true` | When you receive a webmention set status to published |
84+
| `komment-auto-publish` | `false` | When you receive a komment set status to published |
85+
| `send-mention-on-update` | `true` | Detect urls in your pages and send webmentions |
86+
| `send-limit-to-templates` | `[]` | An array of template names (strings). When set webmentions will be sent only when this pages are updated |
87+
| `send-mention-url-fields` | `['text']` | An array of fieldnames in which the plugin will search for urls |
88+
| `send-to-mastodon-on-publish` | `false` | Send a post to mastodon when publishing a page |
89+
| `mastodon-bearer` | - | Your Mastodon bearer Token |
90+
| `mastodon-instance-url` | `'https://mastodon.social/api/v1/statuses‘` | Your Mastodon API Endpoint |
91+
| `mastodon-text-field` | `'mastodonTeaser'` | The fieldname of the field you write your mastodon msg in, otherwise the title is used |
92+
| `ping-archiveorg` | `false` | Enable if you want to inform archive.org when you update a page |
93+
| `auto-delete-spam` | `true` | When comment spam is detected it will be rejected, set to false to just mark the comment as SPAM |
94+
| `auto-disable-komments` | `0` | Disables the komment form after `n` number of days. Use `0` to never disable komments (default) |
95+
| `auto-disable-komments-datefield` | `'date'` | Set a field to function as publish date field used for `auto-disable-komments` |
96+
| `komment-icon-like` | '❤️' | The icon for likes in your komment list |
97+
| `komment-icon-reply` | '💬' | The icon for replies/comments in your komment list |
98+
| `komment-icon-repost` | '♻️' | The icon for reposts in your komment list |
99+
| `komment-icon-mention` | '♻️' | The icon for mention in your komment list |
97100

98101
**Please make sure to prefix all the options with `mauricerenck.komments.`**. For example the debug option should be set in your `config.php` like so: `'mauricerenck.komments.debug' => true`
99102

103+
## Page Methods
104+
105+
| Method | Returns | Exsample |
106+
| ----------------------------- | --------- | ------------------------------------------------------------------------------------------ |
107+
| `$page->kommentCount()` | `integer` | `<?php echo $page->kommentCount(); ?> comments` |
108+
| `$page->kommentsAreEnabled()` | `boolean` | `<?php if($page->kommentsAreEnabled()): ><button>Write a comment!</button><?php endif; ?>` |
109+
| `$page->hasQueuedKomments()` | `boolean` | `<?php if($page->hasQueuedKomments()): >There are comments in moderation<?php endif; ?>` |
110+
100111
---
101112

102113
## Special features
103114

104115
Next to komments directly on your page, there are some other features enabled by this plugin
105116

117+
### Disable komment form after n days
118+
119+
You can let the plugin automatically disable komments after a certain number of days after the page was published. So you could set `auto-disable-komments` to `14`. When you publish a page the komments on that page will be disabled 14 days after the publish date. Only webmentions will be received after this. You can define any date field as a source by using the option `auto-disable-komments-datefield`. The default datefield is `date`.
120+
121+
Please be aware: If you configure a non-existing date field, this will result in a disabled komment state for all pages.
122+
106123
### Receiving webmentions
107124

108125
**To receive webmentions you have to install the [tratschtante plugin](https://github.com/mauricerenck/tratschtante) and configure it.** Tratschtante will handle all the webmentions and normalize their data. Currently only webmention.io is supported. After installing tratschtante, komment will automaticly be informed about new webmentions.
@@ -140,7 +157,3 @@ By changing the the icon options you can add your own emoji or icons. You can se
140157
If you want to change the styling, have a look at the classes, you can find the default styling in the `assets` folder of this plugin.
141158

142159
You can also modify the javascript part, but be aware, that this might result in false spam detection.
143-
144-
### Show the number of komments for a page
145-
146-
Simply use this tag anywhere on your site: `<?php echo $page->kommentCount(); ?>`

changelog.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
- 2020-08-20 - Bugfixes and split view
2-
- 2020-05-11 - Initial beta release
1+
- 2020-09-03: Improved handling of enabled/disabled komments
2+
3+
- kommentsAreEnabled() page methods
4+
- disable komments after certain amount of time
5+
6+
- 2020-08-20:
7+
8+
- Komments split view
9+
- bugfixes
10+
11+
- 2020-05-11: Initial beta release

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mauricerenck/komments",
3-
"version": "0.9.8",
3+
"version": "0.9.9",
44
"description": "A comment and webmention plugin for Kirby 3",
55
"type": "kirby-plugin",
66
"license": "MIT",
@@ -15,7 +15,8 @@
1515
"utils/sendMastodon.php",
1616
"utils/sendWebmention.php",
1717
"utils/receiveKomment.php",
18-
"utils/moderation.php"
18+
"utils/moderation.php",
19+
"utils/base.php"
1920
]
2021
},
2122
"require": {

composer.lock

Lines changed: 70 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/options.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
'mastodon-text-field' => 'mastodonTeaser',
1717
'ping-archiveorg' => false,
1818
'auto-delete-spam' => true,
19+
'auto-disable-komments' => 0,
20+
'auto-disable-komments-datefield' => 'date',
1921
'komment-icon-like' => '❤️',
2022
'komment-icon-reply' => '💬',
2123
'komment-icon-repost' => '♻️',

0 commit comments

Comments
 (0)