add front-comments
This commit is contained in:
parent
c3ea78cab5
commit
c9f4af7e58
53 changed files with 2921 additions and 1 deletions
|
|
@ -0,0 +1,7 @@
|
|||
<?php if ($kirby->user()): ?>
|
||||
<div class="fc__field" data-field-name="<?= $content->key() ?>" data-content="<?= $content ?>">
|
||||
<?= $content ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?= $content ?>
|
||||
<?php endif ?>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
$comments = $page->comments()->exists() && $page->comments()->isNotEmpty()
|
||||
? $page->comments()->toData('yaml')
|
||||
: [];
|
||||
|
||||
$suggestions = $page->suggestions()->exists() && $page->suggestions()->isNotEmpty()
|
||||
? $page->suggestions()->toData('yaml')
|
||||
: [];
|
||||
|
||||
foreach ($comments as &$comment) {
|
||||
$comment['message'] = nl2br($comment['message']);
|
||||
}
|
||||
|
||||
foreach ($suggestions as &$suggestion) {
|
||||
$suggestion['message'] = nl2br($suggestion['message']);
|
||||
}
|
||||
|
||||
|
||||
$commentsJson = json_encode($comments, JSON_HEX_APOS);
|
||||
$suggestionsJson = json_encode($suggestions, JSON_HEX_APOS);
|
||||
?>
|
||||
<script>
|
||||
const FCAuthor = '<?= e($kirby->user()->name()->isNotEmpty(), $kirby->user()->name(), $kirby->user()->email()) ?>';
|
||||
const FCTeam = '<?= $kirby->user()->team() ?>';
|
||||
const FCPageId = '<?= $page->panel()->id() ?>';
|
||||
const FCPageUri = '<?= $page->panel()->id() ?>';
|
||||
const FCCsrf = "<?= csrf() ?>";
|
||||
const FCComments = <?= $commentsJson ?>;
|
||||
const FCSuggestions = <?= $suggestionsJson ?>;
|
||||
const FCFilesPath = '<?= $filesPath ?>';
|
||||
const FCPosition = '<?= $position ?>';
|
||||
</script>
|
||||
<?php
|
||||
|
||||
echo js($filesPath . '/index.js');
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<style>
|
||||
:root {
|
||||
--fc-icon-chat-box-empty: url(<?= $filesPath ?>/icons/chat-box-empty.svg);
|
||||
}
|
||||
</style>
|
||||
<?= css($filesPath . '/style.css');
|
||||
21
site/plugins/front-comments/snippets/front-comments.php
Normal file
21
site/plugins/front-comments/snippets/front-comments.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
if ($kirby->user()) {
|
||||
$position = isset($position) ? $position : 'bottom-right';
|
||||
$location = isset($location) ? $location : 'media';
|
||||
|
||||
$filesPath = $location === 'media' ?
|
||||
'/media/plugins/adrienpayet/front-comments'
|
||||
: '/assets/front-comments';
|
||||
setFiles($location);
|
||||
|
||||
|
||||
echo snippet('front-comments-style', ['filesPath' => $filesPath]);
|
||||
echo snippet(
|
||||
'front-comments-script',
|
||||
[
|
||||
'filesPath' => $filesPath,
|
||||
'position' => $position
|
||||
]
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue