Skip to content

Phase 14b-2: BasicTheme rewritten on iManager 2.0 stack#20

Merged
bigin merged 5 commits into
masterfrom
phase-14b2-basictheme
May 12, 2026
Merged

Phase 14b-2: BasicTheme rewritten on iManager 2.0 stack#20
bigin merged 5 commits into
masterfrom
phase-14b2-basictheme

Conversation

@bigin
Copy link
Copy Markdown
Owner

@bigin bigin commented May 3, 2026

Summary

Bundled basic theme now extends Frontend\Site and pulls every service from
the container — no remaining call into the legacy imanager() function or
editor/core/ classes survives the public render path. Pagination, theme
cache, template fragments, navigation, archive, hero, contact and subscribe
are all on iManager 2.0 plumbing.

Highlights:

  • BasicTheme rewritten on the typed PageRepository methods + Pagination
    value object + PaginationRenderer + FilesystemCache. Single-article
    rendering forces blog-post via currentTemplate() instead of mutating
    the Page DTO.
  • BasicRouter collapsed to a 22-line wrapper.
  • _ext.php sets up the theme + checks SuperCache before routing.
  • Frontend\Site gained input (Request), templateParser, cache,
    currentTemplate(), getBasePath(), getPageUrl() (cycle-safe).
  • Frontend\PageRepository gained typed findByParent/findInTimeRange/
    countByParent/levels (all with visited-set cycle detection — the
    migrated demo data has page id=8 pointing parent→8 to itself, which would
    otherwise OOM the request).
  • _tpls.php migrated [[VAR]]{{var}} for the iManager
    TemplateRenderer; pagination fragments grouped to match
    PaginationRenderer's expected keys.
  • basic-theme-config.php: dropped static Scriptor::getConfig() /
    BasicTheme::VERSION references; merged from $site->config at runtime.
  • MailChimp: typed properties, dropped dead Imanager\Util import,
    defensive defaults.

Subscribe / contact / loadToken endpoints are kept as a bridge with the new
typed Request accessors and JSON responses; CSRF placeholders are empty
until 14c-1 (auth module) wires CSRF back.

Test plan

  • GET / 200, 7.3 KB
  • GET /scriptors-demo-page 200, 7.5 KB (home alt slug)
  • GET /articles/ 200, 7.1 KB (article list)
  • GET /articles/page2/ 200, 5.8 KB (paginated)
  • GET /articles/get-started-with-scriptor 200, 7.7 KB (single article,
    forced blog-post template)
  • GET /contact 200, 7.1 KB (form)
  • GET /this-does-not-exist 404
  • Browser smoke against ServBay

bigin added 5 commits May 3, 2026 10:00
- composer.json now requires bigins/imanager:2.0.x-dev via a path
  repository on ../imanager (symlinked); platform pinned to PHP 8.2
  so the lock file matches ServBay's runtime even when the dev
  machine has a newer PHP.
