# $URL$ # $Id$ import paginate logger = logging.getLogger('meresco.resultlist') logger.debug("Starting logger") serverConfig = configs ['server'] serverConfig.setSection('proxies') websiteConfig = configs ['website'] websiteConfig.setSection('searchform') COVERS_ISSN = serverConfig.get('Covers_ISSN',section='proxies') COVERS_ISBN = serverConfig.get('Covers_ISBN',section='proxies') namespaceMap = { 'mods': 'http://www.loc.gov/mods/v3' } def renderSingleItem(index, link, recordId): logger.debug('recordId: ' + recordId) record = any.createRecord(recordId) logger.debug(infra.prpt('record: ', record)) mods = any.getMods(recordId) logger.debug(infra.prpt('mods: ', mods)) db, rid = recordId.split(':', 1) opc = 0 if db == "opc-uvt-nl": opc = 1 urls = 0 if 'URL(s)' in record: urls = 1 genre = '' yield """ """ ### column 1: position in result set yield '%s.' % index ### column 2: genre if 'Publication type' in record: genre = record['Publication type'] yield '%s' % genre ### column 3: title yield '%s' % ( link, record['Title'] ) ### column 4: year if 'Publication date' in record: date=record['Publication date'] else: date='' yield '%s' % date ### column 5: authors if 'Author(s)' in record: authors = record['Author(s)'] elif 'Editor(s)' in record: authors = record['Editor(s)'] + ' (Ed.)' else: authors='' yield '%s' % authors yield """ """ ### column 1 and 2: cover coverUrl = getCoverUrlFor(record) if coverUrl: # infra.dd('record', record) # logger.debug('getCoverUlrFor: '+ coverUrl) yield '' %coverUrl else: yield '' # logger.debug('niets from getCoverUlrFor') ### column 3: source if 'Source' in record: source=record['Source'] else: source='' yield '%s' %source ### column 4 and 5: availability id = 'td' + str(index) yield '' % {'id' : id} if urls: for url in record['URL(s)']: yield '* full text
' %(url) if opc: if not urls: askServer = [] if genre == 'series' and 'Related Titles' in record: yield record['Related Titles'] elif genre == 'multivolume monograph': yield 'Search the catalogue for availability information' %record['Title'] else: for copyInformation in mods.xpath("//mods:location/mods:holdingSimple/mods:copyInformation", namespaceMap): uitleencode = copyInformation.xpath("mods:note[@type='status']/text()", namespaceMap) if not uitleencode: pass elif uitleencode[0] == 'i' or uitleencode[0] == 'f': ####################### f = niet uitleenbaar, wel fotokopie ####################### i = niet uitleenbaar, geen fotokopie, wel inzage location = copyInformation.xpath("mods:shelfLocator/text()", namespaceMap)[0] if inDepot(location): yield 'Available for perusal in depot: request %(loc)s from depot' %{'loc': location} else: if genre == 'journal': yield 'Availability information about this journal (%(loc)s)' %{'loc': location} else: yield 'Available for perusal in the open stacks: %s' %location yield '
' # uitleencodes #a = titel in bestelling #c = niet balie, wel IBL #d = wel balie, niet IBL #e = elektronisch beschikbaar #g = geblokkeerd #o = onbekend #s = speciale toestemming #z = boek zoek elif uitleencode[0] == 'u' or uitleencode[0] == 'b': ####################### u = normaal uitleenbaar ####################### b = beperkt uitleenbaar askServer.append(copyInformation) yield '' if askServer: for copyInformation in askServer: EPN = copyInformation.xpath("mods:note[@type='epn']/text()", namespaceMap)[0] if EPN: location = copyInformation.xpath("mods:shelfLocator/text()", namespaceMap) location = location and location[0] or '' if location: depot = inDepot(location) yield """ """ %{'id':id, 'EPN':EPN, 'loc': location, 'inDepot': depot} else: yield '' else: locator = any.createOpenURL(mods) yield """ """ % {'locator' : locator, 'id' : id } yield '' yield """
""" % index yield '
' % (index,index) yield """ ' def getCoverUrlFor(record): if 'ISSN' in record: return COVERS_ISSN + '/' + record['ISSN'] if 'ISBN' in record: return COVERS_ISBN + '/' + record['ISBN'] def inDepot(location): if location.split()[0] in ['CBM', 'CBC', 'KHS', 'KOD', 'TRE']: return 1 if len(location.split()) > 1: collection = location.split()[0] + " " + location.split()[1] if collection in ['TF PRE', 'TF HS', 'TF INC', 'TFK E', 'KTFK HS', 'KTFK INC']: return 1 else: return 0 else: return 0 def main(total=0, recordIds=[], bitMatrixRow=[], duration=0, cqlQuery=None, httpQuery='', arguments={}, path='', *args, **kwargs): language = 'en' #path.startswith('/en/') and 'en' or 'nl' # logger.debug(infra.prpt('arguments',arguments)) # logger = logging.getLogger('meresco.resultlist') query = arguments.get('query', [''])[0] yield """ """ % (query) offset = int(arguments.get('offset', ['0'])[0]) lo, hi = offset + 1, min(offset + len(recordIds), total) if total == 0: lo = 0 resultString= {'nl':'Resultaten %s - %s van %d (%.5s seconden).', 'en': 'Results %s - %s of %d (%.5s seconds).'}[language] % (lo, hi, total, duration) yield """
""" yield resultString yield """
""" if total == 0: yield '
%s
' % websiteConfig.get('searchTips','better luck next time!') yield """
""" yield paginate.main(offset, total, arguments=arguments, path=path, *args, **kwargs) yield """
""" index = offset for recordId in recordIds: link = 'page/recordview?' + urlencode({ 'recordId': recordId}) index += 1 yield renderSingleItem(index, link, recordId) yield """
""" yield paginate.main(offset, total, arguments=arguments, path=path, *args, **kwargs) yield """
"""