Class: Howl::Post

Inherits:
Template show all
Includes:
Comparable
Defined in:
lib/howl/post.rb

Instance Attribute Summary

Attributes inherited from Template

#content, #extension, #path, #relative_path, #site, #view, #view_yaml

Instance Method Summary collapse

Methods inherited from Template

#==, can_view, #converter, #initialize, #output_filename, #render, viewables

Constructor Details

This class inherits a constructor from Howl::Template

Instance Method Details

#<=>(other) ⇒ Object



9
10
11
# File 'lib/howl/post.rb', line 9

def <=>(other)
  other.date <=> self.date
end

#dateObject



5
6
7
# File 'lib/howl/post.rb', line 5

def date
  view.date? ? Time.parse(view.date.to_s) : File.mtime(path)
end

#dom_idObject



21
22
23
# File 'lib/howl/post.rb', line 21

def dom_id
  title.slugify
end


25
26
27
# File 'lib/howl/post.rb', line 25

def link
  "/" + output_path.relative_path_from(site.output_path).to_s
end

#output_pathObject



13
14
15
# File 'lib/howl/post.rb', line 13

def output_path
  site.output_path("posts") + date.strftime("%Y/%m/%d") + output_filename
end

#rendered_contentObject



29
30
31
32
33
# File 'lib/howl/post.rb', line 29

def rendered_content
  render_view = view.dup
  render_view.delete('template')
  converter.convert(Mustache.render(@content, render_view))
end

#titleObject



17
18
19
# File 'lib/howl/post.rb', line 17

def title
  view.title || path.basename(extension).to_s
end

#view_dataObject



35
36
37
38
39
# File 'lib/howl/post.rb', line 35

def view_data
  { :site => site,
    :date => date,
    :link => link }
end