addons/welcome-guide/main.php
1 <?php
2 /**
3 * Welcome & Formatting Guide Addon
4 *
5 * Fires on render_post_footer for post #1 of every topic.
6 * Shows a collapsible formatting cheatsheet under the first post.
7 * wgToggle() is defined in public/js/app.js — no inline script needed.
8 */
9 if (!defined('NEXUS')) exit('Forbidden');
10
11 addon_on('render_post_footer', function (array $post): string {
12
13 // Only show on the first post (the OP) in every topic
14 if ((int)($post['post_num'] ?? 0) !== 1) return '';
15
16 // Respect admin on/off toggle
17 if (cfg('welcome_guide_enabled', '1') !== '1') return '';
18
19 return '
20 <div class="wg-guide" id="wgGuide">
21 <button class="wg-toggle" onclick="wgToggle()" aria-expanded="false">
22 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
23 stroke-linecap="round" stroke-linejoin="round" width="13" height="13">
24 <circle cx="12" cy="12" r="10"/>
25 <line x1="12" y1="8" x2="12" y2="12"/>
26 <line x1="12" y1="16" x2="12.01" y2="16"/>
27 </svg>
28 Formatting guide
29 <svg class="wg-arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor"
30 stroke-width="2.5" stroke-linecap="round" width="11" height="11">
31 <polyline points="6 9 12 15 18 9"/>
32 </svg>
33 </button>
34 <div class="wg-body" style="display:none">
35 <div class="wg-grid">
36
37 <div class="wg-section">
38 <div class="wg-section-title">Text Formatting</div>
39 <div class="wg-row"><code class="wg-mono">**bold**</code> <span><strong>bold</strong></span></div>
40 <div class="wg-row"><code class="wg-mono">*italic*</code> <span><em>italic</em></span></div>
41 <div class="wg-row"><code class="wg-mono">~~strike~~</code> <span><del>strike</del></span></div>
42 <div class="wg-row"><code class="wg-mono">[text](url)</code><span><a href="#">link</a></span></div>
43 </div>
44
45 <div class="wg-section">
46 <div class="wg-section-title">Code</div>
47 <div class="wg-row">
48 <code class="wg-mono">`inline`</code>
49 <span><code style="background:#f5f3ff;color:#7c3aed;padding:1px 5px;border-radius:4px;font-size:12px">inline</code></span>
50 </div>
51 <div class="wg-row wg-block-row">
52 <div>
53 <code class="wg-mono">```php</code><br>
54 <code class="wg-mono">echo "hi";</code><br>
55 <code class="wg-mono">```</code>
56 </div>
57 <span>→ purple code block</span>
58 </div>
59 <div class="wg-hint">Languages: php, js, python, sql, html, css, bash…</div>
60 </div>
61
62 <div class="wg-section">
63 <div class="wg-section-title">Quote</div>
64 <div class="wg-row wg-block-row">
65 <div>
66 <code class="wg-mono">> first line</code><br>
67 <code class="wg-mono">> second line</code>
68 </div>
69 <span>→ green quote block</span>
70 </div>
71 <div class="wg-section-title" style="margin-top:10px">Lists</div>
72 <div class="wg-row"><code class="wg-mono">- item</code> <span>bullet list</span></div>
73 <div class="wg-row"><code class="wg-mono">1. item</code> <span>numbered list</span></div>
74 </div>
75
76 <div class="wg-section">
77 <div class="wg-section-title">Other</div>
78 <div class="wg-row"><code class="wg-mono">## Heading</code> <span><strong>Heading</strong></span></div>
79 <div class="wg-row"><code class="wg-mono">@username</code> <span>mention user</span></div>
80 <div class="wg-row"><code class="wg-mono">---</code> <span>horizontal rule</span></div>
81 <div class="wg-hint" style="margin-top:8px">
82 Paste a YouTube, Spotify, Twitter or Vimeo URL on its own line to auto-embed it.
83 </div>
84 </div>
85
86 </div>
87 </div>
88 </div>
89 ';
90 }, 100);