#! /usr/local/bin/ruby # FT-review-link # 2001.12.28-2002.4.7 # DB言語覚えたら多分一発なんだよなー。XREAはSQLも提供してるし。誰か教えて。 #mode_check = true mode_check = false message_mode = 'sjis' @message_code = 3 #sjis mode_all = false require "kconv" require "cgi" #require '../ruby/simpleuri' require '../ruby/cookie' require '../ruby/webagent' require '../ruby/cache' #----- def argopt ----- def argopt ( argv, opt2v ) argopt0 = [] argopt1 = [] argopt2 = [] num = '0123456789' flag = false argv.each { |arg| if (arg =~ /^-/) && ((arg[1] < num[0]) || (arg[1] > num[-1])) then flag = false opt2v.each { |opt| flag = true if arg == opt } if flag == false then argopt1 << arg else argopt2 << arg end else if flag == false then argopt0 << arg else argopt2 << arg end flag = false end } newargopt2 = [] 0.upto(argopt2.size - 2) { |i| tmp = [] tmp << argopt2[i] if argopt2[i+1] !~ /^-/ tmp << argopt2[i+1] i = i + 1 end newargopt2 << tmp } if argopt2[argopt2.size - 1] =~ /^-/ newargopt2 << argopt2[argopt2.size - 1] end argopts = [] argopts << argopt0 << argopt1 << newargopt2 return argopts end #----- check arg ----- usage = 'command (-a(ll))(book.txt, reviewer.txt, review.txt reviewer_comment.txt -> isbnXXXXXXXXXX.html, list.html, reviewer_XXXXX.html)' opt2v = [] argopts = argopt ( ARGV, opt2v ) case argopts[0].size when 1 input = argopts[0][0] when 2 input = argopts[0][0] output = argopts[0][1] #else # $stderr.puts "Usage: " << usage # exit 1 end argopts[1].each { |option| if (option == "-h") || (option == "-help") then $stderr.puts "Usage: " << usage exit 1 end if (option == "-a") || (option == "-all") then $stderr.puts "CHK; mode all remake" mode_all = true end } #----- def data read ----- def ttcsv_reader ( file = nil, checkkey = nil, checktrack = nil ) $stderr.puts "CHK; file; " << file if file.nil? then fp = $stdin else fp = File.open( file ) end text = [] fp.each {|line| string = Kconv.toeuc(line).chomp.chomp("\r") text << string if string !~ /^#/ # $stderr.puts string if string =~ /^#/ } if !file.nil? then fp.close end key = text.shift.split("\t") data = [] text.each_index { |j| record = {} record["track"] = j if checktrack.nil? info = text[j].split("\t") key.each_index { |i| str = info[i] str = '' if str.nil? record[key[i]] = str } data << record } return data if checkkey.nil? return data, key if !checkkey.nil? end def nncomment_reader ( file = nil ) $stderr.puts "CHK; file; " << file if file.nil? then fp = $stdin else fp = File.open( file ) end text = [] fp.each {|line| string = Kconv.toeuc(line).chomp.chomp("\r") text << string if string !~ /^#/ } if !file.nil? then fp.close end data = [] text1 = text.join("\n") text2 = text1.split("\n\n") text2.each { |block| record = {} if block =~ /^(.*?)\n([\S\s]*)$/ then record["r-code"] = $1 record["comment"] = $2 data << record end } return data end def tlcsv_reader ( file = nil ) $stderr.puts "CHK; file; " << file if file.nil? then fp = $stdin else fp = File.open( file ) end text = [] fp.each {|line| string = Kconv.toeuc(line).chomp.chomp("\r") text << string if string !~ /^#/ } if !file.nil? then fp.close end data = {} text.each_index { |j| record = {} info = text[j].split("\t") key = info.shift list = [] info.each { |track| list << track } data[key] = list } return data end #----- def html ----- def head_html ( file = nil, title = nil, target = nil, banner = nil, bgcolor = nil ) $stderr.puts "CHK; file; " << file #for xrea-ad banner = false if banner.nil? # bgcolor = 'f0ffff' if bgcolor.nil? if file.nil? then fp = $stdout else fp = File.open( file, "w" ) end fp.puts '' fp.puts '' fp.puts '' fp.puts '' + title + '' if !title.nil? fp.puts '' fp.puts '' fp.puts '' if !target.nil? fp.puts '' if !banner.nil? fp.puts '' fp.puts '' if banner == false fp.puts '
' fp.puts '' fp.puts '
' end fp.puts '
' return fp end def tail_html ( fp ) time = Time.now.strftime("%Y.%m.%d %H:%M") fp.puts '
' fp.puts '
' fp.puts 'Last Updated ' + time + ' ' fp.puts '' fp.puts '
' fp.puts '
' fp.puts '' fp.puts '' fp.close end def check_html ( file, title, data, key_data ) fp = head_html(file, title) fp.puts '' str = '' key_data.each{ |key| fp.puts '' } str = '' fp.puts str data.each{ |line| str = '' key_data.each{ |key| str << '' } str << '' fp.puts str } fp.puts '
' + key + '
' str << line[key] if !line[key].nil? str << 'nil' if line[key].nil? str << '
' tail_html(fp) end def check_nncomment_html ( file, title, data ) fp = head_html(file, title) data.each{ |line| fp.puts '
' fp.puts line["r-code"] fp.puts '
' fp.puts line["comment"].gsub(/\n/,"
\n") fp.puts '
' } tail_html(fp) end #test-make def check_data_html ( file, title, data, key_data ) fp = head_html(file, title) fp.puts '' str = '' key_data.each{ |key| fp.puts '' } str = '' fp.puts str data.each{ |line| str = '' key_data.each{ |key| str << '' } str << '' fp.puts str } fp.puts '
' + key + '
' code = line[key] code = 'nil' if code.nil? # if (code !~ 'nil') && (key == 'h-code') then # str << '' + code + '' # else if (code !~ 'nil') && (key == 'r-code') then # str << '' + code + '' # else str << code # end str << '
' tail_html(fp) end def check_image_html ( file, title, data ) fp = head_html(file, title) list = [] data.each{ |key, str| file = 'isbn' + key.downcase.gsub(/-/, '') + '.html' list << '' + str + '' } list.sort!.each{ |line| fp.puts line } tail_html(fp) end #===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== #----- data read ---- book, key_book = ttcsv_reader("book.txt", "withkey") reviewer, key_reviewer = ttcsv_reader("reviewer.txt", "withkey") review, key_review = ttcsv_reader("review.txt", "withkey") reviewer_comment = nncomment_reader("reviewer_comment.txt") image, key_image = ttcsv_reader("image_hayakawa.txt", "withkey") image_hayakawa = {} image.each { |line| image_hayakawa[line["isbn"]] = line["image"].to_i } image, key_image = ttcsv_reader("image_amazon.txt", "withkey") image_amazon = {} image.each { |line| image_amazon[line["isbn"]] = line["image"].to_i } data_ameq = ttcsv_reader("data_ameq.txt") data_sera = ttcsv_reader("data_sera.txt") history = ttcsv_reader("history.txt") update = tlcsv_reader("addlist.dat") #===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== #----- data check ---- $stderr.puts "CHK; check html" check_html("data_book.html", "HAYAKAWA FT review list; data; book.txt", book, key_book) check_html("data_review.html", "HAYAKAWA FT review list; data; review.txt", review, key_review) check_html("data_reviewer.html", "HAYAKAWA FT review list; data; reviewer.txt", reviewer, key_reviewer) check_nncomment_html("data_reviewer_comment.html", "HAYAKAWA FT review list; data; reviewer_comment.txt", reviewer_comment) $stderr.puts 'CHK; book-size; ' + book.size.to_s $stderr.puts 'CHK; review-size; ' + review.size.to_s $stderr.puts 'CHK; reviewer-size; ' + reviewer.size.to_s $stderr.puts 'CHK; reviewer_comment-size; ' + reviewer_comment.size.to_s #----- #? data juufuku check ? #? data code juufuku check ? #----- edit review; r-code->reviewer, h-code->book ----- #----- edit reviewer; r-code->review ----- #----- edit book; h-code->review ----- #? hash-search-method ? $stderr.puts "CHK; search review data" reviewer.each { |line| line["review-list"] = [] } book.each{ |line| line["review-list"] = [] data_ameq.each {|line2| if line["h-code"] == line2["h-code"] then line["ameq"] = 'http://www.ameqland.com/' + line2["url"] end } data_sera.each {|line2| if line["h-code"] == line2["h-code"] then line["sera"] = 'http://home.att.ne.jp/zeta/SERAENO/' + line2["url"] end } } $stderr.puts "CHK; data-ameq, data-sera; set" review.each_index { |i| reviewer.each_index { |j| if review[i]["r-code"] == reviewer[j]["r-code"] then review[i]["reviewer-number"] = j reviewer[j]["review-list"] << i end } book.each_index { |j| if review[i]["h-code"] == book[j]["h-code"] then review[i]["book-number"] = j book[j]["review-list"] << i end } } #----- edit reviewer-comment ----- $stderr.puts "CHK; edit reviewer-comment data" reviewer_comment.each { |line| reviewer.each_index { |j| if line["r-code"] == reviewer[j]["r-code"] then line["reviewer-number"] = j end } line["comment"].gsub!(/】\n([^【])/){ "】\n\n" + $1 } line["comment"].gsub!(/(\n\(.*\)\n)/){ $1 + "\n" } } #----- update check ----- update["book"].each_index{ |i| update["book"][i] = update["book"][i].to_i } update["reviewer"].each_index{ |i| update["reviewer"][i] = update["reviewer"][i].to_i } update["review"].each { |track| track = track.to_i update["book"] << review[track]["book-number"] if review[track]["book-number"].nil? then $stderr.puts "ERR; check review-record" p review[track] exit end update["reviewer"] << review[track]["reviewer-number"] } update["reviewer_comment"].each { |track| track = track.to_i update["reviewer"] << reviewer_comment[track]["reviewer-number"] } update["book"].uniq! update["reviewer"].uniq! if mode_all == true then update["book"] = [] book.each_index{ |i| update["book"] << i} update["reviewer"] = [] reviewer.each_index{ |i| update["reviewer"] << i} end #----- image file ----- $stderr.puts "CHK; image" image_hayakawa_url = {} image_hayakawa.each{ |key, data| if data > 0 then code = '' if key.upcase.gsub(/-/, '') =~ /(\d\d\d).$/ then code = $1 end if code != '' then str = ''
        str << code
        str << '' image_hayakawa_url[key] = str end end } image_amazon_url = {} image_amazon.each{ |key, data| if data > 0 then code = key.upcase.gsub(/-/, '') if code != '' then str = ''
      str << code
      str << '' image_amazon_url[key] = str end end } check_image_html("image_hayakawa.html", "HAYAKAWA FT review list; image hayakawa", image_hayakawa_url) check_image_html("image_amazon.html", "HAYAKAWA FT review list; image amazon", image_amazon_url) #----- filename ----- $stderr.puts "CHK; append output filename" book.each { |line| isbn = line["isbn"] hcode = line["h-code"] file = 'isbn' + isbn.downcase.gsub(/-/, '') + '.html' if isbn != '' file = 'code' + hcode.downcase.gsub(/-/, '') + '.html' if isbn == '' if (file == 'code.html') then file = nil $stderr.puts "WAR; filename; " + file end line["file"] = file } reviewer.each { |line| rcode = line["r-code"] file = 'reviewer_' + rcode + '.html' if (file == 'reviewer_.html') then file = nil $stderr.puts "WAR; filename; " + file end line["file"] = file } #===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== #----- author list ----- $stderr.puts "CHK; make author code" str_zenk = ("ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン へ").split str_hanr = ("aa ii uu ee oo ka ki ku ke ko sa si su se so ta ti tu te to na ni nu ne no ha hi hu he ho ma mi mu me mo ya yu yo ra ri ru re ro wa wo nn he").split str_zenn = ("1 2 3 4 5 6 7 8 9 0").split str_hann = ("1 2 3 4 5 6 7 8 9 0").split str_zenhan = {} str_zenk.each_index { |i| str_zenhan[str_zenk[i]] = str_hanr[i] } str_zenn.each_index { |i| str_zenhan[str_zenn[i]] = str_hann[i] } str_zenhan["―"] = '-' book.each { |line| line["aa-code"] = '' line["aa-code"] << line["a-code"] str_zenhan.each{ |key, data| line["aa-code"].gsub!(/#{key}/, data) } line["aa-code"].downcase.gsub!(/ /, '') if line["aa-code"] =~ /-../ then line["aa-code"].gsub!(/-/, '') else line["aa-code"].gsub!(/-/, '0') end # puts line["a-code"] + "\t" + line["aa-code"] } $stderr.puts "CHK; make author list" author_list= [] book.each { |line| str = line["author"] acode = line["a-code"] code = line["aa-code"] list= str.split("&") count = 0 list.each { |name| name.strip! if !name.empty? then list = {} list["full"] = name list["a-code"] = acode list["aa-code"] = code list["aa-code"] << '_' * count if count > 0 author_list << list count += 1 end } } #author_list.sort!{ |x,y| x["a-code"] <=> y["a-code"]}.uniq! #$stderr.puts "CHK; author-size?; " + author_list.size.to_s #uniqはhashでは効かなくなってる。ので、自作。 acodelist = [] author_list.each{ |line| acodelist << line["a-code"] } acodelist.uniq! newalist = [] acodelist.each { |code| newalist << author_list.find{ |line| line["a-code"] == code} } author_list = newalist author_list.sort!{ |x,y| x["a-code"] <=> y["a-code"] } $stderr.puts "CHK; author-size; " + author_list.size.to_s author_list.each{ |line| full = line["full"] name = full.split("・") if (full =~ /\(.+\)/) || (full =~ /《.+》/) then name = [] name << full end line["family"] = name.pop line["first"] = name.shift line["middle"] = name.join("・") line["first"] = '' if line["first"].nil? line["middle"] = '' if line["middle"].nil? line["book-list"] = [] line["fanseries-list"] = [] book.each_index { |i| if book[i]["author"] =~ /#{line["full"]}/ then line["book-list"] << i if book[i]["series"] != '' then series = book[i]["series"] reviewer_comment.each_index{ |j| if reviewer_comment[j]["comment"] =~ /(特定の作品・作者ファンサイト:#{series})/ then rcode = reviewer_comment[j]["r-code"] $stderr.puts "WAR; no-r-code." if rcode == '' reviewer.each_index { |k| if rcode == reviewer[k]["r-code"] then line["fanseries-list"] << k end } end } end end } line["fan-list"] = [] reviewer_comment.each_index{ |i| if reviewer_comment[i]["comment"] =~ /(特定の作品・作者ファンサイト:#{line["full"]})/ then rcode = reviewer_comment[i]["r-code"] if rcode == '' then $stderr.puts "WAR; no-r-code." end reviewer.each_index {|j| if rcode == reviewer[j]["r-code"] then line["fan-list"] << j end } end } } #===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== #=begin #----- output isbnXXXXXXXXXX ----- #book.each { |line| #p update["book"] update["book"].each { |track| #p track #p book[track] line = book[track] file = line["file"] isbn = line["isbn"] hcode = line["h-code"] title = line["title"] series = line["series"] abcode = line["ab-code"] author = line["author"] acode = line["a-code"] aacode = line["aa-code"] translator = line["translator"] illust = line["illust"] commentator = line["commentator"] date = line["date"] etitle = line["e-title"] eauthor = line["e-author"] edate = line["e-date"] comment = line["comment"] ameq = line["ameq"] sera = line["sera"] image = '' image = isbn.upcase.gsub(/-/, '') if isbn != '' isbn = '(unknown ISBN)' if isbn == '' hcode = '(unknown h-code)' if hcode == '' title = '(unknown title)' if title == '' author = '(unknown author)' if author == '' image_hayakawa[image] = 0 if image_hayakawa[image].nil? image_amazon[image] = 0 if image_amazon[image].nil? if file.nil? $stderr.puts "ERR; book-filename." exit end fp = head_html(file, title, "_blank", true) fp.puts '早川文庫FT
