~ubuntu-branches/ubuntu/wily/ruby-ferret/wily

« back to all changes in this revision

Viewing changes to .pc/block_variables_have_local_scopes.patch/bin/ferret-browser

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2013-11-25 01:09:16 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20131125010916-4wj3pwzcjjp8b9et
Tags: 0.11.8.5-1
* Imported Upstream version 0.11.8.5
* debian/control:
  + remove obsolete DM-Upload-Allowed flag
  + use canonical URI in Vcs-* fields
  + update my email address
  + bump Standards-Version to 3.9.5 (no changes needed)
  + drop transitional packages
* Remove single-debian-patch option
* Drop fix_compatibility_with_minitest.patch and
  block_variables_have_local_scopes.patch (applied upstream)
* Remove indications that the source has been repacked (not true anymore)
* Remove embedded copy of bzlib when cleaning instead of repacking
* Add copyright notice for the embedded copy of bzlib
* Install RELEASE_NOTES as documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env ruby
2
 
 
3
 
#$: << File.expand_path(File.join(File.basename(__FILE__), '../lib'))
4
 
require 'ferret'
5
 
require 'ferret/browser'
6
 
 
7
 
require 'optparse'
8
 
require 'ostruct'
9
 
 
10
 
SERVER_OPTIONS = ['webrick']
11
 
conf = OpenStruct.new(:host => '0.0.0.0', :port => 3301)
12
 
 
13
 
opts = OptionParser.new do |opts|
14
 
  opts.banner = "Usage: #{File.basename($0)} /path/to/index"
15
 
  opts.separator ""
16
 
  opts.separator "Specific Options:"
17
 
 
18
 
  opts.on("-h", "--host HOSTNAME",
19
 
          "Host for web server to bind to (default is all IPs)") { |conf.host| }
20
 
  opts.on("-p", "--port NUM",
21
 
          "Port for web server (defaults to #{conf.port})") { |conf.port| }
22
 
  opts.on("-s", "--server NAME",
23
 
          "Server to force (#{SERVER_OPTIONS.join(', ')}).") { |s| conf.server = s.to_sym }
24
 
 
25
 
  opts.separator ""
26
 
  opts.separator "Common options:"
27
 
  
28
 
  opts.on_tail("-?", "--help", "Show this message") do
29
 
    puts opts
30
 
    exit
31
 
  end
32
 
  
33
 
  opts.on_tail("-v", "--version", "Show version") do
34
 
    puts Ferret::VERSION
35
 
    exit
36
 
  end
37
 
end
38
 
 
39
 
opts.parse! ARGV
40
 
if ARGV.length != 1
41
 
  puts opts
42
 
  exit
43
 
end
44
 
@path = ARGV[0]
45
 
 
46
 
# Load the Ferret index
47
 
begin
48
 
  @reader = Ferret::Index::IndexReader.new(@path)
49
 
rescue Ferret::FileNotFoundError => e
50
 
  puts "\033[31mCannot start Ferret. No index exists at \"\033[m" + 
51
 
    "\033[33m#{@path}\033[m\033[31m\".\033[m"
52
 
  exit
53
 
rescue Exception => e
54
 
  puts "\033[31mCannot start Ferret.\n\033[m\033[33m#{e.to_s}\031[m"
55
 
  exit
56
 
end
57
 
 
58
 
unless conf.server 
59
 
  conf.server = :webrick 
60
 
end
61
 
 
62
 
case conf.server.to_s
63
 
when 'webrick'
64
 
  require 'webrick/httpserver'
65
 
  require 'ferret/browser/webrick'
66
 
 
67
 
  # Mount the root
68
 
  s = WEBrick::HTTPServer.new(:BindAddress => conf.host, :Port => conf.port)
69
 
  s.mount "/s", WEBrick::HTTPServlet::FileHandler, Ferret::Browser::Controller::STATIC_DIR, true
70
 
  s.mount "/", WEBrick::FerretBrowserHandler, @reader, @path
71
 
 
72
 
  # Server up
73
 
  trap(:INT) do
74
 
    s.shutdown
75
 
  end
76
 
  s.start
77
 
else
78
 
  raise "server #{conf.server} not known. Must be one of [#{SERVER_OPTIONS.join(', ')}]"
79
 
end