Class: Thoth::TagController

### Home Classes Methods

### In Files

- lib/thoth/controller/tag.rb

### Parent

Ramaze::Controller

### Methods

- #atom
- #index

### Files

- robots.txt

### Class/Module Index

Quicksearch

- Thoth
- Thoth::AdminController
- Thoth::ArchiveController
- Thoth::Comment
- Thoth::CommentApiController
- Thoth::CommentController
- Thoth::Config
- Thoth::Error
- Thoth::Importer
- Thoth::MainController
- Thoth::Media
- Thoth::MediaController
- Thoth::MinifyController
- Thoth::Page
- Thoth::PageApiController
- Thoth::PageController
- Thoth::Pager
- Thoth::Plugin
- Thoth::Plugin::Delicious
- Thoth::Plugin::Flickr
- Thoth::Plugin::Tags
- Thoth::Plugin::Twitter
- Thoth::Post
- Thoth::PostApiController
- Thoth::PostController
- Thoth::SchemaError
- Thoth::SearchController
- Thoth::Tag
- Thoth::TagApiController
- Thoth::TagController
- Thoth::TagsPostsMap
- Ramaze
- Ramaze::Dispatcher
- Ramaze::Dispatcher::File
- Ramaze::Helper
- Ramaze::Helper::Admin
- Ramaze::Helper::Cookie
- Ramaze::Helper::Error
- Ramaze::Helper::Pagination
- Ramaze::Helper::Sanitize
- Ramaze::Helper::Wiki
- Ramaze::Helper::Ysearch
- Ramaze::Helper::Ysearch::SearchError
- AddMediaSize
- CreateSchema
- PantsImporter
- PoseidonImporter

No matching classes.

# Thoth::TagController

### Public Instance Methods

atom(name = nil) click to toggle source

    # File lib/thoth/controller/tag.rb, line 68
    def atom(name = nil)
      error_404 unless name && tag = Tag[:name => name.strip.downcase]

      posts   = tag.posts.limit(10)
      updated = posts.count > 0 ? posts.first.created_at.xmlschema :
          Time.at(0).xmlschema

      response['Content-Type'] = 'application/atom+xml'

      x = Builder::XmlMarkup.new(:indent => 2)
      x.instruct!

      x.feed(:xmlns => 'http://www.w3.org/2005/Atom') {
        x.id       tag.url
        x.title    "Posts tagged with \"#{tag.name}\" - #{Config.site.name}"
        x.updated  updated
        x.link     :href => tag.url
        x.link     :href => tag.atom_url, :rel => 'self'

        x.author {
          x.name  Config.admin.name
          x.email Config.admin.email
          x.uri   Config.site.url
        }

        posts.all do |post|
          x.entry {
            x.id        post.url
            x.title     post.title
            x.published post.created_at.xmlschema
            x.updated   post.updated_at.xmlschema
            x.link      :href => post.url, :rel => 'alternate'
            x.content   post.body_rendered, :type => 'html'

            post.tags.each do |tag|
              x.category :term => tag.name, :label => tag.name,
                  :scheme => tag.url
            end
          }
        end
      }
    end

index(name = nil, page = 1) click to toggle source

    # File lib/thoth/controller/tag.rb, line 43
    def index(name = nil, page = 1)
      error_404 unless name && @tag = Tag[:name => name.strip.downcase]

      page = page.to_i
      page = 1 unless page >= 1

      @posts = @tag.posts.paginate(page, 10)

      if page > @posts.page_count && @posts.page_count > 0
        page   = @posts.page_count
        @posts = @tag.posts.paginate(page, 10)
      end

      @title = "Posts tagged with \"#{@tag.name}\" (page #{page} of " <<
          "#{@posts.page_count > 0 ? @posts.page_count : 1})"

      @pager = pager(@posts, Rs(name, '%s'))

      @feeds = [{
        :href  => @tag.atom_url,
        :title => 'Posts with this tag',
        :type  => 'application/atom+xml'
      }]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.