def response_formated_records(records, collection, of, **kwargs): """Return formatter records. Response contains correct Cache and TTL information in HTTP headers. """ response = make_response(format_records(records, collection=collection, of=of, **kwargs)) response.mimetype = get_output_format_content_type(of) current_time = datetime.datetime.now() response.headers['Last-Modified'] = http_date( time.mktime(current_time.timetuple()) ) expires = current_app.config.get( 'CFG_WEBSEARCH_SEARCH_CACHE_TIMEOUT', None) if expires is None: response.headers['Cache-Control'] = ( 'no-store, no-cache, must-revalidate, ' 'post-check=0, pre-check=0, max-age=0' ) response.headers['Expires'] = '-1' else: expires_time = current_time + datetime.timedelta(seconds=expires) response.headers['Vary'] = 'Accept' response.headers['Cache-Control'] = ( 'public' if current_user.is_guest else 'private' ) response.headers['Expires'] = http_date(time.mktime( expires_time.timetuple() )) return response
def response_formated_records(records, collection, of, **kwargs): """Return formatter records. Response contains correct Cache and TTL information in HTTP headers. """ response = make_response( format_records(records, collection=collection, of=of, **kwargs)) response.mimetype = get_output_format_content_type(of) current_time = datetime.datetime.now() response.headers['Last-Modified'] = http_date( time.mktime(current_time.timetuple())) expires = current_app.config.get('CFG_WEBSEARCH_SEARCH_CACHE_TIMEOUT', None) if expires is None: response.headers['Cache-Control'] = ( 'no-store, no-cache, must-revalidate, ' 'post-check=0, pre-check=0, max-age=0') response.headers['Expires'] = '-1' else: expires_time = current_time + datetime.timedelta(seconds=expires) response.headers['Vary'] = 'Accept' response.headers['Cache-Control'] = ('public' if current_user.is_guest else 'private') response.headers['Expires'] = http_date( time.mktime(expires_time.timetuple())) return response
def metadata(recid, of='hd', ot=None): """Display formated record metadata.""" # TODO add signal support if get_output_format_content_type(of) != 'text/html': return response_formated_records( [g.record], of, collections=g.collection ) return render_template('records/metadata.html', of=of, ot=ot)
def metadata(recid, of='hd', ot=None): """Display formated record metadata.""" # TODO add signal support if get_output_format_content_type(of) != 'text/html': return response_formated_records([g.record], of, collections=g.collection) return render_template('records/metadata.html', of=of, ot=ot)
def metadata(recid, of='hd', ot=None): """Display formated record metadata.""" # TODO add signal support if get_output_format_content_type(of) != 'text/html': return response_formated_records([g.record], of, collections=g.collection) # Send the signal 'document viewed' record_viewed.send(current_app._get_current_object(), recid=recid, id_user=current_user.get_id(), request=request) return render_template('records/metadata.html', of=of, ot=ot)
def metadata(recid, of='hd', ot=None): """Display formated record metadata.""" # TODO add signal support if get_output_format_content_type(of) != 'text/html': return response_formated_records( [g.record], of, collections=g.collection ) # Send the signal 'document viewed' record_viewed.send( current_app._get_current_object(), recid=recid, id_user=current_user.get_id(), request=request) return render_template('records/metadata.html', of=of, ot=ot)
def metadata(recid, of='hd', ot=None): """Display formated record metadata.""" # from invenio.legacy.bibrank.downloads_similarity import \ # register_page_view_event # register_page_view_event(recid, current_user.get_id(), # str(request.remote_addr)) if get_output_format_content_type(of) != 'text/html': return response_formated_records([g.record], of, collections=g.collection) # Send the signal 'document viewed' record_viewed.send(current_app._get_current_object(), recid=recid, id_user=current_user.get_id(), request=request) return render_template('records/metadata.html', of=of, ot=ot)
def metadata(recid, of='hd', ot=None): """Display formated record metadata.""" # from invenio.legacy.bibrank.downloads_similarity import \ # register_page_view_event # register_page_view_event(recid, current_user.get_id(), # str(request.remote_addr)) if get_output_format_content_type(of) != 'text/html': return response_formated_records( [g.record], of, collections=g.collection ) # Send the signal 'document viewed' record_viewed.send( current_app._get_current_object(), recid=recid, id_user=current_user.get_id(), request=request) return render_template('records/metadata.html', of=of, ot=ot)