Class: Writecast::Index
- Includes:
- UUIDTools
- Defined in:
- lib/writecast/models.rb
Instance Attribute Summary
Attributes inherited from Document
#body, #file_path, #link_path, #raw_file_path, #summary, #tags, #time, #title
Instance Method Summary collapse
-
#initialize(posts_hash, tags_hash, num_posts) ⇒ Index
constructor
A new instance of Index.
- #to_atom ⇒ Object
- #to_html(pages) ⇒ Object
Constructor Details
#initialize(posts_hash, tags_hash, num_posts) ⇒ Index
Returns a new instance of Index.
94 95 96 97 98 99 100 101 102 |
# File 'lib/writecast/models.rb', line 94 def initialize(posts_hash, , num_posts) @title = INDEX_TITLE # used to indicate 'selected' in the menu @file_path = 'index.html' @link_path = '/' @posts_hash = posts_hash @tags_hash = @num_posts = num_posts @recent_posts = recent_posts end |
Instance Method Details
#to_atom ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/writecast/models.rb', line 111 def to_atom feed = Atom::Feed.new do |f| f.title = SITE_TITLE f.links << Atom::Link.new(:href => SITE_URI) f.updated = Time.now f. << Atom::Person.new(:name => SITE_AUTHOR) f.id = "urn:uuid:#{UUID.sha1_create(UUID_URL_NAMESPACE, SITE_URI).to_s}" @recent_posts.each do |post| f.entries << Atom::Entry.new do |e| e.title = post.title e.links << Atom::Link.new(:href => SITE_URI + post.link_path) e.id = post.id e.updated = post.time e.summary = post.summary end end end feed.to_xml end |
#to_html(pages) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/writecast/models.rb', line 104 def to_html(pages) years = @posts_hash.keys Index_view.new(:doc => self, :pages => pages, :recent_posts => @recent_posts, :years => years, :title_tag => SITE_TITLE, :tags_hash => @tags_hash, :num_posts => @num_posts).to_html(:prettyprint => PRETTY_HTML) end |