add front-comments
This commit is contained in:
parent
c3ea78cab5
commit
c9f4af7e58
53 changed files with 2921 additions and 1 deletions
43
site/plugins/front-comments/dropdowns/comment.php
Normal file
43
site/plugins/front-comments/dropdowns/comment.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'pattern' => 'comments/(:any)/(:all)',
|
||||
'action' => function (string $commentId, string $pageUri) {
|
||||
$options = [
|
||||
[
|
||||
'text' => t('adrienpayet.front-comments.see'),
|
||||
'icon' => 'preview',
|
||||
'link' => site()->url() . '/' . $pageUri . '/#' . $commentId,
|
||||
],
|
||||
[
|
||||
'text' => t('adrienpayet.front-comments.remove'),
|
||||
'icon' => 'remove',
|
||||
'dialog' => 'comments/delete/' . $commentId . '/' . $pageUri
|
||||
]
|
||||
];
|
||||
|
||||
if (option('adrienpayet.front-comments.repo.name')) {
|
||||
$page = Find::page($pageUri);
|
||||
$comments = $page->comments()->toData('yaml');
|
||||
|
||||
$commentData = getCommentData($comments, $commentId);
|
||||
$service = strtolower(option('adrienpayet.front-comments.repo.service'));
|
||||
|
||||
if (isset($commentData['issue-id']) && strlen($commentData['issue-id']) > 0) {
|
||||
$options[] = [
|
||||
'text' => t('adrienpayet.front-comments.see-issue'),
|
||||
'icon' => $service === 'github' ? 'github' : 'gitlab',
|
||||
'link' => $commentData['issue-url'],
|
||||
];
|
||||
} else {
|
||||
$options[] = [
|
||||
'text' => t('adrienpayet.front-comments.create-issue'),
|
||||
'icon' => $service === 'github' ? 'github' : 'gitlab',
|
||||
'dialog' => 'comments/create-issue/' . $commentId . '/' . $pageUri
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue