-
Notifications
You must be signed in to change notification settings - Fork 0
/
worldcat.rb
executable file
·57 lines (54 loc) · 2.04 KB
/
worldcat.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# $Id$
require_relative "fuwatto.rb"
module Fuwatto
class WorldcatApp < BaseApp
TERMS = 5
TITLE = "ふわっとWorldCat関連検索 / Fuwatto WorldCat Search"
HELP_TEXT = <<-EOF
<p>
This search tool allows you to search <a href="http://www.worldcat.org">WorldCat</a> just by specifying free text or a web page. The tool automatically extracts feature words from the specified contents, and returns a ranked list of bibliographic information ordered by relevance score.
</p>
<p>
入力したテキストまたはウェブページに関連した文献を<a href="http://www.worldcat.org">WorldCat</a>で検索します。
長いテキストやURLで指定したページからでも関連キーワードを自動的に抜き出して文献検索できるのが特徴です。
</p>
<p style="text-align:center;padding:1ex;font-weight:bolder">
Enjoy my quick hack of WorldCat Basic API at Code4Lib 2010 Conference!<br/>
(from <a href="http://worldcat.org/devnet/wiki/C4l10">OCLC Web Services and Lightning Talk Demos</a> session)
<br/>
<small>Note: This service is just for demonstration purpose and it is very slow, 20sec. per search request.</small>
</p>
EOF
EXAMPLE_TEXT = <<EOF
<div id="feed"></div>
EOF
def execute
super( :worldcat_search, TERMS, { :count => count } )
end
end
end
if $0 == __FILE__
# 検索に使用する最大キーワード数
@cgi = CGI.new
begin
app = Fuwatto::WorldcatApp.new( @cgi )
data = app.execute
app.output( "worldcat", data )
rescue Exception
if @cgi then
print @cgi.header( 'status' => CGI::HTTP_STATUS['SERVER_ERROR'], 'type' => 'text/html' )
else
print "Status: 500 Internal Server Error\n"
print "Content-Type: text/html\n\n"
end
puts "<h1>500 Internal Server Error</h1>"
puts "<pre>"
puts CGI::escapeHTML( "#{$!} (#{$!.class})" )
puts ""
puts CGI::escapeHTML( [email protected]( "\n" ) )
puts "</pre>"
puts "<div>#{' ' * 500}</div>"
end
end