' if hcode !~ /_/ fp.puts hcode + '
' if hcode !~ /_/ fp.puts title fp.puts ' 《' + series + '》' if series != '' fp.puts ' (' + abcode + ')' if abcode != '' fp.puts '
' fp.puts author # fp.puts ' (' + acode + ')' if acode != '' fp.puts ' (' + acode + ')' if acode != '' fp.puts '
' fp.puts translator + '
' if translator != '' fp.puts illust + '
' if illust != '' fp.puts commentator + '
' if commentator != '' fp.puts date + '
' if date != '' fp.puts 'ISBN' + isbn + '
' fp.puts '(' + comment + ')
' if comment != '' fp.puts '
' line["review-list"].each { |i| $stderr.puts "CHK; " + reviewer[review[i]["reviewer-number"]]["reviewer"].kconv(@message_code) rfile = 'reviewer_' + review[i]["r-code"] + '.html' rname = reviewer[review[i]["reviewer-number"]]["reviewer"] rtitle = review[i]["r-title"] rurl = review[i]["url"] rname = '(unknown reviewer)' if rname == '' rtitle = '(review)' if rtitle == '' # $stderr.puts "CHK; " + Kconv.tosjis(review[i]["reviewer"]) # if message_mode == "sjis" then fp.puts '' + rname + ' さん ' fp.puts '' + rtitle + '
' } if (image_hayakawa[image] + image_amazon[image]) > 0 then fp.puts "
" if image_hayakawa[image] > 0 then str = '' str << 'hayakawa-image' fp.puts str end if image_amazon[image] > 0 then str = '' str << 'amazon-image' fp.puts str end end fp.puts '
' fp.puts etitle + '
' if etitle != '' fp.puts eauthor + '
' if eauthor != '' fp.puts edate + '
' if edate != '' if (!ameq.nil?) || (!sera.nil?) then fp.puts '
' tmp = [] tmp << '→AMEQ LAND' if !ameq.nil? tmp << '→瀬良ヱ野図書館' if !sera.nil? fp.puts tmp.join(" ") end fp.puts '' tail_html(fp) } #=end #----- output book list ----- fp = head_html("list.html", "HAYAKAWA FT review list", "review", true, 'ccffff') fp.puts 'book list

