Class: Thoth::SearchController

### Home Classes Methods

### In Files

- lib/thoth/controller/search.rb

### Parent

Ramaze::Controller

### Methods

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

### Public Instance Methods

index() click to toggle source

    # File lib/thoth/controller/search.rb, line 44
    def index
      redirect_referrer if request[:q].nil? || request[:q].empty?
      @query = request[:q].strip
      redirect_referrer if @query.empty?

      count  = request[:count] ? request[:count].strip.to_i : 10
      start  = request[:start] ? request[:start].strip.to_i : 1

      count = 5   if count < 5
      count = 100 if count > 100
      start = 1   if start < 1
      start = 990 if start > 990

      @title = "Search results for #{@query}"

      @data = yahoo_search(
        "#{@query} -inurl:/tag -inurl:/archive -inurl:/search",
        :adult_ok => 1,
        :results  => count,
        :site     => Config.site.url.gsub(/^https?:\/\/([^\/]+)\/?$/){$1},
        :start    => start
      )

      # Set up pagination links.
      if @data[:available] > @data[:returned]
        if @data[:start] > 1
          prev_start = start - count
          prev_start = 1 if prev_start < 1

          @prev_url = "#{Rs()}?q=#{u(@query)}&count=#{count}&start=" <<
              prev_start.to_s
        end

        if @data[:available] > (@data[:start] + @data[:returned])
          next_start = start + @data[:returned]
          next_start = 1001 - count if next_start > (1001 - count)

          @next_url = "#{Rs()}?q=#{u(@query)}&count=#{count}&start=" <<
              next_start.to_s
        end
      end

    rescue SearchError => e
      @error = e.message
      @data  = {:results => []}
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.