dopetalk does not endorse any advertised product nor does it accept any liability for it's use or misuse


Our Discord Notification Server invitation link is https://discord.gg/jB2qmRrxyD

Author Topic: Redbox BBCode  (Read 14 times)

Online Chip (OP)

  • Server Admin
  • Hero Member
  • *****
  • Administrator
  • *****
  • Join Date: Dec 2014
  • Location: Australia
  • Posts: 7308
  • Reputation Power: 0
  • Chip has hidden their reputation power
  • Gender: Male
  • Last Login:Today at 09:54:11 PM
  • Deeply Confused Learner
  • Profession: IT Engineer now retired
Redbox BBCode
« on: Today at 09:20:46 AM »

RedBox BBCode

One box. Every mod. Forever.

Right now, every mod on your forum that needs to say "something's wrong" either builds its own ad-hoc error markup, or doesn't bother and lets PHP fatal ugly. Tonight alone you watched that play out twice — a duplicated iframe block from a copy-pasted patch, and a "Class not found" that took a whole page down with zero visible explanation. Both were the same root problem: no single, dependable way to say "here's an error" that every mod could just reach for.

RedBox fixes that permanently, and cheaply:

  • Zero install cost for what it protects. Six files, no dependencies, no CSS to break, no theme to patch. It either sits there quietly or it saves you from a dead page — never a liability either way.
  • Two lines, anywhere.
  if (!class_exists('RedBoxBBCode'))      require_once($sourcedir . '/RedBoxBBC.php');  echo RedBoxBBCode::render('Something went wrong.');

  Works inside a mod's PHP, a template, an install script, a future thing neither of us has thought of yet.

  • Already proven, not theoretical. LMV uses it right now as its own fallback for caught exceptions. It's not a nice idea sitting on a shelf — it's load-bearing in production-bound code tonight.
  • Human-facing too. The same visual identity is available to anyone typing [redbox]...[/redbox] in a post — moderators flagging a locked thread, a warning banner, whatever — so the styling is consistent whether the box comes from your code or from a person's fingers.
  • It compounds. Every mod you build after this one gets to skip reinventing error display. That's not a one-time win, that's a standing discount on every future project.

Honest caveat: same as everything tonight — it hasn't run against a live PHP interpreter from my side. It's reasoned-through, brace-checked, and now matches SMF's actual documented tag conventions instead of a guess, but "install it and see" is still the real test.







TEAM CHECKPOINT — 2026-08-15

Session covered three SMF BBCode mods (LMV, RedBox, MD) plus live-server theme/CSS cleanup. One item remains genuinely unresolved — flagged clearly below, don't re-solve what's already fixed.

LMV BBCode mod — [lmv] — v3.4, stable

Markdown-viewer BBCode tag for .md attachments. All confirmed working live: URL form, attachment form, attach-NN, auto-detect, inline mode, scroll/noscroll, autodisplay + autodisplay-scroll/-noscroll toggle tags. Key fixes this session:

  • renderAttachmentById() added as the shared entry point (was

  duplicated inline before).

  • Autodisplay's Display.template.php patch rewritten from a stale

  PDF-mod iframe copy-paste into a real call to the actual renderer.

  • Switched from Package Manager <modification> search/replace to

  idempotent PHP <code> install scripts (self-healing — detects and   upgrades any prior version of the inserted block instead of just   skipping on presence, and loops every installed theme, not just   default).

  • renderMarkdown()/renderAttachmentById() wrapped in try/catch,

  rendering a visible box on any caught error instead of a fatal.

  • Install now hard-fails with a clear message if MDBBC isn't already

  installed (was a silent runtime failure before).

RedBox BBCode mod — [redbox] — v1.2, new, stable

New standalone mod, no dependency on LMV/MD/PDF. Self-contained inline box styling (no CSS file needed). Two ways to use:

  • [redbox]text[/redbox] in any post — standard before/after tag

  form (an earlier 'type' => 'parsed_content' attempt was wrong,   SMF doesn't recognize that type — fixed to the standard form SMF's   own built-in tags use).

  • RedBoxBBCode::render($content, $escape = true) — callable directly

  from any other mod's PHP. LMV now uses this as a soft/optional   fallback for its own caught-error display.

MD BBCode mod — [md] — v12.5 — ⚠️ ONE BUG STILL OPEN