' rbook_count = 0 book.each{ |line| rbook_count += 1 if line["review-list"].size > 0 } fp.puts '
総評数 ' + review.size.to_s + '評 総評冊数 ' + rbook_count.to_s + '冊
' fp.puts '早川番号 『タイトル』 《シリーズ》 著者 (評数)  □総冊数 ' + book.size.to_s + '冊
' book.each { |line| file = line["file"] hcode = line["h-code"] title = line["title"] series = line["series"] author = line["author"] rlist = line["review-list"] hcode = '(h-code)' if hcode == '' title = '(title)' if title == '' author = '(author)' if author == '' if file.nil? $stderr.puts "ERR; book-filename; h-code; " + hcode exit end list = [] list << hcode str = '『' + title + '』' list << str if series != '' then str = '《' + series + '》' list << str end list << author str = '(' + rlist.size.to_s + ')' list << str if rlist.size == 0 then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } tail_html(fp) #----- output book list(no-frame) ----- #book.sort!{ |x,y| (x["review-list"].size <=> y["review-list"].size).nonzero? || (x["series"] <=> y["series"]).nonzero? || x["h-code"] <=> y["h-code"] } fp = head_html("list_noframe.html", "HAYAKAWA FT review list (no frame)", nil, nil, 'ccffff') fp.puts 'book list

