Class: Abqari::VizPage
- Inherits:
-
Object
- Object
- Abqari::VizPage
- Defined in:
- lib/abqari/visualizations.rb
Overview
A single visualization page. Generated by Visualizations#pages and added to Site's @generated_pages, so it renders through the normal pipeline.
Constant Summary collapse
- TITLES =
{ 'tag-bubble' => 'Tag Bubble', 'tag-cooccurrence' => 'Tag Co-occurrence', 'topic-constellation' => 'Topic Constellation' }.freeze
- DESCRIPTIONS =
{ 'tag-bubble' => 'Each tag rendered as a circle, sized by the number of posts using it.', 'tag-cooccurrence' => 'Which tags appear together — chord diagram of tag overlap across posts.', 'topic-constellation' => 'Posts as nodes, connected by shared tags. Drag to explore.' }.freeze
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#viz_name ⇒ Object
readonly
Returns the value of attribute viz_name.
Instance Method Summary collapse
- #bundle_images ⇒ Object
- #content ⇒ Object
- #description ⇒ Object
- #frontmatter ⇒ Object
-
#initialize(viz_name, site) ⇒ VizPage
constructor
A new instance of VizPage.
- #lastmod ⇒ Object
-
#layout_name ⇒ Object
Used by Site's incremental render: re-render when shared deps change or any post changes (since post data feeds the JSON).
- #needs_render? ⇒ Boolean
- #output_path ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(viz_name, site) ⇒ VizPage
Returns a new instance of VizPage.
149 150 151 152 |
# File 'lib/abqari/visualizations.rb', line 149 def initialize(viz_name, site) @viz_name = viz_name @site = site end |
Instance Attribute Details
#site ⇒ Object (readonly)
Returns the value of attribute site.
147 148 149 |
# File 'lib/abqari/visualizations.rb', line 147 def site @site end |
#viz_name ⇒ Object (readonly)
Returns the value of attribute viz_name.
147 148 149 |
# File 'lib/abqari/visualizations.rb', line 147 def viz_name @viz_name end |
Instance Method Details
#bundle_images ⇒ Object
205 206 207 |
# File 'lib/abqari/visualizations.rb', line 205 def bundle_images [] end |
#content ⇒ Object
162 163 164 |
# File 'lib/abqari/visualizations.rb', line 162 def content '' end |
#description ⇒ Object
158 159 160 |
# File 'lib/abqari/visualizations.rb', line 158 def description DESCRIPTIONS[viz_name] end |
#frontmatter ⇒ Object
166 167 168 |
# File 'lib/abqari/visualizations.rb', line 166 def frontmatter {} end |
#lastmod ⇒ Object
201 202 203 |
# File 'lib/abqari/visualizations.rb', line 201 def lastmod @site.posts.map(&:lastmod).compact.max end |
#layout_name ⇒ Object
Used by Site's incremental render: re-render when shared deps change or any post changes (since post data feeds the JSON).
185 186 187 |
# File 'lib/abqari/visualizations.rb', line 185 def layout_name 'visualization' end |
#needs_render? ⇒ Boolean
189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/abqari/visualizations.rb', line 189 def needs_render? return true unless File.exist?(output_path) output_mtime = File.mtime(output_path) return true if @site.shared_deps_mtime > output_mtime # Layouts live outside GLOBAL_DEP_GLOBS and are tracked per-page; # only Page consulted them, so editing this layout rebuilt nothing. return true if @site.layout_deps_mtime(layout_name) > output_mtime @site.posts.any? { |post| (post.lastmod || Time.now) > output_mtime } end |
#output_path ⇒ Object
174 175 176 |
# File 'lib/abqari/visualizations.rb', line 174 def output_path File.join(@site.output_dir, 'visualizations', viz_name, 'index.html') end |
#title ⇒ Object
154 155 156 |
# File 'lib/abqari/visualizations.rb', line 154 def title TITLES[viz_name] end |
#url ⇒ Object
170 171 172 |
# File 'lib/abqari/visualizations.rb', line 170 def url "/visualizations/#{viz_name}/" end |
#write ⇒ Object
178 179 180 181 |
# File 'lib/abqari/visualizations.rb', line 178 def write FileUtils.mkdir_p(File.dirname(output_path)) File.write(output_path, @site.post_process(render, page: self)) end |