invenio_records_ui/views.py
def create_blueprint(endpoints):
    """Create Invenio-Records-UI blueprint.

    The factory installs one URL route per endpoint defined, and adds an
    error handler for rendering tombstones.

    :param endpoints: Dictionary of endpoints to be installed. See usage
        documentation for further details.
    :returns: The initialized blueprint.
    """
    blueprint = Blueprint(
        'invenio_records_ui',
        __name__,
        url_prefix='',
        template_folder='templates',
        static_folder='static',
    )

    @blueprint.errorhandler(PIDDeletedError)
    def tombstone_errorhandler(error):
        return render_template(
            current_app.config['RECORDS_UI_TOMBSTONE_TEMPLATE'],
            pid=error.pid,
            record=error.record or {},
        ), 410

    @blueprint.context_processor
    def inject_export_formats():
        return dict(
            export_formats=(
                current_app.extensions['invenio-records-ui'].export_formats)
            )

    for endpoint, options in (endpoints or {}).items():
        blueprint.add_url_rule(**create_url_rule(endpoint, **options))

    return blueprint
def create_blueprint(endpoints):
    """Create Invenio-Records-UI blueprint.

    The factory installs one URL route per endpoint defined, and adds an
    error handler for rendering tombstones.

    :param endpoints: Dictionary of endpoints to be installed. See usage
        documentation for further details.
    :returns: The initialized blueprint.
    """
    blueprint = Blueprint(
        'invenio_records_ui',
        __name__,
        url_prefix='',
        template_folder='templates',
        static_folder='static',
    )

    @blueprint.errorhandler(PIDDeletedError)
    def tombstone_errorhandler(error):
        return render_template(
            current_app.config['RECORDS_UI_TOMBSTONE_TEMPLATE'],
            pid=error.pid,
            record=error.record or {},
        ), 410

    @blueprint.context_processor
    def inject_export_formats():
        return dict(
            export_formats=(
                current_app.extensions['invenio-records-ui'].export_formats)
            )

    for endpoint, options in (endpoints or {}).items():
        blueprint.add_url_rule(**create_url_rule(endpoint, **options))

    return blueprint
Create Invenio-Records-UI blueprint.

    The factory installs one URL route per endpoint defined, and adds an
    error handler for rendering tombstones.

    :param endpoints: Dictionary of endpoints to be installed. See usage
        documentation for further details.
    :returns: The initialized blueprint.