Class: Aardi::Post

Inherits:
AbstractBlog show all
Includes:
AbstractPageSupport
Defined in:
lib/aardi/post.rb

Instance Attribute Summary

Attributes included from AbstractPageSupport

#metadata, #mtime

Attributes inherited from AbstractBlog

#key

Instance Method Summary collapse

Methods included from AbstractPageSupport

#parse_source, #title

Methods inherited from AbstractBlog

#metadata, #mtime, #render

Constructor Details

#initialize(path) ⇒ Post

Returns a new instance of Post.



7
8
9
10
11
# File 'lib/aardi/post.rb', line 7

def initialize(path)
  @path = path
  parse_source path
  raise "#{path}: missing Creation metadata" unless ['Creation']
end

Instance Method Details

#contentObject



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

def content
  "#{@src_content}\n<div><span class=\"bookmark\">[<a href=\"#{url}\">bookmark</a>]</span></div>\n"
end

#creationObject



17
# File 'lib/aardi/post.rb', line 17

def creation = ['Creation']

#dayObject



19
# File 'lib/aardi/post.rb', line 19

def day = creation.day

#feed_snippetObject



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

def feed_snippet
  clean_content = @src_content.sub(/\A(### .*\n)?\n+/, '')
  render_markup(clean_content).strip
end

#monthObject



26
# File 'lib/aardi/post.rb', line 26

def month = creation.month

#nameObject



28
# File 'lib/aardi/post.rb', line 28

def name = File.basename(@path, '.*')

#report_field_summaryObject



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

def report_field_summary
  creation_header = creation.strftime('%e %b %Y')
  puts "#{creation_header} | #{@path} | #{title}"
end

#target_pathObject



35
36
37
# File 'lib/aardi/post.rb', line 35

def target_path
  "./#{short_target}.html"
end

#updatedObject



39
# File 'lib/aardi/post.rb', line 39

def updated = ['Updated'] || creation

#urlObject



41
# File 'lib/aardi/post.rb', line 41

def url = "#{Aardi.config[:site_url]}/#{short_target}"

#yearObject



43
# File 'lib/aardi/post.rb', line 43

def year = creation.year