From ea24c7c93e3485c5c578a594bd46730af4c7aa25 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 17 Jan 2022 10:14:28 +0100 Subject: [PATCH] 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 --- lib/galaxy/datatypes/text.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/galaxy/datatypes/text.py b/lib/galaxy/datatypes/text.py index 46e7f07dd09..091965dafd8 100644 --- a/lib/galaxy/datatypes/text.py +++ b/lib/galaxy/datatypes/text.py @@ -875,6 +875,13 @@ class Yaml(Text): """Returns the mime type of the datatype""" return 'application/yaml' + def _yield_user_file_content(self, trans, from_dataset, filename): + # Override non-standard application/yaml mediatype with + # non-standard text/x-yaml, so preview is shown in preview iframe, + # instead of downloading the file. + trans.response.set_content_type('text/x-yaml') + return super()._yield_user_file_content(trans, from_dataset, filename) + def _looks_like_yaml(self, file_prefix): # Pattern used by SequenceSplitLocations if file_prefix.file_size < 50000 and not file_prefix.truncated: