MishkaCmsCore.Dev.Generator (Mishka CMS Core v0.0.1)

Copy Markdown View Source

Generator for MishkaCmsCore resources.

  • Test functions (no prefix): simple, deterministic — used by factory and tests.
  • Dev functions (dev_ prefix): realistic, rich data — used by dev seeds.

Every attribute an action accepts is named

One a generator leaves out is INVENTED by Ash.Generator from its type, and a type is looser than the resource: a layout's example drawn from all of printable Unicode passes min_length: 3 and is refused by the guard, which strips zero-width and control characters before counting, so seeds failed now and then. The same omission made precompile a coin flip and uploads a random list before it. MishkaCmsCore.Dev.GeneratorNamesEveryAttributeTest reads each defaults list against its action's accept, so an attribute added to a resource fails there first.

The error-page templates are AUTHOR CONTENT, not markup

generate_error_pages/0 builds template STRINGS that are written into the database. Nothing here is rendered by Phoenix: MishkaCmsCore.Runtime.Compilers.ErrorCompiler reads those rows back, compiles them per site and serves them from a controller on a PUBLIC page. Two things follow.

Their Tailwind classes are found by the per-site pass over stored templates rather than by mix admin_css, which is why test/mishka_cms_web/live/interpolated_class_test.exs exempts this file by name.

And they cannot carry an inline event handler. A site that enforces a Content-Security-Policy refuses onclick= outright — script-src has no nonce or hash that applies to an event handler, so the attribute IS the violation — and there is no LiveView on an error page to accept a phx-click instead. A control that needs the browser to move is therefore a link: "Try Again" re-requests @conn.request_path, which is what a reload is. Walking back through history is the one thing no link expresses, so it is not offered.

Summary

Functions

component(opts \\ [], tenant \\ nil)

dev_error_page(opts \\ [], tenant)

dev_layout_global(opts \\ [])

dev_layout_with_tenant(opts \\ [], tenant)

dev_page_with_layout(opts \\ [], tenant, layout_id)

dev_page_without_layout(opts \\ [], tenant)

dev_site(opts \\ [])

error_page(opts \\ [], tenant \\ nil)

generate(generator)

See Ash.Generator.generate/1.

generate_many(generator, count)

See Ash.Generator.generate_many/2.

js_hook(opts \\ [], tenant \\ nil)

layout(opts \\ [], tenant \\ nil)

media(opts \\ [], tenant \\ nil)

media_category(opts \\ [], tenant \\ nil)

page(opts \\ [], tenant \\ nil)

permission(opts \\ [])

redirect(opts \\ [], tenant \\ nil)

site(opts \\ [])

user(opts \\ [], tenant \\ nil)