' fp.puts '
総評数 ' + review.size.to_s + '評 総評冊数 ' + rbook_count.to_s + '冊
' fp.puts '早川番号 『タイトル』 《シリーズ》 著者 (評数)  □総冊数 ' + book.size.to_s + '冊
' book.each { |line| file = line["file"] hcode = line["h-code"] title = line["title"] series = line["series"] author = line["author"] rlist = line["review-list"] hcode = '(h-code)' if hcode == '' title = '(title)' if title == '' author = '(author)' if author == '' if file.nil? $stderr.puts "ERR; book-filename; h-code; " + hcode exit end list = [] list << hcode str = '『' + title + '』' list << str if series != '' then str = '《' + series + '》' list << str end list << author str = '(' + rlist.size.to_s + ')' list << str if rlist.size == 0 then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } fp.puts '
' fp.puts 'reviewer list

' fp.puts '評者 サイト (評数)  □総評者数 ' + reviewer.size.to_s + '人
' reviewer.each { |line| list = [] file = "reviewer_" + line["r-code"] + ".html" str = '' + line["reviewer"] + ' さん' list << str if !line["site-url"].nil? then str = ' ' + line["site"] + '' list << str end str = '(' + line["review-list"].size.to_s + ')' list << str if line["review-list"].size == 0 then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } tail_html(fp) #----- output reviewer list ----- fp = head_html("list_reviewer.html", "HAYAKAWA FT review list; reviewer", "review", true, 'ccffff') fp.puts 'reviewer list