- New PSR-4 namespace `Scriptor\Boot\` (-> boot/) holds:
    - ImanagerBootstrap::create() — wires PDO + Sqlite storage +
      every repository + Sanitizer + FieldTypeRegistry (all 16 v1
      field types) + FilesystemCache + LocalFileStorage +
      ImageProcessor + FullTextSearch.
    - App — process-wide service-locator bridge so legacy code can
      reach the container during the 14b–14e transition; emptied
      out at the end of Phase 14.
- boot.php is gutted to container-only. The legacy 1.x library
  (Scriptor/imanager/) shares the `Imanager\` namespace with the
  new vendor package and cannot coexist, so the public site and
  editor are intentionally non-functional on this branch until
  14b/14c rebuild them. `master` remains the working 1.x build.
- test-bootstrap.php is the §14a smoke page: boots the container,
  resolves every registered service, and dumps categories + fields
  + item counts as JSON.
- .gitignore covers vendor/, the migrated SQLite db (+ wal/shm),
  the new uploads-2.0 layout, the section cache, and data.bak.*
  migration backups.

Migration was run beforehand against /data with the iManager 2.0
CLI (PR #17): 2 categories, 10 fields, 9 items, 12 assets, 0
errors. Backup at data.bak.2026-05-03.
## Summary                                                
  - composer.json: path-repo to ../imanager (symlink), `bigins/imanager:2.0.x-dev`,
    platform pinned to PHP 8.2 to match ServBay's runtime.                         
  - New PSR-4 namespace `Scriptor\Boot\` (boot/):                                                                                                                                                                                                                                                                                                                                          
    - `ImanagerBootstrap::create()` — wires PDO + Sqlite storage + all repos +
      Sanitizer + FieldTypeRegistry (16 field types) + FilesystemCache +                                                                                                                                                                                                                                                                                                                   
      LocalFileStorage + ImageProcessor + FullTextSearch.                                                                                                                                                                                                                                                                                                                                  
    - `App` — process-wide service locator bridge for the 14b–14e transition.                                                                                                                                                                                                                                                                                                              
  - `boot.php` gutted to container-only. Legacy 1.x site/editor are                                                                                                                                                                                                                                                                                                                        
    intentionally non-functional on this branch (Imanager\ namespace clash).                                                                                                                                                                                                                                                                                                               
    `master` remains the working 1.x build as the rollback path.                                                                                                                                                                                                                                                                                                                           
  - `test-bootstrap.php` smoke page resolves every registered service and                                                                                                                                                                                                                                                                                                                  
    reads back categories+fields+item counts from the migrated SQLite DB.                                                                                                                                                                                                                                                                                                                  
  - `.gitignore` for vendor/, imanager.db*, uploads-2.0/, cache/sections/,                                                                                                                                                                                                                                                                                                                 
    data.bak.*.                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                           
  Migration ran beforehand against /data with the iManager 2.0 CLI:                                                                                                                                                                                                                                                                                                                        
  2 categories, 10 fields, 9 items, 12 assets, 0 errors. Backup at                                                                                                                                                                                                                                                                                                                         
  data.bak.2026-05-03/.                                           
                                                                                                                                                                                                                                                                                                                                                                                           
  ## Test plan                                              
  - [x] composer install läuft auf PHP 8.3 (ServBay)                                                                                                                                                                                                                                                                                                                                       
  - [x] `php test-bootstrap.php` gibt JSON mit allen Services + Categories aus
  - [x] `php -r 'require "boot.php"; ...'` lädt Container ohne Fehler                                                                                                                                                                                                                                                                                                                      
  - [ ] Browser-Smoke: `https://<scriptor-host>/test-bootstrap.php`
Public site renders from the migrated SQLite DB through a brand-new,
container-driven render path. Default-theme files (default.php,
template.php, _head/_header/_footer.php) keep working as adapter
templates — only one $site->version substitution in _footer.php.

