Skip to content

Feat/community template browser#529

Open
ObsidianTTRPGProject wants to merge 6 commits into
Obsidian-TTRPG-Community:mainfrom
ObsidianTTRPGProject:feat/community-template-browser
Open

Feat/community template browser#529
ObsidianTTRPGProject wants to merge 6 commits into
Obsidian-TTRPG-Community:mainfrom
ObsidianTTRPGProject:feat/community-template-browser

Conversation

@ObsidianTTRPGProject

Copy link
Copy Markdown
Member

Community Template Browser

Adds an in-app browser for installing community-contributed statblock layouts, so users can theme creatures for systems beyond the built-in D&D 5e and Pathfinder 2e support without hand-editing JSON or hunting for CSS snippets.

Motivation

Fantasy Statblocks ships great 5e/PF2e layouts, but support for other systems (OSR, sci-fi horror, etc.) has always meant manually importing someone's exported layout JSON and, for themed cards, manually installing a CSS snippet. This PR turns that into a one-click experience backed by a public, PR-driven registry.

What's included

  • Browse Community Templates button under Settings → Fantasy Statblocks → Layouts, opening a gallery modal.
  • Gallery view — tiles with a preview thumbnail and labeled data (System, Author, Downloads), plus search, a system filter, and a sort dropdown (Name / System / Most popular).
  • Detail view — full live-rendered preview of the layout using the template's example data, the template's description/tags/requirements, and an Install button.
  • One-click install — validates the layout JSON, adds it to the user's custom layouts, installs and enables the template's CSS snippet, and (optionally) drops the example note into a Statblock Templates/ folder so the in-note format is immediately visible.
  • Submit a template button linking to the registry's GitHub issue form.
  • Removes the previously configurable registry-source setting in favor of the official registry.

How it works

The registry is a separate GitHub repo (Obsidian-TTRPG-Community/fantasy-statblocks-templates) with an index.json manifest listing each template's layout, example, css, preview, and metadata.

Asset fetching is split deliberately:

  • Manifest, CSS, example note, and preview image are fetched from raw.githubusercontent.com so author edits reach users immediately — no CDN cache lag and no cold-start.
  • The layout download is routed through the jsDelivr CDN, whose public per-file statistics provide the "Most popular" sort with no backend and nothing phoning home beyond the fetch the plugin already makes.

All network access uses Obsidian's requestUrl (no CORS issues) and degrades gracefully — download stats and previews fall back silently when unavailable.

CSS theming

Templates may ship a CSS snippet that re-themes their layout. On install it's written to .obsidian/snippets/ and enabled automatically; it's tracked against the installed layout id and disabled/cleaned up if that layout is later removed. Snippets are expected to scope their rules to the layout's auto-generated container class (e.g. .mrk-borg-creature) so they only affect their own layout, and may embed textures/fonts as base64 data URIs to stay self-contained.

Safety & privacy

  • Layouts are deep-scanned for javascript blocks; previewing or installing one shows a confirmation prompt first.
  • No telemetry or backend — popularity is derived from jsDelivr's existing CDN stats.
  • Layout JSON is validated before install.

Files

  • src/community/types.ts — manifest schema, registry constants, layout validation, JS-block scan, snippet naming. (new)
  • src/community/manager.ts — all registry network access (manifest, layout, example, CSS, download stats); raw-vs-CDN URL resolution. (new)
  • src/community/BrowseModal.ts — gallery + detail modal, live preview, CSS injection, install flow. (new)
  • src/main.tsCommunityTemplateManager instance, customCss typing, default settings.
  • index.tscommunityTemplateSnippets settings field.
  • src/settings/settings.ts — Browse button and snippet cleanup on layout removal.
  • src/settings/settings.css — modal/gallery/tile/detail styles.
  • src/view/statblock.ts — honor an explicitly-passed layout so not-yet-installed templates can be previewed.
  • community-templates/ — bundled copy of the registry (manifest, example templates, docs).

Testing

  • Written and tested by a robot under the direction of Josh. Someone with a functional non-robot brain should absolutely confirm this code.
  • Verified end-to-end against the live registry in a test vault: browse → filter/sort → open detail → live themed preview → install (adds layout, enables CSS snippet, writes example note).
  • Confirmed the installed layout renders with its theme and that removing the layout cleans up its snippet.
  • Confirmed the live preview and a fresh install both pick up current CSS from raw (no CDN staleness).

Notes / follow-ups

  • Backwards compatible: no changes to existing layouts, monsters, or the in-note statblock format.
  • The submission pipeline (issue form → auto-PR) lives in the registry repo.

Sklore and others added 6 commits June 9, 2026 14:31
…); keep layout on jsDelivr for download counts
Conflict resolutions:
- src/main.ts: take upstream imports (parser/linkify, Bestiary); keep
  communityTemplates manager and communityTemplateSnippets default;
  adopt upstream atomicWrite:false; drop names/#creatures (moved to Bestiary)
- src/settings/settings.ts: take upstream import block, keep BrowseModal import
- src/settings/settings.css: keep both community-browser and loading-spinner blocks
- src/typings/obsidian-extended.d.ts: move customCss typing here (declarations
  relocated from main.ts upstream)
- src/community/*: fix 'types/layout' import to real path src/layouts/layout.types
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.

2 participants