From bcfa017b39a8963ec30613aa488da139e8f5657a Mon Sep 17 00:00:00 2001 From: Stian Haklev Date: Fri, 11 May 2007 01:09:28 +0700 Subject: [PATCH] removing obsolete file --- zipweb.rb | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100755 zipweb.rb diff --git a/zipweb.rb b/zipweb.rb deleted file mode 100755 index aea195b..0000000 --- a/zipweb.rb +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/ruby -require 'rubygems' -require 'mongrel' -homedir = '/users/stian/source/zip-doc' -require File.join(homedir, 'zarchive') -require File.join(homedir, 'htmlshrinker') - - -archive = ZArchive.new(ARGV[0]) -htmlshrink = HTMLShrinker.new("/id") -class SimpleHandler < Mongrel::HttpHandler - def process(req, resp) - p req - t = Time.now - puts req - txt = archive.get_article(req.unparsed_uri[3..-1]) - if txt.nil? - out.write = "Sorry, article not found" - else - out.write = htmlshrink.uncompress(txt) - end - puts "Served in #{Time.now - t} seconds." - end -end - -search_proc = lambda do |req, resp| - t = Time.now - resp['Content-Type'] = "text/html" - search_query =req.unparsed_uri[("search".size+2)..-1] - puts search_queryearch_query - @found_documents=[] - FERRET.search_each(search_query) do |docid, score| - @found_documents << {:path => FERRET.reader.get_document(docid)[:filename], - :score => score, :highlight => FERRET.highlight(search_query, - docid, :pre_tag => '', :post_tag => '', - :field => :content)} - end - resp.body = "" - unless @found_documents.empty? - resp.body << "

Search results for query #{search_query}

" - @found_documents.each do |doc| - resp.body << "
  • #{doc[:path]}
    #{doc[:highlight]}

    " - end - else - resp.body << "Sorry, no documents found" - end - puts "Served in #{Time.now - t} seconds." -end - -h = Mongrel::HttpServer.new("0.0.0.0", "3000") -h.register("/", SimpleHandler.new) -h.register("/files", Mongrel::DirHandler.new(".")) -h.run.join -- 2.11.4.GIT