def resource_preview_custom(resource, pkg_id): resource_format = resource.get('format', '').lower() if is_map_viewer_format(resource): viewer_url = config.get('ckanext.geodatagov.spatial_preview.url') url = '{viewer_url}?{params}'.format( viewer_url=viewer_url, params=get_map_viewer_params(resource)) return p.toolkit.render_snippet("dataviewer/snippets/data_preview.html", data={'embed': False, 'resource_url': url, 'raw_resource_url': resource['url']}) elif resource_format in ('web map application', 'arcgis online map') \ and ('webmap=' in resource.get('url') or 'services=' in resource.get('url')): url = resource['url'].replace('viewer.html', 'embedViewer.html') return p.toolkit.render_snippet("dataviewer/snippets/data_preview.html", data={'embed': False, 'resource_url': url, 'raw_resource_url': resource['url']}) return h.resource_preview(resource, pkg_id)
def resource_preview_custom(resource, pkg_id): resource_format = resource.get('format', '').lower() if is_map_viewer_format(resource): viewer_url = config.get('ckanext.geodatagov.spatial_preview.url') url = '{viewer_url}?{params}'.format( viewer_url=viewer_url, params=get_map_viewer_params(resource)) return p.toolkit.render_snippet( "dataviewer/snippets/data_preview.html", data={ 'embed': False, 'resource_url': url, 'raw_resource_url': resource['url'] }) elif resource_format in ('web map application', 'arcgis online map') \ and ('webmap=' in resource.get('url') or 'services=' in resource.get('url')): url = resource['url'].replace('viewer.html', 'embedViewer.html') return p.toolkit.render_snippet( "dataviewer/snippets/data_preview.html", data={ 'embed': False, 'resource_url': url, 'raw_resource_url': resource['url'] }) return h.resource_preview(resource, pkg_id)
def preview_resource_or_ingested(pkg, res): snippet = resource_preview(res, pkg) data_dict = copy.copy(pkg) data_dict.update({'resource': res}) if not _resource_preview(data_dict): raster_resources = ext_template_helpers.get_ingested_raster(pkg, res) vector_resources = ext_template_helpers.get_ingested_vector(pkg, res) for ing_res in raster_resources: #for ing_res in pkg.get('resources'): data_dict.update({'resource': ing_res}) if _resource_preview(data_dict): snippet = resource_preview(ing_res, pkg) break for ing_res in vector_resources: data_dict.update({'resource': ing_res}) if _resource_preview(data_dict): snippet = resource_preview(ing_res, pkg) break return snippet
def preview_resource_or_ingested(pkg, res): snippet = resource_preview(res, pkg) data_dict = copy.copy(pkg) data_dict.update({'resource':res}) if not _resource_preview(data_dict): raster_resources = ext_template_helpers.get_ingested_raster(pkg,res) vector_resources = ext_template_helpers.get_ingested_vector(pkg,res) for ing_res in raster_resources: #for ing_res in pkg.get('resources'): data_dict.update({'resource':ing_res}) if _resource_preview(data_dict): snippet = resource_preview(ing_res, pkg) break for ing_res in vector_resources: data_dict.update({'resource':ing_res}) if _resource_preview(data_dict): snippet = resource_preview(ing_res, pkg) break return snippet