New PSR-4 namespace `Scriptor\Boot\Frontend\`:
  - Page         — readonly DTO around `Imanager\Domain\Item`; surfaces
                   slug/template/parent/content/menu_title/images plus
                   any other field via __get against the FieldValueBag.
  - PageRepository
                 — wrapper over CategoryRepository + ItemRepository for
                   the Pages category; find/findBySlug/findHome/
                   findByParent/findActiveByParent built on the iManager
                   Query AST.
  - Sanitizer    — facade over `Imanager\Validation\Sanitizer` adding
                   the legacy-only `templateName()` and `pageName()`
                   helpers themes still call.
  - Site         — minimal renderer: resolves the requested slug from
                   `$_SERVER['REQUEST_URI']`, exposes the legacy `$site`
                   surface (siteUrl, themeUrl, config, version, page,
                   sanitizer, render(), cache(), throw404(), getTCP()
                   stub with sane defaults). The render() switch returns
                   '' for theme-overridable hooks (hero, mainNavItems,
                   footerNav, …) so the default render path doesn't
                   crash before BasicTheme reattaches in 14b-2.

boot.php now loads vendor/autoload + container + the legacy
scriptor-config.php (with IS_IM/IM_DATAPATH defines so the legacy file
header doesn't die()). The 1.x `imanager/` library and
`editor/core/scriptor.php` stay disabled — same Imanager\ namespace
clash as 14a.

index.php constructs Frontend\Site directly and includes the theme
template. The basic-theme `_ext.php` (BasicRouter / SuperCache /
BasicTheme) is intentionally NOT loaded here — comes back in 14b-2.

Manual smoke (PHP built-in server):
  GET /                       → 200, 5.3 KB, <h1>Scriptor's Demo Page</h1>
  GET /scriptors-demo-page    → 200, identical (home slug)
  GET /this-does-not-exist    → 404, sane fallback

Markdown content rendered via Sanitizer::markdown() (Parsedown +
HTMLPurifier when enabled).
Phase 14b-1: Frontend skeleton on iManager 2.0 container
The bundled basic theme now extends Frontend\Site and pulls every
service from the container — no remaining call into the legacy
imanager() function or editor/core/ classes survives the public
render path. Pagination, theme cache, template fragments, navigation,
archive, hero, contact and subscribe are all on 2.0 plumbing.

Key rewrites:
  - BasicTheme (lib/Basic.php) extends Frontend\Site and overrides
    init()+render(). Article list / archive use the typed
    PageRepository methods (findInTimeRange, findByParent,
    countByParent), pagination is built with iManager's Pagination
    value object + PaginationRenderer. Single-article rendering
    forces template `blog-post` via currentTemplate() instead of
    mutating the Page DTO. Contact + subscribe + loadToken endpoints
    preserved as a bridge with the new typed Request accessors and
    JSON responses; CSRF placeholders are empty until 14c-1 wires
    auth back.
  - BasicRouter (lib/BasicRouter.php) collapsed to a 22-line wrapper
    that dispatches actions and delegates routing to BasicTheme.
  - _ext.php sets up BasicTheme + checks the FilesystemCache for a
    SuperCache hit before invoking the router.
  - lib/subscriber/MailChimp.php: typed properties, removed dead
    Imanager\Util import, defensive defaults for missing config.

Frontend\Site additions for the theme surface:
  - Properties: input (Imanager\Http\Request), templateParser
    (TemplateRenderer), cache (FilesystemCache), msgs[]
  - currentTemplate() override hook for blog-style routing
  - getBasePath(), getPageUrl() (cycle-safe), addMsg()
  - init() empty hook for theme subclasses

Frontend\PageRepository additions:
  - findByParent(parent, orderBy, direction, activeOnly, offset, limit)
  - findInTimeRange(start, end, parent, orderBy, direction)
  - countByParent(parent, activeOnly)
  - levels(rootParent, maxDepth, activeOnly, excludeIds) with
    visited-set cycle detection (the migrated demo data has page id=8
    pointing parent→8 to itself; would otherwise OOM the request)
  - descendants(parent) with the same cycle guard

Theme files & data:
  - resources/_tpls.php migrated from `[[VAR]]` to `{{var}}` so the
    iManager TemplateRenderer (Phase 11) resolves them; pagination
    fragments grouped under a `pagination` sub-array with the keys
    PaginationRenderer expects (wrapper/link/current/prev/...).
  - data/settings/basic-theme-config.php: dropped the static
    Scriptor::getConfig() / BasicTheme::VERSION references that
    don't autoload on the 2.0 stack — BasicTheme::init() merges the
    live values from $site->config.
  - template.php uses $site->currentTemplate() so the blog routing
    can override without mutating the Page DTO.
  - index.php delegates to the theme's _ext.php when present and
    bails out cleanly when _ext.php returns early on a SuperCache hit.

Manual smoke (PHP built-in server):
  GET /                                        200, 7.3 KB
  GET /scriptors-demo-page                     200, 7.5 KB (home alt)
  GET /articles/                               200, 7.1 KB (article list)
  GET /articles/page2/                         200, 5.8 KB (paginated)
  GET /articles/get-started-with-scriptor      200, 7.7 KB (single article)
  GET /contact                                 200, 7.1 KB (form)
  GET /this-does-not-exist                     404
@bigin bigin merged commit 9637388 into master May 12, 2026
@bigin bigin deleted the phase-14b2-basictheme branch May 15, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant