Skip to content

Commit

Permalink
feat: mark logged in users as verified
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricerenck committed Feb 5, 2021
1 parent 316b5ba commit 857a4b5
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 19 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

A Kirby comment plugin

**Please be aware, this is still a beta.**

## Features

- ✅ Receive comments from a form on your site
Expand All @@ -20,6 +18,10 @@ A Kirby comment plugin
- Moderate komments on your page
- Disable/enable komments per page
- ✅ Disable komments after a certain number of dates in relation to the publish date
- ✅ Reply to comments
- ✅ Verified badge for logged in users

**As of version 0.10.0 the split view is the default view** The mixed view is deprecated due to the new nested comments functionality.

![the dashboard](doc-assets/komments-dashboard.png)
(The komment dashboard)
Expand All @@ -40,10 +42,6 @@ After Installing the Plugin add the snippet to your template. There are two snip

To list all komments and webmentions:

`<?php snippet('komments/webmention'); ?>`

To list komments and webmentions separated from each other:

`<?php snippet('komments/webmention-splitted'); ?>`

To show the komment form
Expand Down Expand Up @@ -114,6 +112,8 @@ You can fine tune the komments to behave as you whish, use this options in `conf
| `komment-icon-reply` | '💬' | The icon for replies/comments in your komment list |
| `komment-icon-repost` | '♻️' | The icon for reposts in your komment list |
| `komment-icon-mention` | '♻️' | The icon for mention in your komment list |
| `komment-icon-verified` | '✅' | The icon for the verify badge list |
| `replyClassNames` | '' | add classnames tto the reply link |

**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`

Expand Down
10 changes: 7 additions & 3 deletions blueprints/sections/komments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fields:
kommentType:
type: select
label: Type
width: 1/3
width: 1/4
options:
LIKE: Like
REPOST: Repost
Expand All @@ -60,11 +60,15 @@ fields:
type: date
label: Published
time: true
width: 1/3
width: 1/4
status:
type: toggle
label: Status
width: 1/3
width: 1/4
verified:
type: toggle
label: Verified
width: 1/4
columns:
author:
width: 1/4
Expand Down
2 changes: 2 additions & 0 deletions config/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@
'komment-icon-reply' => '💬',
'komment-icon-repost' => '♻️',
'komment-icon-mention' => '♻️',
'komment-icon-verified' => '',
'replyClassNames' => '',
];
2 changes: 2 additions & 0 deletions config/translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'mauricerenck.komments.headline.reposts' => 'Shares',
'mauricerenck.komments.headline.mentions' => 'Mentions',
'mauricerenck.komments.headline.replies' => 'Replies',
'mauricerenck.komments.action.reply.text' => 'reply',
],
'de' => [
'mauricerenck.komments.liked' => 'hat ein like spendiert',
Expand All @@ -32,5 +33,6 @@
'mauricerenck.komments.headline.reposts' => 'Geteilt',
'mauricerenck.komments.headline.mentions' => 'Erwähnungen',
'mauricerenck.komments.headline.replies' => 'Antworten',
'mauricerenck.komments.action.reply.text' => 'antworten',
]
];
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@
return new Response('<h1>error</h1><p>Invalid field values</p>', 'text/html', 412);
}

$newEntry = $kommentReceiver->createKomment($webmention, $spamlevel);
$isVerified = (!is_null(kirby()->user())) ? kirby()->user()->isLoggedIn() : false;
$newEntry = $kommentReceiver->createKomment($webmention, $spamlevel, $isVerified);
$kommentReceiver->storeData($newEntry, $targetPage);
$kommentModeration->addCookieToModerationList($newEntry['id']);

Expand Down
21 changes: 15 additions & 6 deletions snippets/kommentform.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<?php if (!$page->kommentsAreEnabled()): ?>
<div class="moderation-note" id="disabled"><?php echo t('mauricerenck.komments.disabled'); ?></div>
<?php return false; ?>
<?php endif; ?>
<?php
if (!$page->kommentsAreEnabled()): ?>
<div class="moderation-note" id="disabled"><?php echo t('mauricerenck.komments.disabled'); ?></div>
<?php return false; ?>
<?php endif; ?>
$formName = '';
$formEmail = '';
$user = $kirby->user();

if (!is_null($user) && $user->isLoggedIn()) {
$formName = $user->name();
$formEmail = $user->email();
}
?>
<?php $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; ?>
<div class="share-elsewhere">
<span><?php echo t('mauricerenck.komments.externalReply'); ?></span><br>
Expand All @@ -17,8 +26,8 @@
<span class="replyHandleDisplay"></span>
<textarea name="komment" id="komment" cols="30" rows="5" placeholder="Kommentar*" required></textarea>
<input type="text" name="url" id="url" placeholder="Leave empty" tabindex="-1">
<input type="email" name="email" id="email" placeholder="E-Mail*" required>
<input type="text" name="author" id="author" placeholder="Name*" required>
<input type="email" name="email" id="email" placeholder="E-Mail*" required value="<?php echo $formEmail; ?>">
<input type="text" name="author" id="author" placeholder="Name*" required value="<?php echo $formName; ?>">
<input type="url" name="author_url" id="author_url" placeholder="Website">
<div class="spam-indicator">
<div class="progress"></div>
Expand Down
5 changes: 3 additions & 2 deletions snippets/mention-type-reply.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<li class="single-komment komment-type-<?php echo strtolower($komment['kommenttype']); ?>" id="komment_<?php echo $komment['id']; ?>">
<li class="single-komment komment-type-<?php echo strtolower($komment['kommenttype']); ?> <?php echo ($komment['verified'] == 'true') ? 'verified' : ''?>" id="komment_<?php echo $komment['id']; ?>">
<div class="type-of"><?php echo option('mauricerenck.komments.komment-icon-reply'); ?></div>
<div class="author-avatar">
<a href="<?php echo $komment['authorurl']; ?>" rel="nofollow" target="_blank">
<img src="<?php echo $komment['avatar']; ?>" alt="<?php echo $komment['author']; ?>">
</a>
</div>
<div class="author-action">
<?php if ($komment['verified'] == 'true') : ?><span class="verified-badge"><?php echo option('mauricerenck.komments.komment-icon-verified', ''); ?></span><?php endif; ?>
<a href="<?php echo $komment['authorurl']; ?>" rel="nofollow" target="_blank"><?php echo $komment['author']; ?></a>&nbsp;
<?php echo t('mauricerenck.komments.replied'); ?>
</div>
Expand All @@ -19,6 +20,6 @@
<?php echo $komment['komment']->komment()->kirbytext(); ?>
</div>
<?php endif; ?>
<a href="#kommentform" class="kommentReply" data-id="<?php echo $komment['id']; ?>" data-handle="<?php echo $komment['author']; ?>">Reply</a>
<a href="#kommentform" class="kommentReply <?php echo option('mauricerenck.komments.replyClassNames'); ?>" data-id="<?php echo $komment['id']; ?>" data-handle="<?php echo $komment['author']; ?>"><?php echo t('mauricerenck.komments.action.reply.text'); ?></a>
</div>
</li>
1 change: 1 addition & 0 deletions utils/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private function transformToReply($komment)
'wmsource' => $komment->wmsource()->value(),
'wmtarget' => $komment->wmtarget()->value(),
'wmproperty' => $komment->wmproperty()->value(),
'verified' => $komment->verified()->value(),
'replies' => []
];
}
Expand Down
3 changes: 2 additions & 1 deletion utils/receiveKomment.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function storeData(array $newEntry, $targetPage)
]);
}

public function createKomment($webmention, $spamlevel = 0)
public function createKomment($webmention, $spamlevel = 0, $isVerified = false)
{
return [
'id' => md5($webmention['target'] . $webmention['author']['name'] . $webmention['published']),
Expand All @@ -39,6 +39,7 @@ public function createKomment($webmention, $spamlevel = 0)
'kommentType' => $webmention['type'],
'status' => $this->setStatus($webmention['type']),
'spamlevel' => $spamlevel,
'verified' => $isVerified
];
}

Expand Down

0 comments on commit 857a4b5

Please sign in to comment.