Class: Ucode::Audit::Browser::LibraryPage
- Inherits:
-
Object
- Object
- Ucode::Audit::Browser::LibraryPage
- Includes:
- Repo::AtomicWrites
- Defined in:
- lib/ucode/audit/browser/library_page.rb
Overview
Renders the library-level index.html — a card grid of all
audited fonts in a library, with search/sort/filter controls.
The page inlines the same JSON shape that
Emitter::LibraryEmitter writes to index.json, plus inlined
CSS and JS. Clicking a card navigates to that face's
per-face browser (<label>/index.html).
Self-contained: no external resources. The entire
output/font_audit/ tree is portable as a unit.
Two construction modes — pass exactly one of:
- `summary:` — a live {Models::Audit::LibrarySummary}. The
JSON shape is derived via {Emitter::LibraryEmitter#build_index}.
- `library_json:` — a pre-built JSON string of the library
overview shape. Used by {Commands::AuditBrowserCommand}
when regenerating HTML from an existing `index.json`.
Instance Method Summary collapse
-
#initialize(summary: nil, library_json: nil) ⇒ LibraryPage
constructor
A new instance of LibraryPage.
-
#render ⇒ String
Render the page as a string.
-
#write(output_root) ⇒ Boolean
Write the rendered page to
<library_root>/index.html.
Methods included from Repo::AtomicWrites
#same_content?, #to_pretty_json, #write_atomic
Constructor Details
#initialize(summary: nil, library_json: nil) ⇒ LibraryPage
Returns a new instance of LibraryPage.
37 38 39 40 41 42 43 |
# File 'lib/ucode/audit/browser/library_page.rb', line 37 def initialize(summary: nil, library_json: nil) raise ArgumentError, "pass exactly one of summary: / library_json:" \ unless summary.nil? ^ library_json.nil? @summary = summary @library_json = library_json end |
Instance Method Details
#render ⇒ String
Render the page as a string.
55 56 57 58 59 60 |
# File 'lib/ucode/audit/browser/library_page.rb', line 55 def render Template.new(:library).render( library_json: library_json, page_title: "ucode audit library", ) end |
#write(output_root) ⇒ Boolean
Write the rendered page to <library_root>/index.html.
48 49 50 51 |
# File 'lib/ucode/audit/browser/library_page.rb', line 48 def write(output_root) path = Ucode::Audit::Emitter::Paths.library_html_path(output_root) write_atomic(path, render) end |