lots of changes to rails. search only retrieves 20 at a time. back and next to go...
[zcc.git] / rails / app / controllers / record_controller.rb
blobf232836f71c08e402719e81484afd8465cc3f687
1 class RecordController < ApplicationController
3   def show
4     
5     @data = params[:r]
6     @back = params[:term]
7     @start = params[:start]
8     puts "data: " + @data
9     puts "back: " + @back if @back
10     conn = ZOOM::Connection.new
11     conn.connect("localhost", 9999)
12     conn.set_option('charset', 'UTF-8')
13     conn.preferred_record_syntax = 'MARC21'
14     conn.database_name = "zcc"
15     search_term = "@attr 1=1016 \"#{@data}\""
16     rset = conn.search(search_term)
17     puts rset.size
18     record = ZCC.convert_char(rset[0])
19     #@title = record['245']['a']
20     #puts @title
21     @isbd = isbd record
22     
23     marc_record = record.to_s
24     marc_record.gsub!("LEADER", "<br>LEADER")
25     @records_string = marc_record.gsub("\n", "<br>")
26   end
28   def isbd r
29     string = "<span id=\"title\">"
30     string += r['245']['a'].to_s + r['245']['b'].to_s + r['245']['c'].to_s + "</span>" 
31     string += "<br /><br /> Published: " + r['260']['a'].to_s + r['260']['b'].to_s + r['260']['c'].to_s 
32     string += "<br /><br /> Edition: " + r['250']['a'].to_s if r['250']
33     string += "<br /><br />Physical Description: " + r['300']['a'].to_s + r['300']['b'].to_s + r['300']['c'].to_s
34     string += "<br><br>ISBN: " + r['020']['a'].to_s if r['020']
35     fields = r.find_all{|f| f.tag == "650"}
36     string += "<br /><br />Subjects: <br/>" if fields.size > 0
37     fields.each do |f|
38       subject = []
39       f.each{|sf| subject << sf.value}
40       string += subject.join("--")
41       string << "<br />"
42     end
43     string += "<br /><br />" + r['505']['a'] if r['505']
44     
45 #r[''][''].to_s +
46     string 
47   end
48   
49 end