' fp.puts '評者 サイト (評数)  □総評者数 ' + reviewer.size.to_s + '人
' reviewer.each { |line| list = [] file = "reviewer_" + line["r-code"] + ".html" str = '' + line["reviewer"] + ' さん' list << str if !line["site-url"].nil? then str = ' ' + line["site"] + '' list << str end str = '(' + line["review-list"].size.to_s + ')' list << str if line["review-list"].size == 0 then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } fp.puts '
' fp.puts 'sort by name

' fp.puts '評者 サイト (評数)  □総評者数 ' + reviewer.size.to_s + '人
' sreviewer = reviewer.sort{ |x,y| x["reviewer"] <=> y["reviewer"] } sreviewer.each { |line| list = [] file = "reviewer_" + line["r-code"] + ".html" str = '' + line["reviewer"] + ' さん' list << str if !line["site-url"].nil? then str = ' ' + line["site"] + '' list << str end str = '(' + line["review-list"].size.to_s + ')' list << str if line["review-list"].size == 0 then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } tail_html(fp) #----- output reviewer ----- #reviewer.each { |line| update["reviewer"].each { |track| line = reviewer[track] file = line["file"] rcode = line["r-code"] rname = line["reviewer"] site = line["site"] siteurl = line["site-url"] rlist = line["review-list"] rname = '(unknown reviewer)' if rname == '' site = '(unknown site)' if site == '' if file.nil? $stderr.puts "ERR; reviewer-filename.; reviewer; " + rname exit end fp = head_html(file, rname + ' さん書評', "_blank") fp.puts '' + rname + ' さん
' fp.puts '' fp.puts '' + site + '
' fp.puts ' (' + siteurl + ')

' if siteurl != '' fp.puts ' (unknown site-url)
' if siteurl == '' fp.puts '
' reviewer_comment.each { |line2| if line["r-code"] == line2["r-code"] then fp.puts line2["comment"].gsub(/\n/, "
\n") end } fp.puts '
' rlist.each { |i| hcode = book[review[i]["book-number"]]["h-code"] isbn = book[review[i]["book-number"]]["isbn"].downcase.gsub(/-/,'') # title = book[review[i]["book-number"]]["title"] # series = book[review[i]["book-number"]]["series"] # author = book[review[i]["book-number"]]["author"] title = review[i]["title"] author = review[i]["author"] rtitle = review[i]["r-title"] rurl = review[i]["url"] hcode = '(unknown h-code)' if hcode == '' title = '(unknown title)' if title == '' # author = '(unknown author)' if author == '' rtitle = '(review)' if rtitle == '' if rurl == '' then $stderr.puts "WAR; no-url; review-number; " + i.to_s end if isbn == '' then $stderr.puts "ERR; no-isbn; review-number; " + i.to_s end list = [] # list << hcode str = '' + hcode + '' if isbn != '' str = hcode if isbn == '' list << str # str = '『' + title + '』' # list << str list << title # if series != '' then # str = '《' + series + '》' # list << str # end list << author str = '' + rtitle + '' if rurl != '' str = rtitle if rurl == '' list << str if rurl == '' then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } tail_html(fp) } #----- output author list ----- fp = head_html("list_author.html", "HAYAKAWA FT review list; author", "review", true, 'ccffff') fp.puts 'author list (code sort)

' #fp.puts '
総著者数 ' + author_list.size.to_s + '人
' fp.puts '(著者番号) ● 著者
' fp.puts '早川番号 『タイトル』 《シリーズ》 (評数)  □総著者数 ' + author_list.size.to_s + '人
' author_list.each { |line| acode = line["a-code"] aacode = line["aa-code"] author = line["full"] blist = line["book-list"].sort{|x,y| (book[x]["series"] <=> book[y]["series"]).nonzero? || book[x]["h-code"] <=> book[y]["h-code"]} flist = line["fan-list"] slist = line["fanseries-list"] author = '(unknown author)' if author == '' if aacode.nil? $stderr.puts "ERR; aa-code." exit end if acode.nil? $stderr.puts "ERR; a-code." exit end if author.nil? $stderr.puts "ERR; author." exit end fp.puts '

