- Reviews and forum posts/replies now use a modern comment layout: avatar + username/meta on the left, content/actions on the right.
Added sanitized Markdown rendering for reviews, forum topics, and replies. Added a local Markdown editor with toolbar and live visual preview for:Review body on [business.php](/Users/tyemeclifford/Documents/GH/MyKeyser/business.php) Forum topic body and reply body on [forum.php](/Users/tyemeclifford/Documents/GH/MyKeyser/forum.php) Added editor/comment styling in [assets/css/style.css](/Users/tyemeclifford/Documents/GH/MyKeyser/assets/css/style.css). Added the editor script at [assets/js/markdown-editor.js](/Users/tyemeclifford/Documents/GH/MyKeyser/assets/js/markdown-editor.js), included globally through [includes/footer.php](/Users/tyemeclifford/Documents/GH/MyKeyser/includes/footer.php).
This commit is contained in:
@@ -57,7 +57,7 @@ function forumAttachmentList(array $attachments): string {
|
||||
return $out.'</div>';
|
||||
}
|
||||
function forumText(string $text): string {
|
||||
return nl2br(e($text));
|
||||
return renderMarkdown($text);
|
||||
}
|
||||
|
||||
$errors = [];
|
||||
@@ -153,7 +153,7 @@ if ($topicSlug === '') {
|
||||
<?=csrfField()?><input type="hidden" name="_act" value="create_topic">
|
||||
<div class="fg"><label class="flabel">CATEGORY *</label><select name="category_id" class="fselect" required><option value="">Choose category</option><?php foreach($categories as $cat): ?><option value="<?=$cat['id']?>"<?=((int)($_POST['category_id']??0)===(int)$cat['id'])?' selected':''?>><?=e($cat['name'])?></option><?php endforeach; ?></select></div>
|
||||
<div class="fg"><label class="flabel">TITLE *</label><input type="text" name="title" class="finput" value="<?=e($_POST['title']??'')?>" required></div>
|
||||
<div class="fg"><label class="flabel">BODY *</label><textarea name="body" class="ftextarea" required><?=e($_POST['body']??'')?></textarea></div>
|
||||
<div class="fg"><label class="flabel">BODY *</label><textarea name="body" class="ftextarea markdown-editor" required><?=e($_POST['body']??'')?></textarea></div>
|
||||
<div class="fg"><label class="flabel">ATTACH FILES</label><input type="file" name="attachments[]" class="finput" multiple><div class="fhint">Allowed: <?=e($allowedHint)?>. Max <?=e($maxHint)?> each.</div></div>
|
||||
<button class="btn btn-primary btn-block">Post Topic</button>
|
||||
</form>
|
||||
@@ -228,9 +228,17 @@ include __DIR__.'/includes/header.php';
|
||||
</div>
|
||||
|
||||
<div class="section-sm forum-thread">
|
||||
<article class="forum-post">
|
||||
<div class="forum-post-body"><?=forumText($topic['body'])?></div>
|
||||
<?=forumAttachmentList($topicAttachments)?>
|
||||
<article class="forum-post comment-card">
|
||||
<aside class="comment-author">
|
||||
<?=userAvatarHtml($topic, 'avatar-lg')?>
|
||||
<div class="comment-name"><?=e($topic['username'])?></div>
|
||||
<div class="comment-meta"><?=ago($topic['created_at'])?></div>
|
||||
<span class="badge badge-blue"><?=e($topic['category_name'])?></span>
|
||||
</aside>
|
||||
<div class="comment-content">
|
||||
<div class="forum-post-body markdown-body"><?=forumText($topic['body'])?></div>
|
||||
<?=forumAttachmentList($topicAttachments)?>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<div class="forum-replies-head">
|
||||
@@ -239,13 +247,20 @@ include __DIR__.'/includes/header.php';
|
||||
</div>
|
||||
|
||||
<?php foreach($replies as $reply): ?>
|
||||
<article class="forum-reply" id="reply-<?=$reply['id']?>">
|
||||
<div class="forum-reply-meta">
|
||||
<div class="forum-reply-author"><?=userAvatarHtml($reply, 'avatar-sm')?><span><?=e($reply['username'])?></span></div>
|
||||
<a href="<?=e(forumTopicUrl($topic).'#reply-'.$reply['id'])?>" class="forum-permalink">#reply-<?=$reply['id']?></a>
|
||||
<article class="forum-reply comment-card" id="reply-<?=$reply['id']?>">
|
||||
<aside class="comment-author">
|
||||
<?=userAvatarHtml($reply, 'avatar-lg')?>
|
||||
<div class="comment-name"><?=e($reply['username'])?></div>
|
||||
<div class="comment-meta"><?=ago($reply['created_at'])?></div>
|
||||
</aside>
|
||||
<div class="comment-content">
|
||||
<div class="comment-topline">
|
||||
<div></div>
|
||||
<a href="<?=e(forumTopicUrl($topic).'#reply-'.$reply['id'])?>" class="forum-permalink">#reply-<?=$reply['id']?></a>
|
||||
</div>
|
||||
<?php if($reply['body'] !== ''): ?><div class="forum-post-body markdown-body"><?=forumText($reply['body'])?></div><?php endif; ?>
|
||||
<?=forumAttachmentList($replyAttachments[$reply['id']] ?? [])?>
|
||||
</div>
|
||||
<?php if($reply['body'] !== ''): ?><div class="forum-post-body"><?=forumText($reply['body'])?></div><?php endif; ?>
|
||||
<?=forumAttachmentList($replyAttachments[$reply['id']] ?? [])?>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -257,7 +272,7 @@ include __DIR__.'/includes/header.php';
|
||||
<?php else: ?>
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
<?=csrfField()?><input type="hidden" name="_act" value="reply">
|
||||
<div class="fg"><label class="flabel">REPLY</label><textarea name="body" class="ftextarea"><?=e($_POST['body']??'')?></textarea></div>
|
||||
<div class="fg"><label class="flabel">REPLY</label><textarea name="body" class="ftextarea markdown-editor"><?=e($_POST['body']??'')?></textarea></div>
|
||||
<div class="fg"><label class="flabel">ATTACH FILES</label><input type="file" name="attachments[]" class="finput" multiple><div class="fhint">Allowed: <?=e($allowedHint)?>. Max <?=e($maxHint)?> each.</div></div>
|
||||
<button class="btn btn-primary">Post Reply</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user