Class: Thoth::MainController

### Home Classes Methods

### In Files

- lib/thoth/controller/main.rb

### Parent

Ramaze::Controller

### Methods

- #'recent-comments'
- #archives
- #article
- #atom
- #comments
- #index
- #rss
- #sitemap

### 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::MainController

### Public Instance Methods

'recent-comments'() click to toggle source
Alias for: comments
archives(page = 1) click to toggle source

Legacy redirect to /archive/`page`.

    # File lib/thoth/controller/main.rb, line 170
    def archives(page = 1)
      redirect R(ArchiveController, page), :status => 301
    end

article(name) click to toggle source

Legacy redirect to /post/`name`.

    # File lib/thoth/controller/main.rb, line 175
    def article(name)
      redirect R(PostController, name), :status => 301
    end

atom() click to toggle source

    # File lib/thoth/controller/main.rb, line 57
    def atom
      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       Config.site.url
        x.title    Config.site.name
        x.subtitle Config.site.desc
        x.updated  Time.now.xmlschema # TODO: use modification time of the last post
        x.link     :href => Config.site.url
        x.link     :href => Config.site.url.chomp('/') + Rs(:atom),
                   :rel => 'self'

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

        Post.recent.all.each 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

comments() click to toggle source

Legacy redirect to /comment.

    # File lib/thoth/controller/main.rb, line 180
    def comments
      if type = request[:type]
        redirect R(CommentController, type), :status => 301
      else
        redirect R(CommentController), :status => 301
      end
    end

Also aliased as: 'recent-comments'
index() click to toggle source

    # File lib/thoth/controller/main.rb, line 46
    def index
      # Check for legacy feed requests and redirect if necessary.
      if type = request[:type]
        redirect Rs(type), :status => 301
      end

      @title = Config.site.name
      @posts = Post.recent
      @pager = pager(@posts, Rs(:archive, '%s'))
    end

rss() click to toggle source

    # File lib/thoth/controller/main.rb, line 96
    def rss
      response['Content-Type'] = 'application/rss+xml'

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

      x.rss(:version     => '2.0',
            'xmlns:atom' => 'http://www.w3.org/2005/Atom') {
        x.channel {
          x.title          Config.site.name
          x.link           Config.site.url
          x.description    Config.site.desc
          x.managingEditor "#{Config.admin.email} (#{Config.admin.name})"
          x.webMaster      "#{Config.admin.email} (#{Config.admin.name})"
          x.docs           'http://backend.userland.com/rss/'
          x.ttl            60
          x.atom           :link, :rel => 'self',
                               :type => 'application/rss+xml',
                               :href => Config.site.url.chomp('/') + Rs(:rss)

          Post.recent.all.each do |post|
            x.item {
              x.title       post.title
              x.link        post.url
              x.guid        post.url, :isPermaLink => 'true'
              x.pubDate     post.created_at.rfc2822
              x.description post.body_rendered

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

sitemap() click to toggle source

    # File lib/thoth/controller/main.rb, line 133
    def sitemap
      error_404 unless Config.site.enable_sitemap

      response['Content-Type'] = 'text/xml'

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

      x.urlset(:xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9') {
        x.url {
          x.loc        Config.site.url
          x.changefreq 'hourly'
          x.priority   '1.0'
        }

        Page.reverse_order(:updated_at).all do |page|
          x.url {
            x.loc        page.url
            x.lastmod    page.updated_at.xmlschema
            x.changefreq 'weekly'
            x.priority   '0.6'
          }
        end

        now = Time.now

        Post.reverse_order(:updated_at).all do |post|
          x.url {
            x.loc        post.url
            x.lastmod    post.updated_at.xmlschema
            x.changefreq 'weekly'
          }
        end
      }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.