Fixed and confirmed this session:

  • Rich-text (/) line-break reconstruction, not just `

`.

  • .md-code-block CSS was never actually reaching the page at all —

  the old MDBBC.php tried injecting a <link> tag into the post   body's own HTML ($data inside validate()), which never worked.   Replaced with a proper integrate_load_theme hook appending to   $context['html_headers'] (same technique this forum's own   Code_Highlighting/highlight.js mod already uses successfully).

  • nohighlight class added to code blocks — this forum's separate

  Code_Highlighting mod runs hljs.initHighlightingOnLoad()   completely unscoped, grabbing every <pre><code> on any page.

Still open: code blocks in [md] output render with a mystery inline style="height: 33px" on the <code> element, visually compressing multi-line code onto what looks like one line. Confirmed:

  • Happens on Live AND Dev-test-smf20.
  • Happens in verified rich-text mode AND verified source/BBC mode —

  rules out SCEditor.

  • Happens in the actual full topic view, not a preview/quote context —

  rules out a viewing-context height clamp.

  • MDParser.php/MDBBC.php/md_bbcode.css never generate an inline

  height style anywhere — confirmed by direct code inspection.

Next step, not yet done: check the raw stored [md] source text (edit the post, source view, copy the literal stored text) to see whether the height artifact is already present before any parsing/rendering happens — would point to a server-side save-time cause, a different class of bug than anything ruled out above.

Live production server — housekeeping

  • Deleted ~15 unused legacy theme folders (Curve_Black,

  Ancient_and_Rusted, Vertex, smooth1, OmegaCreamRC4, blueeyes, camo,   thechemicaltheme, Ubuntu_Theme, blu, Limon_Portakal2, bluefolders,   sachat themes) — confirmed via Admin → Themes only 2 remain   (SMF Default/Curve, Core).

  • Found and removed two unmarked, dead CSS blocks baked directly into

  Themes/default/css/index.css (a stale pre-inline-style .lmv-viewer   copy, and a full unmarked duplicate of md_bbcode.css's entire   ruleset). Backups saved: index.css.bak-20260815,   index.css.bak2-20260815.

ISEmisc / markdown search project — queued, not started

Full-text search facility for .md/.txt/.json attachments (including orchestrator's own shared_memory*.json logs). Design already locked in from an earlier session: word-index + store JSON pair (not a single blob), MiscIndexer.py/MiscSearch.py, modelled on PDFIndexer.py/PDFsearch.py. Not touched this session — still waiting on a fresh conversation to actually build it.

⚠️
That's the `RedBoxBBCode::render()` method — call it from anywhere else in your PHP code (another mod, an install script, wherever) to get the same box without going through the BBC tag at all:Wherever you're already writing PHP that outputs into a page (another mod's method, a template file, a `<code>` install script), drop this in:

```php
if (!class_exists('RedBoxBBCode'))
    require_once($sourcedir . '/RedBoxBBC.php');

echo RedBoxBBCode::render('Something went wrong.');
```

That's the whole pattern — check the class is loaded (it might not be if this code runs somewhere that doesn't already have it in memory), require it if not, then call `render()` with your message and it echoes the box directly.

Two things worth knowing:

- **Escaping is on by default.** `render('some text')` treats your text as plain text and escapes it safely — good for anything that includes user input or variable data.
- **Pass `false` as the second argument only if you're deliberately including HTML** you built yourself (like a link): `RedBoxBBCode::render('Click <a href="...">here[/url]', false)`.

This is exactly the pattern LMV itself now uses internally for its own caught errors — so it's already proven inside your own codebase, not just theoretical.


```
1
2
3
4
5
```




Post Merged: Today at 11:54:05 AM
⚠️ Refused to fetch this URL.
« Last Edit: Today at 11:54:05 AM by Chip »
friendly
0
funny
0
informative
0
agree
0
disagree
0
like
0
dislike
0
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
Our Discord Server invitation link is https://discord.gg/jB2qmRrxyD

Tags:
 


dopetalk does not endorse any advertised product nor does it accept any liability for it's use or misuse





TERMS AND CONDITIONS

In no event will d&u or any person involved in creating, producing, or distributing site information be liable for any direct, indirect, incidental, punitive, special or consequential damages arising out of the use of or inability to use d&u. You agree to indemnify and hold harmless d&u, its domain founders, sponsors, maintainers, server administrators, volunteers and contributors from and against all liability, claims, damages, costs and expenses, including legal fees, that arise directly or indirectly from the use of any part of the d&u site.


TO USE THIS WEBSITE YOU MUST AGREE TO THE TERMS AND CONDITIONS ABOVE


Founded December 2014
SimplePortal 2.3.6 © 2008-2014, SimplePortal