' fp.puts '(' + acode.gsub(/―/, '-') + ')' fp.puts ' ' + author + '
' blist.each { |i| file = book[i]["file"] hcode = book[i]["h-code"] title = book[i]["title"] series = book[i]["series"] rlist = book[i]["review-list"] hcode = '(unknown h-code)' if hcode == '' title = '(unknown title)' if title == '' if file == '' then $stderr.puts "WAR; no-file; book; " + title end list = [] list << hcode str = '『' + title + '』' str = '『' + title + '』' if file == '' list << str if series != '' then str = '《' + series + '》' list << str end str = '(' + rlist.size.to_s + ')' list << str if rlist.size == 0 then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } flist.each { |i| file = reviewer[i]["file"] name = reviewer[i]["reviewer"] name = '(unknown fan)' if name == '' if file == '' then $stderr.puts "WAR; no-file; fan; " + author end fp.puts ' → ' + name + ' さん
' } slist.each { |i| file = reviewer[i]["file"] name = reviewer[i]["reviewer"] name = '(unknown fan)' if name == '' if file == '' then $stderr.puts "WAR; no-file; fan; " + author end fp.puts ' → ' + name + ' さん
' } fp.puts '

' } tail_html(fp) author_list.sort!{ |x,y| x["full"] <=> y["full"] } fp = head_html("list_author_f.html", "HAYAKAWA FT review list; author; first name", "review", true, 'ccffff') fp.puts 'author list (first name sort)

' #fp.puts '
総著者数 ' + author_list.size.to_s + '人
' fp.puts '▽ ● 著者
' fp.puts '早川番号 『タイトル』 《シリーズ》 (評数)  □総著者数 ' + author_list.size.to_s + '人
' author_list.each { |line| acode = line["a-code"] aacode = line["aa-code"] author = line["full"] blist = line["book-list"].sort{|x,y| (book[x]["series"] <=> book[y]["series"]).nonzero? || book[x]["h-code"] <=> book[y]["h-code"]} flist = line["fan-list"] slist = line["fanseries-list"] author = '(unknown author)' if author == '' if aacode.nil? $stderr.puts "ERR; aa-code." exit end if acode.nil? $stderr.puts "ERR; a-code." exit end if author.nil? $stderr.puts "ERR; author." exit end fp.puts '

' fp.puts '' fp.puts ' ' + author + '
' blist.each { |i| file = book[i]["file"] hcode = book[i]["h-code"] title = book[i]["title"] series = book[i]["series"] rlist = book[i]["review-list"] hcode = '(unknown h-code)' if hcode == '' title = '(unknown title)' if title == '' if file == '' then $stderr.puts "WAR; no-file; book; " + title end list = [] list << hcode str = '『' + title + '』' str = '『' + title + '』' if file == '' list << str if series != '' then str = '《' + series + '》' list << str end str = '(' + rlist.size.to_s + ')' list << str if rlist.size == 0 then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } flist.each { |i| file = reviewer[i]["file"] name = reviewer[i]["reviewer"] name = '(unknown fan)' if name == '' if file == '' then $stderr.puts "WAR; no-file; fan; " + author end fp.puts ' → ' + name + ' さん
' } slist.each { |i| file = reviewer[i]["file"] name = reviewer[i]["reviewer"] name = '(unknown fan)' if name == '' if file == '' then $stderr.puts "WAR; no-file; fan; " + author end fp.puts ' → ' + name + ' さん
' } fp.puts '

' } tail_html(fp) fp = head_html("list_author_l.html", "HAYAKAWA FT review list; author; family name", "review", true, 'ccffff') fp.puts 'author list (family name sort)

' #fp.puts '
総著者数 ' + author_list.size.to_s + '人
' fp.puts '▽ ● 著者
' fp.puts '早川番号 『タイトル』 《シリーズ》 (評数)  □総著者数 ' + author_list.size.to_s + '人
' alist = author_list.sort{|x,y| (x["family"] <=> y["family"]).nonzero? || x["full"] <=> y["full"]} alist.each { |line| acode = line["a-code"] aacode = line["aa-code"] author = line["family"] first = line["first"] middle = line["middle"] blist = line["book-list"].sort{|x,y| (book[x]["series"] <=> book[y]["series"]).nonzero? || book[x]["h-code"] <=> book[y]["h-code"]} flist = line["fan-list"] slist = line["fanseries-list"] author = '(unknown author)' if author == '' if aacode.nil? $stderr.puts "ERR; aa-code." exit end if acode.nil? $stderr.puts "ERR; a-code." exit end if author.nil? $stderr.puts "ERR; author." exit end fp.puts '

