# $Id$ # $URL$ import paginate, availability 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') def renderSingleItem(index, link, recordId): logger.debug('recordId: ' + recordId) record = any.createRecord(recordId) # logger.debug(infra.prpt('record: ', record)) yield """ """ ### column 1: position in result set yield '%s.' % index ### column 2: genre 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 """ """ emptyImage = '/files/' + websiteConfig.get('empty', section='images') ### column 1 and 2: cover coverUrl = getCoverUrlFor(record) if coverUrl: # infra.dd('record', record) # logger.debug('getCoverUlrFor: '+ coverUrl) yield """""" % (coverUrl,emptyImage) 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 yield availability.main(index=index, record=record, recordId=recordId) 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=[], 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] httpQuery = escapeHtml(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 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 """
"""