mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Show yaml files in preview
The `application/yaml` mediatype might be the logical mediatype for yaml (there's no standard yet), but we want to see a textual preview (in the absence of a viewer). Fixes https://github.com/galaxyproject/galaxy/issues/13168
This commit is contained in:
@@ -12,7 +12,7 @@ import tempfile
|
||||
|
||||
import yaml
|
||||
|
||||
from galaxy.datatypes.data import get_file_peek, Text
|
||||
from galaxy.datatypes.data import get_file_peek, Headers, Text
|
||||
from galaxy.datatypes.metadata import MetadataElement, MetadataParameter
|
||||
from galaxy.datatypes.sniff import (
|
||||
build_sniff_from_prefix,
|
||||
@@ -884,6 +884,13 @@ class Yaml(Text):
|
||||
"""Returns the mime type of the datatype"""
|
||||
return 'application/yaml'
|
||||
|
||||
def _yield_user_file_content(self, trans, from_dataset, filename, headers: Headers):
|
||||
# Override non-standard application/yaml mediatype with
|
||||
# non-standard text/x-yaml, so preview is shown in preview iframe,
|
||||
# instead of downloading the file.
|
||||
headers['content-type'] = 'text/x-yaml'
|
||||
return super()._yield_user_file_content(trans, from_dataset, filename, headers)
|
||||
|
||||
def _looks_like_yaml(self, file_prefix: FilePrefix):
|
||||
# Pattern used by SequenceSplitLocations
|
||||
if file_prefix.file_size < 50000 and not file_prefix.truncated:
|
||||
|
||||
Reference in New Issue
Block a user