Class: Writecast::Post

Inherits:
Document show all
Includes:
UUIDTools
Defined in:
lib/writecast/models.rb

Instance Attribute Summary collapse

Attributes inherited from Document

#body, #file_path, #link_path, #raw_file_path, #summary, #tags, #time, #title

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Post

Returns a new instance of Post.



59
60
61
62
63
64
65
# File 'lib/writecast/models.rb', line 59

def initialize(file_path)
    super
    path_dir = ["/%04d" % @time.year, "/%02d" % @time.month, "/%02d-" % @time.day].join
    @link_path = path_dir + "%s.html" % CGI.escape(@title)
    @file_path = path_dir + "%s.html" % @title
    @id = "urn:uuid:#{UUID.sha1_create(UUID_URL_NAMESPACE, SITE_URI + @link_path).to_s}"
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



57
58
59
# File 'lib/writecast/models.rb', line 57

def id
  @id
end

Instance Method Details

#to_html(pages) ⇒ Object



67
68
69
70
71
72
# File 'lib/writecast/models.rb', line 67

def to_html(pages)
    title_tag = SITE_TITLE + 
        @time.strftime("#{SEPARATOR}%Y#{SEPARATOR}%B#{SEPARATOR}%d#{SEPARATOR}") + @title
    Post_view.new(:doc => self, :pages => pages, :title_tag => title_tag
                 ).to_html(:prettyprint => PRETTY_HTML)
end