Webbook
Learner webbook viewer β theme resolution / progress calculation / content mode decision (Pure) (Layer 3 Domain).
Statusβ
| Key | Value |
|---|---|
| Layer | domain |
| Tier | L1 |
| Status | wip |
| Version | 0.9.0 |
| Price | Free (free) |
| Category | Content |
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:
- URL
?theme=xxx(operator preview) Book.theme(per-book mood)Tenant.settings.academy.default_theme(organization default)- 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/PageModel + Migration (opt-in) - Filament Resource
- Vue/React viewer SDK
- Pattern composition + tip injection integration
Licenseβ
MIT
Dependenciesβ
Demosβ
- Platform κ΄λ¦¬μ ν¨λμμ λ©ν νμΈ π Login required
- μ¬μ© μμ (PHP)
π View on Plugin Store: store.codebase.how/plugins/webbook