Class: Writecast::Tag_index

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

Instance Method Summary collapse

Constructor Details

#initialize(tag_set, posts) ⇒ Tag_index

Returns a new instance of Tag_index.



185
186
187
188
# File 'lib/writecast/models.rb', line 185

def initialize(tag_set, posts)
    @tag,@escaped_tag = tag_set
    @posts = posts
end

Instance Method Details

#to_atomObject



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/writecast/models.rb', line 197

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.authors << Atom::Person.new(:name => SITE_AUTHOR)
        f.id = "urn:uuid:" + 
            UUID.sha1_create(UUID_URL_NAMESPACE,
                             SITE_URI + "tags/#{@escaped_tag}").to_s
        @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



190
191
192
193
194
195
# File 'lib/writecast/models.rb', line 190

def to_html(pages)
    title_tag = SITE_TITLE + SEPARATOR + "tag: #{@tag}"
    Tag_index_view.new(:doc => self, :tag => @tag, :escaped_tag => @escaped_tag,
                       :posts => @posts, :pages => pages, :title_tag => title_tag
                      ).to_html(:prettyprint => PRETTY_HTML)
end