Skip to main content

Webbook

Learner webbook viewer β€” theme resolution / progress calculation / content mode decision (Pure) (Layer 3 Domain).

Status​

KeyValue
Layerdomain
TierL1
Statuswip
Version0.9.0
PriceFree (free)
CategoryContent

Overview​

Overview​

Webbook is a Layer 3 Domain Plugin of multi-saas-kit. It provides the core decision logic for the learner viewer β€” theme / progress / content mode β€” as Pure services without model dependencies.

Layer atop DocumentProcessor (HtmlRenderer) and Annotation (anchor visibility).

Core Components (3 Pure Services)​

ThemeResolver​

Extracted from academy.how's WebbookController::resolveEffectiveTheme. 4-level priority:

  1. URL ?theme=xxx (operator preview)
  2. Book.theme (per-book mood)
  3. Tenant.settings.academy.default_theme (organization default)
  4. config default ('system')

Allowed whitelist enforced at each level β€” disallowed values fall through.

ProgressCalculator + LessonProgress DTO​

Extracted from WebbookController::showLesson. Computes progress / prev / next from lesson id array + current id alone.

Output: currentIndex (0-based), total, progressPercent, prevId, nextId, toArray() with current_position (1-based).

ContentModeResolver​

Extracted from WebbookController::showLesson's image | html branch.

  • Input: ?content=xxx + hasActiveHtml: bool
  • 'html' requested + no active html β†’ fallback to 'image'
  • Disallowed β†’ default

Configuration​

return [
'enabled' => env('PLG_WEBBOOK_ENABLED', true),
'theme' => [
'allowed' => ['system', 'light', 'dark', 'sepia', 'high_contrast', 'soft', 'ocean', 'forest'],
'default' => 'system',
],
'content_mode' => [
'allowed' => ['image', 'html'],
'default' => 'image',
],
];

Usage​

$theme = ThemeResolver::fromConfig(config('webbook'))->resolve(
$request->query('theme'),
$book->theme,
$tenant?->settings,
);

$progress = (new ProgressCalculator)->calculate(
$allLessons->pluck('id')->all(),
$currentLesson->id,
);

$contentMode = ContentModeResolver::fromConfig(config('webbook'))->resolve(
$request->query('content'),
hasActiveHtml: $activeHtml !== null,
);

Origin​

Extracted from academy.how's WebbookController. Eloquent Book/Lesson/Page/Asset model dependencies remain in the project; only model-free decision logic was extracted.

Dependencies​

  • DocumentProcessor β€” caller uses HtmlRenderer / activeDocument
  • Annotation β€” caller renders anchor tips/notes

Plugin Relationships​

  • LessonThread β€” embed thread widget in lesson page (optional)

Roadmap (Phase 3+)​

  • Standard Book / Lesson / Page Model + Migration (opt-in)
  • Filament Resource
  • Vue/React viewer SDK
  • Pattern composition + tip injection integration

License​

MIT

Dependencies​

Demos​


πŸ›’ View on Plugin Store: store.codebase.how/plugins/webbook