PhoenixKitOG.Render (PhoenixKitOG v0.3.2)

Copy Markdown View Source

Top-level rendering facade. Given a template + binding values, produces a PNG (cached) and returns its public URL.

Pipeline (since the OpenFresco switch):

template + values/globals  SceneStore.load (lazy legacy-canvas
                             migration)
                             Media.prepare (UUIDs  data: URLs,
                             :public fallbacks)
                             cache lookup
                             
                              hit  served path
                             
                              miss  OpenFresco.render/3
                                         (measured text, anchors,
                                         gradients, rasterize)
                                         atomic write to cache

SVG generation, text layout, and rasterization all belong to open_fresco now; this module keeps media resolution, caching, and the URL contract. When no rasterizer backend is reachable (:rasterizer_missing), the caller (PhoenixKitOG.refine_og/4) drops back to the pre-existing og.image — never a crash.

Summary

Functions

Returns just the public URL for a key (whether or not it exists).

Returns {:ok, public_url} on success, {:error, reason} on failure.

Functions

cache_url(key)

@spec cache_url(String.t()) :: String.t()

Returns just the public URL for a key (whether or not it exists).

render_url(template, context)

@spec render_url(PhoenixKitOG.Schemas.Template.t(), map()) ::
  {:ok, String.t()} | {:error, term()}

Returns {:ok, public_url} on success, {:error, reason} on failure.

context keys:

  • :values — resolved {{slot}} values (map, required)
  • :globals[[global]] values (map, default %{})
  • :mode:public (crawler-facing; unresolved image slots fall back / drop) or :preview (unresolved image slots draw OpenFresco's labeled stand-in). Default :public.

Side effect: caches the PNG on disk so the next call is a no-op.