Juggernaut.Report.Html (Juggernaut v0.4.0)

Copy Markdown View Source

The dashboard page (mix juggernaut.report, design notes §11): one HTML file holding its styles, its script and its data (Juggernaut.Report.Data) inline. A Content Security Policy forbids every network request, so the page works offline and leaks nothing.

The data sits in <script type="application/json" id="juggernaut-data">, encoded so that no text inside it can end the element: Jason's :html_safe escape (/ as \/) plus every < as \u003c (deps:jason).

Pages, each a <section> by id: overview, codemap, inspector, tests, performance. The location hash picks one (#inspector/<hash> opens a mutant); ?theme=light|dark forces a theme, otherwise the viewer's preference applies.

Summary

Functions

data as JSON that is safe inside a <script> element: invalid UTF-8 replaced, / escaped and every < written as \u003c. It decodes to the same document.

Escapes text for HTML element content and attribute values.

The page ids, in navigation order.

The page for the data document data.

Functions

encode(data)

@spec encode(term()) :: String.t()

data as JSON that is safe inside a <script> element: invalid UTF-8 replaced, / escaped and every < written as \u003c. It decodes to the same document.

escape(text)

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

Escapes text for HTML element content and attribute values.

pages()

@spec pages() :: [String.t()]

The page ids, in navigation order.

render(data)

@spec render(map()) :: iodata()

The page for the data document data.