Class: Ucode::Audit::Browser::FacePage
- Inherits:
-
Object
- Object
- Ucode::Audit::Browser::FacePage
- Includes:
- Repo::AtomicWrites
- Defined in:
- lib/ucode/audit/browser/face_page.rb
Overview
Renders one face's index.html — a fully self-contained
browser page for one audited font.
The page inlines the same JSON shape that Emitter::IndexEmitter
writes to index.json, plus inlined CSS and JS. Opening the
file via file:// renders the overview immediately; lazy
fetches of the per-block chunks (blocks/<NAME>.json,
codepoints/<NAME>.json, glyphs/U+XXXX.svg) work when the
directory is served over HTTP.
Self-contained: no external CSS, no external JS, no CDN.
Portable: the entire <label>/ directory can be moved/served
whole and the page still works.
Two construction modes — pass exactly one of:
- `report:` — a live {Models::Audit::AuditReport}. The JSON
shape is derived via {Emitter::IndexEmitter#build_index}.
Used by {Emitter::FaceDirectory} when emitting alongside
the audit.
- `overview_json:` — a pre-built JSON string of the overview
shape. Used by {Commands::AuditBrowserCommand} when
regenerating HTML from an existing `index.json`.
Instance Method Summary collapse
-
#initialize(report: nil, overview_json: nil, verbose: false, with_glyphs: false, universal_set_root: nil, face_dir: nil) ⇒ FacePage
constructor
A new instance of FacePage.
-
#render ⇒ String
Render the page as a string.
-
#write(face_dir) ⇒ Boolean
Write the rendered page to
<face_dir>/index.html.
Methods included from Repo::AtomicWrites
#same_content?, #to_pretty_json, #write_atomic
Constructor Details
#initialize(report: nil, overview_json: nil, verbose: false, with_glyphs: false, universal_set_root: nil, face_dir: nil) ⇒ FacePage
Returns a new instance of FacePage.
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ucode/audit/browser/face_page.rb', line 55 def initialize(report: nil, overview_json: nil, verbose: false, with_glyphs: false, universal_set_root: nil, face_dir: nil) raise ArgumentError, "pass exactly one of report: / overview_json:" \ unless report.nil? ^ overview_json.nil? @report = report @overview_json = overview_json @verbose = verbose @with_glyphs = with_glyphs @universal_set_root = universal_set_root @face_dir = face_dir end |
Instance Method Details
#render ⇒ String
Render the page as a string. Useful in tests.
78 79 80 81 82 83 84 85 86 |
# File 'lib/ucode/audit/browser/face_page.rb', line 78 def render Template.new(:face).render( overview_json: overview_json, page_title: page_title, verbose: @verbose, with_glyphs: @with_glyphs, universal_set: universal_set_section, ) end |
#write(face_dir) ⇒ Boolean
Write the rendered page to <face_dir>/index.html.
71 72 73 74 |
# File 'lib/ucode/audit/browser/face_page.rb', line 71 def write(face_dir) @face_dir = Pathname.new(face_dir) write_atomic(@face_dir.join("index.html"), render) end |