예제 #1
0
def specific_manifest(source_type):
    if request.method == 'POST':
        params = request.get_json()
    else:
        params = request.args
    try:
        ph = source_mapping[(source_type, 'view')]
    except KeyError:
        try:
            ph = source_mapping[(source_type, 'base')]
        except KeyError:
            return "not found", 404
    if not is_dynamic_source(ph):
        ph = ph(params)
        source_url = ph.source_url
        # auth_service = ph.auth_service(source_url)
        canvas_id = ph.canvas_id
        url = url_for('.get_manifest', source_type=source_type,
                      options=list_to_rest_options([
                          source_url,
                          ph.manifest_identifier
                          ])
                      )
        if canvas_id:
            canvas_id = iiif_metadata_url(url, canvas_id, 'canvas')

        # category = manifest.manifest_category
        manifests = Manifest.query.filter_by(
            source_url=source_url,
            source_type=source_type
        )
        manifests = _path_cat_map(manifests)
        response = render_template(
            'mirador2_index.html',  # auth=auth_service,
            uris_and_locations=manifests,
            preloaded_manifest=url,
            do_not_save=True
        ) if not canvas_id else render_template(
            'mirador2_index.html',  # auth=auth_service,
            uris_and_locations=manifests,
            preloaded_manifest=url,
            preloaded_image=canvas_id,
            do_not_save=True
        )
        return response
    else:
        ph = ph(params)
        category = ph.category
        manifest = url_for('.get_manifest', source_type=source_type,
                           options=dict_to_rest_options(request.args))
        return render_template('mirador2_index.html',
                               uris_and_locations=[(manifest, category)],
                               do_not_save=True,
                               preloaded_manifest=manifest)
예제 #2
0
    def get_all_manifest_path_components(cls):
        """Get all the options url paths for manifests from a source type.

        Returned as a list of dicts containing "options": REST_options_path
        to allow passing to view function.

        They are combined with the type_name and other URIs to form paths to
        allow discovery from the sitemap.

        :returns: list - dicts containing values for source_url and manifest id.
            Return value must always correspond to the manifest view function's
            arguments, minus the source_type.
        """
        return [{"options": dict_to_rest_options(optionset)}
                for optionset in cls.discoverable_option_sets()]