Class: Abqari::PublisherIndexPage
- Inherits:
-
Object
- Object
- Abqari::PublisherIndexPage
- Defined in:
- lib/abqari/publisher_pages.rb
Overview
Index page for a kind (publications / bundles / series). Renders
the matching collection-index layout, which iterates the merged
site.collection(name) (manual + externally-sourced).
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
- #bundle_images ⇒ Object
- #content ⇒ Object
- #description ⇒ Object
- #frontmatter ⇒ Object
-
#initialize(site, kind, layout, url) ⇒ PublisherIndexPage
constructor
A new instance of PublisherIndexPage.
- #lastmod ⇒ Object
- #layout_name ⇒ Object
- #needs_render? ⇒ Boolean
-
#output_path ⇒ Object
Bounded-trust external data per docs/security.md §1.
- #title ⇒ Object
- #url ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(site, kind, layout, url) ⇒ PublisherIndexPage
Returns a new instance of PublisherIndexPage.
134 135 136 137 138 139 |
# File 'lib/abqari/publisher_pages.rb', line 134 def initialize(site, kind, layout, url) @site = site @kind = kind @layout = layout @url = url end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
132 133 134 |
# File 'lib/abqari/publisher_pages.rb', line 132 def kind @kind end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
132 133 134 |
# File 'lib/abqari/publisher_pages.rb', line 132 def site @site end |
Instance Method Details
#bundle_images ⇒ Object
193 194 195 |
# File 'lib/abqari/publisher_pages.rb', line 193 def bundle_images [] end |
#content ⇒ Object
149 150 151 |
# File 'lib/abqari/publisher_pages.rb', line 149 def content '' end |
#description ⇒ Object
145 146 147 |
# File 'lib/abqari/publisher_pages.rb', line 145 def description "All #{@kind}." end |
#frontmatter ⇒ Object
153 154 155 |
# File 'lib/abqari/publisher_pages.rb', line 153 def frontmatter {} end |
#lastmod ⇒ Object
189 190 191 |
# File 'lib/abqari/publisher_pages.rb', line 189 def lastmod Time.now end |
#layout_name ⇒ Object
174 175 176 |
# File 'lib/abqari/publisher_pages.rb', line 174 def layout_name @layout end |
#needs_render? ⇒ Boolean
178 179 180 181 182 183 184 185 186 187 |
# File 'lib/abqari/publisher_pages.rb', line 178 def needs_render? return true unless File.exist?(output_path) output_mtime = File.mtime(output_path) return true if output_mtime < @site.shared_deps_mtime # Layouts are tracked per-page rather than in GLOBAL_DEP_GLOBS — # without this, editing `publications_index.html.erb` left the # index stale on the dev server. @site.layout_deps_mtime(layout_name) > output_mtime end |
#output_path ⇒ Object
Bounded-trust external data per docs/security.md §1. The slug
flows into this URL — route through PathSafe so a hostile or
accidental "slug": "../../etc" raises a build error instead
of writing outside _site/.
165 166 167 |
# File 'lib/abqari/publisher_pages.rb', line 165 def output_path PathSafe.join_under(@site.output_dir, @url.sub(%r{\A/}, '').chomp('/'), 'index.html') end |
#title ⇒ Object
141 142 143 |
# File 'lib/abqari/publisher_pages.rb', line 141 def title @kind.capitalize end |
#url ⇒ Object
157 158 159 |
# File 'lib/abqari/publisher_pages.rb', line 157 def url @url end |
#write ⇒ Object
169 170 171 172 |
# File 'lib/abqari/publisher_pages.rb', line 169 def write FileUtils.mkdir_p(File.dirname(output_path)) File.write(output_path, @site.post_process(render, page: self)) end |