devdaily home | apple | java | perl | unix | directory | blog

What this is

This file is included in the DevDaily.com "Ruby Source Code Warehouse" project. The intent of this project is to help you "Learn Ruby by Example" TM.

Other links

The source code

# Copyritght (c) 2003 TANIGUCHI Takaki
# This program is distributed under the GNU GPL 2 or later.

require 'aswiki/plugin'

module AsWiki
  # mknmz -U -t text/plain -a -k -L ja ../text
  class SearchPlugin < Plugin
    Name = 'search'
    include I18N
    include Util
    def onview(line, b, e, av=[])
      require 'search/namazu'
      word = ''
      if av[1..-1].empty?
	word = CGI.new.value('word')[0]
      else
	word = av.join(' ')
      end
      url = []
      if word
	res = Search::Namazu::search(word, 'namazu')
	url = res.result.sort{|a,b| a.rank <=> b.rank}.collect{|r|
	  page = CGI::unescape(File.basename(r.fields['uri']))
	  {:page => page, :url => cgiurl([],page)}
	}
      end
      @data = {
	:word   => word,
	:result => url,
      }
      load_parts	
      return self
    end
  end
end




Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com