# $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, record, singleRecord): logger.debug('recordId: ' + recordId) if not record: record = any.createRecord(recordId, format="short") # logging.debug(infra.prpt('record',record)) ### record dependent fields authors='' source='' genre = '' date='' title='' coverUrl = '' if record: if 'Author(s)' in record : authors = record['Author(s)'] elif 'Editor(s)' in record : authors = record['Editor(s)'] + ' (Ed.)' if 'Source' in record : source=record['Source'] if 'Publication type' in record: genre = record['Publication type'] if 'Publication date' in record: date=record['Publication date'] if 'Title' in record : title=record['Title'] coverUrl = getCoverUrlFor(record) else: ### FIXME fatsoenlijke error genereren title = "Problem: %s cannot be retrieved" %(recordId) emptyImage = '/files/' + websiteConfig.get('empty', section='images') coverImage = '' useHighSlide = websiteConfig.get('useHighSlide', section='behavior') if coverUrl: if (useHighSlide == 'True'): coverImage =""" """% {'coverUrl':coverUrl,'emptyImage':emptyImage} else: coverImage =""" """% {'coverUrl':coverUrl,'emptyImage':emptyImage} else: coverImage =""" """% {'emptyImage':emptyImage} availabilityLabel = websiteConfig.get('availability',section="availability") recordToggler = """
"""%{'index':index, 'recordId':recordId} singleRecordDetails = """
"""%{'index':index, 'recordId':recordId} if singleRecord: yield """
%(coverImage)s
"""%{'index':index, 'genre':genre, 'date':date, 'coverImage':coverImage} else: yield """
%(index)s.
%(genre)s
%(date)s
%(coverImage)s
"""%{'index':index, 'genre':genre, 'date':date, 'coverImage':coverImage} if singleRecord: yield """
%(singleRecordDetails)s
"""%{'title':title, 'authors':authors, 'source':source, 'singleRecordDetails':singleRecordDetails} else: yield """
%(title)s
%(authors)s
%(source)s
%(recordToggler)s
"""%{'link':link, 'title':title, 'authors':authors, 'source':source, 'recordToggler':recordToggler} yield """
%(availability)s
""" %{'availability':availabilityLabel} if (record): yield availability.main(index=index, record=record, recordId=recordId) yield """ """ def getCoverUrlFor(record): if 'ISSN' in record: return COVERS_ISSN + '/' + record['ISSN'] if 'ISBN' in record: return COVERS_ISBN + '/' + record['ISBN'].split()[0].replace('-', '') def main(total=0, recordIds=[], records={}, duration=0, cqlQuery=None, httpQuery='', errorString = '', arguments={}, path='', *args, **kwargs): language = 'en' #path.startswith('/en/') and 'en' or 'nl' 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 displayType = arguments.get('displayType',['multiple'])[0] if displayType == 'single': singleRecord = True else: singleRecord = False if not singleRecord: #resultString= {'nl':'Resultaten %s - %s van %d (%.5s seconden).', 'en': 'Results %s - %s of %d (%.5s seconds).'}[language] % (lo, hi, total, duration) resultString= {'nl':'Resultaten %s - %s van .', 'en': 'Results %s - %s of %d.'}[language] % (lo, hi, total) yield """
""" yield resultString yield """
""" # Display search tips if total == 0: # FIXME Translation yield errorString 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: # FIXME: Change into permaLink: "/id/recordId" link = '?' + urlencode({ 'query': recordId}) + '&displayType=single' index += 1 record = {} if recordId in records: record = records[recordId] yield """ """ yield renderSingleItem(index, link, recordId, record, singleRecord) yield """ """ yield """
""" yield paginate.main(offset, total, arguments=arguments, path=path, *args, **kwargs)