' fp.puts '' fp.puts ' ' + author + '' fp.puts '  ,' + first if first != '' fp.puts ',' + middle if middle != '' fp.puts '
' blist.each { |i| file = book[i]["file"] hcode = book[i]["h-code"] title = book[i]["title"] series = book[i]["series"] rlist = book[i]["review-list"] hcode = '(unknown h-code)' if hcode == '' title = '(unknown title)' if title == '' if file == '' then $stderr.puts "WAR; no-file; book; " + title end list = [] list << hcode str = '『' + title + '』' str = '『' + title + '』' if file == '' list << str if series != '' then str = '《' + series + '》' list << str end str = '(' + rlist.size.to_s + ')' list << str if rlist.size == 0 then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } flist.each { |i| file = reviewer[i]["file"] name = reviewer[i]["reviewer"] name = '(unknown fan)' if name == '' if file == '' then $stderr.puts "WAR; no-file; fan; " + author end fp.puts ' → ' + name + ' さん
' } slist.each { |i| file = reviewer[i]["file"] name = reviewer[i]["reviewer"] name = '(unknown fan)' if name == '' if file == '' then $stderr.puts "WAR; no-file; fan; " + author end fp.puts ' → ' + name + ' さん
' } fp.puts '

' } tail_html(fp) #----- output rank list (book+reviewer) ----- sbook = book.sort{ |x,y| (y["review-list"].size <=> x["review-list"].size).nonzero? || x["h-code"] <=> y["h-code"] } sreviewer = reviewer.sort{ |x,y| (y["review-list"].size <=> x["review-list"].size).nonzero? || (x["reviewer"] <=> y["reviewer"]).nonzero? } fp = head_html("list_rank.html", "HAYAKAWA FT review list (rank)", "review", true, 'ccffff') fp.puts 'book list

' fp.puts '
総評数 ' + review.size.to_s + '評 総評冊数 ' + rbook_count.to_s + '冊
' fp.puts '早川番号 『タイトル』 《シリーズ》 著者 (評数)  □総冊数 ' + book.size.to_s + '冊
' flag_anc = false sbook.each { |line| file = line["file"] hcode = line["h-code"] title = line["title"] series = line["series"] author = line["author"] rlist = line["review-list"] hcode = '(h-code)' if hcode == '' title = '(title)' if title == '' author = '(author)' if author == '' if file.nil? $stderr.puts "ERR; book-filename; h-code; " + hcode exit end if rlist.size < 2 && flag_anc == false flag_anc = true fp.puts '.
' end list = [] list << hcode str = '『' + title + '』' list << str if series != '' then str = '《' + series + '》' list << str end list << author str = '(' + rlist.size.to_s + ')' list << str if rlist.size == 0 then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } fp.puts '
' fp.puts 'reviewer list

' fp.puts '評者 サイト (評数)  □総評者数 ' + reviewer.size.to_s + '人
' sreviewer.each { |line| list = [] file = "reviewer_" + line["r-code"] + ".html" str = '' + line["reviewer"] + ' さん' list << str if !line["site-url"].nil? then str = ' ' + line["site"] + '' list << str end str = '(' + line["review-list"].size.to_s + ')' list << str if line["review-list"].size == 0 then fp.puts '' + list.join(" ") + '
' # fp.puts '' + list.join(" ") + '
' else fp.puts list.join(" ") + '
' end } tail_html(fp) #----- output book list(shopping) ----- #=begin require '../ruby/amazon' require '../ruby/bk1' require '../ruby/esbooks' require '../ruby/asahiya' require '../ruby/jbook' require '../ruby/kinokuniya' require '../ruby/skysoft' amzinfo = {} expire = 300 book.each { |line| isbn = line["isbn"] bookinfo = CacheBib_amazon.new() bookinfo.expire = expire bookinfo.cache_dir = ("../bookcache/amz") info = bookinfo.get_data(isbn) nouki, flag = bookinfo.word_delivery if flag && !bookinfo.url_bibinfo.nil? nouki = ''+ Kconv.toeuc(nouki) + '' end if !info["image"].nil? nouki = '絵' + nouki end amzinfo[isbn] = nouki } bk1info = {} book.each { |line| isbn = line["isbn"] bookinfo = CacheBib_bk1.new() bookinfo.expire = expire bookinfo.cache_dir = ("../bookcache/bk1") info = bookinfo.get_data(isbn) nouki, flag = bookinfo.word_delivery if flag && !bookinfo.url_bibinfo.nil? nouki = ''+ Kconv.toeuc(nouki) + '' end if !info["image"].nil? nouki = '絵' + nouki end bk1info[isbn] = nouki } esinfo = {} book.each { |line| isbn = line["isbn"] bookinfo = CacheBib_esbooks.new() bookinfo.expire = expire bookinfo.cache_dir = ("../bookcache/esb") info = bookinfo.get_data(isbn) nouki, flag = bookinfo.word_delivery if flag && !bookinfo.url_bibinfo.nil? nouki = ''+ Kconv.toeuc(nouki) + '' end if !info["image"].nil? if info["image"] !~ /books_icn.gif/ nouki = '絵' + nouki end end if info["stock"] =~ /絶版/ nouki << '' end esinfo[isbn] = nouki } ashinfo = {} book.each { |line| isbn = line["isbn"] bookinfo = CacheBib_asahiya.new() bookinfo.expire = expire bookinfo.cache_dir = ("../bookcache/ash") info = bookinfo.get_data(isbn) nouki, flag = bookinfo.word_delivery if flag && !bookinfo.url_bibinfo.nil? nouki = ''+ Kconv.toeuc(nouki) + '' end if !info["image"].nil? nouki = '絵' + nouki end ashinfo[isbn] = nouki } jbkinfo = {} book.each { |line| isbn = line["isbn"] bookinfo = CacheBib_jbook.new() bookinfo.expire = expire bookinfo.cache_dir = ("../bookcache/jbk") info = bookinfo.get_data(isbn) nouki, flag = bookinfo.word_delivery if flag && !bookinfo.url_bibinfo.nil? nouki = ''+ Kconv.toeuc(nouki) + '' end if !info["image"].nil? nouki = '絵' + nouki end jbkinfo[isbn] = nouki } kininfo = {} book.each { |line| isbn = line["isbn"] bookinfo = CacheBib_kinokuniya.new() bookinfo.expire = expire bookinfo.cache_dir = ("../bookcache/kin") info = bookinfo.get_data(isbn) nouki, flag = bookinfo.word_delivery if flag && !bookinfo.url_bibinfo.nil? nouki = ''+ Kconv.toeuc(nouki) + '' end if !info["image"].nil? nouki = '絵' + nouki end kininfo[isbn] = nouki } skyinfo = {} book.each { |line| isbn = line["isbn"] bookinfo = CacheBib_skysoft.new() bookinfo.expire = expire bookinfo.cache_dir = ("../bookcache/sky") info = bookinfo.get_data(isbn) nouki, flag = bookinfo.word_delivery if flag && !bookinfo.url_bibinfo.nil? nouki = ''+ Kconv.toeuc(nouki) + '' end if !info["image"].nil? nouki = '絵' + nouki end skyinfo[isbn] = nouki } fp = head_html("shopping.html", "HAYAKAWA FT list (shopping)", nil, nil, 'ccffff') fp.puts '買うかもしれないリンク:Online Bookstore と YAHOO! Auctions' fp.puts '
' fp.puts '

