Class: Lifer::Entry::HTML
- Inherits:
-
Lifer::Entry
- Object
- Lifer::Entry
- Lifer::Entry::HTML
- Defined in:
- lib/lifer/entry/html.rb
Overview
If the entry input is mainly HTML, then this subclass should track it and define its functionality. That means HTML files, and any file that compiles into an HTML file.
Constant Summary
Constants inherited from Lifer::Entry
DEFAULT_DATE, FILENAME_DATE_FORMAT, TAG_DELIMITER_REGEX, TRUNCATION_THRESHOLD
Instance Attribute Summary
Attributes inherited from Lifer::Entry
Instance Method Summary collapse
-
#title ⇒ String
If there is no available metadata in the HTML file, we can extract a makeshift title from the permalink.
-
#to_html ⇒ String
As an entry subclass, this method must be implemented, even though it doesn’t do much here.
Methods inherited from Lifer::Entry
#authors, #body, #feedable?, #frontmatter, #full_text, generate, #initialize, manifest, #path, #permalink, #published_at, #summary, supported?, #tags, #updated_at
Constructor Details
This class inherits a constructor from Lifer::Entry
Instance Method Details
#title ⇒ String
If there is no available metadata in the HTML file, we can extract a makeshift title from the permalink.
Depending on the filename and URI strategy being used for the collection, it’s possible that the extracted title would be “index”, which is not very descriptive. If that’s the case, we attempt to go up a directory to find a non-“index” title.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lifer/entry/html.rb', line 19 def title return frontmatter[:title] if frontmatter[:title] candidate = File.basename(permalink, ".html") if candidate.include?("index") && !file.to_s.include?("index") File.basename(permalink.sub(/\/#{candidate}\.html$/, "")) else candidate end end |
#to_html ⇒ String
As an entry subclass, this method must be implemented, even though it doesn’t do much here.
35 |
# File 'lib/lifer/entry/html.rb', line 35 def to_html = body |