' fp.puts '「欲しい! 読みたい! 今すぐに!」そうだろうそうだろう。そうですかそうですか。
' fp.puts 'であれば、その為のポインタぐらいは用意しておくべきか……
' fp.puts 'という訳で以下。自己責任で頑張ってね。
' fp.puts '

' #fp.puts 'book list

' #fp.puts '早川番号 『タイトル』 《シリーズ》 著者  □総冊数 ' + book.size.to_s + '冊
' count = 0 tlist = ['番号','評','タイトル','Amazon','bk1','eS!','旭屋','Jbook','紀国','sky','ヤフ','シリーズ','ヤフ','著者','ヤフ'] fp.puts '' str = '' tlist.each { |block| str << '' } str << '' fp.puts str book.each { |line| file = line["file"] hcode = line["h-code"] title = line["title"] series = line["series"] author = line["author"] isbn = line["isbn"] rlist = line["review-list"] checktitle = true checkauthor = true checkisbn = true checktitle = false if title == '' checkauthor = false if author == '' hcode = '(h-code)' if hcode == '' title = '(title)' if title == '' author = '(author)' if author == '' asin = isbn.upcase.gsub(/-/, '') if isbn != '' if file.nil? $stderr.puts "ERR; book-filename; h-code; " + hcode exit end list = [] str = '' + hcode + '' list << str str = '(' + rlist.size.to_s + ')' list << str str = '『' + title + '』' list << str str = amzinfo[isbn] list << str str = bk1info[isbn] list << str str = esinfo[isbn] list << str str = ashinfo[isbn] list << str str = jbkinfo[isbn] list << str str = kininfo[isbn] list << str str = skyinfo[isbn] list << str url = "" if checktitle then code = CGI::escape(title) url = 'Y.A' end list << url str = '' if series != '' then str = '《' + series + '》' end list << str str = '' if series != '' then code = CGI::escape(series) url = 'Y.A' str << url end list << str str = '' str << '(' + author + ')' list << str str = '' if checkauthor then code = CGI::escape(author) url = 'Y.A' str << url end list << str str = '' list.each { |block| str << '' } str << '' fp.puts str count += 1 if count >= 50 then fp.puts '
' + block + '
' + block + '
' fp.puts '' count = 0 str = '' tlist.each { |block| str << '' } str << '' fp.puts str end } fp.puts '
' + block + '
' fp.puts 'Script・案については加藤 隆史さんに感謝。
' tail_html(fp) #=end #----- output history ----- fp = head_html("history.html", "HAYAKAWA FT review link : history") fp.puts '早川文庫FT 書評リンク 履歴' fp.puts '
' fp.puts '' tail_html(fp) #----- output update list ----- file = "update.list.org" $stderr.puts "CHK; file; " << file if file.nil? then fp = $stdin else fp = File.open( file ) end text = [] fp.each {|line| string = Kconv.toeuc(line).chomp.chomp("\r") text << string if string !~ /^#/ } if !file.nil? then fp.close end file = "update.list" $stderr.puts "CHK; file; " << file if file.nil? then fp = $stdout else fp = File.open( file, "w" ) end text.each { |line| fp.puts line } update["book"].each{ |line| fp.puts book[line]["file"] } update["reviewer"].each{ |line| fp.puts reviewer[line]["file"] } if !file.nil? then fp.close end