Markdown datatype support.

With test tools demonstrating HTML and Markdown outputs from tools.

Implements #3396 as part of the Qiime hackathon.
This commit is contained in:
John Chilton
2017-01-10 15:51:08 -05:00
parent 542dc4077f
commit ca40f984b0
15 changed files with 2699 additions and 2 deletions
+2 -1
View File
@@ -30,7 +30,8 @@
"jstree": "~3.0.9",
"jquery-ui": "git://github.com/jquery/jquery-ui.git#~1.11.2",
"jquery.complexify": "git://github.com/danpalmer/jquery.complexify.js.git#~0.5.1",
"threedubmedia.jquery.event": "*",
"threedubmedia.jquery.event": "*",
"showdown": "~1.6.0",
"jquery-migrate": "~1.4",
"requirejs": "~2"
},
File diff suppressed because it is too large Load Diff
+1
View File
@@ -24,6 +24,7 @@ module.exports = function( grunt ){
'bootstrap-tour': [ 'build/js/bootstrap-tour.js', 'bootstrap-tour.js' ],
'jquery.complexify': [ 'jquery.complexify.js', 'jquery.complexify.js' ],
'showdown': ['dist/showdown.js', 'showdown.js'],
// these need to be updated and tested
//'jquery-form': [ 'jquery.form.js', 'jquery/jquery.form.js' ],
//'jquery-autocomplete': [ 'src/jquery.autocomplete.js', 'jquery/jquery.autocomplete.js' ],
+1
View File
@@ -114,6 +114,7 @@
<datatype extension="toolshed.gz" type="galaxy.datatypes.binary:Binary" mimetype="multipart/x-gzip" subclass="true" />
<datatype extension="h5" type="galaxy.datatypes.binary:H5" mimetype="application/octet-stream" display_in_upload="true"/>
<datatype extension="html" type="galaxy.datatypes.text:Html" mimetype="text/html"/>
<datatype extension="markdown" type="galaxy.datatypes.text:Markdown" mimetype="text/markdown"/>
<datatype extension="interval" type="galaxy.datatypes.interval:Interval" display_in_upload="true" description="File must start with definition line in the following format (columns may be in any order)." >
<converter file="interval_to_bed_converter.xml" target_datatype="bed"/>
<converter file="interval_to_bedstrict_converter.xml" target_datatype="bedstrict"/>
+5 -1
View File
@@ -363,9 +363,13 @@ class Data( object ):
if not os.path.exists( data.file_name ):
raise paste.httpexceptions.HTTPNotFound( "File Not Found (%s)." % data.file_name )
max_peek_size = 1000000 # 1 MB
if isinstance(data.datatype, datatypes.text.Html):
if isinstance(data.datatype, datatypes.text.Html) or isinstance(data.datatype, datatypes.text.Markdown):
max_peek_size = 10000000 # 10 MB for html
preview = util.string_as_bool( preview )
if trans.response.get_content_type() == "text/markdown":
trans.response.set_content_type( "text/html" )
return trans.stream_template_mako( "/dataset/markdown.mako",
data=open(data.file_name).read())
if not preview or isinstance(data.datatype, datatypes.images.Image) or os.stat( data.file_name ).st_size < max_peek_size:
if trans.app.config.sanitize_all_html and trans.response.get_content_type() == "text/html":
# Sanitize anytime we respond with plain text/html content.
+17
View File
@@ -57,6 +57,23 @@ class Html( Text ):
return True
class Markdown( Text ):
"""Class describing a Markdown file"""
file_ext = "md"
def set_peek( self, dataset, is_multi_byte=False ):
if not dataset.dataset.purged:
dataset.peek = "Markdown file"
dataset.blurb = nice_size( dataset.get_size() )
else:
dataset.peek = 'file does not exist'
dataset.blurb = 'file purged from disk'
def get_mime(self):
"""Returns the mime type of the datatype"""
return 'text/markdown'
class Json( Text ):
edam_format = "format_3464"
file_ext = "json"
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,15 @@
<%inherit file="/base.mako"/>
<div id="raw_content" style="display: none">${ data | h}</div>
<div id="html_content"></div>
<script type="text/javascript">
require(['libs/showdown'], function(showdown) {
var converter = new showdown.Converter(),
text = $("#raw_content").html(),
html = converter.makeHtml(text);
$("#html_content").html(html);
});
</script>
+14
View File
@@ -0,0 +1,14 @@
<tool id="creates_html" name="creates_html" version="1.0.0" profile="16.04">
<command>
mkdir '$output.extra_files_path';
cp '$__tool_directory__/creates_html_index.html' '$output';
cp '$__tool_directory__/creates_html_image.png' '$output.extra_files_path/image.png';
</command>
<inputs>
<param name="inttest" type="integer" value="7" />
</inputs>
<outputs>
<data format="html" name="output" label="Output HTML">
</data>
</outputs>
</tool>
@@ -0,0 +1,12 @@
<html>
<body>
<p>Hello World!</p>
<p>Some of this sentence is <b>bold</b> and some is <i>italic</i>.</p>
<ul>
<li>A list element.</li>
<li>Another list element.</li>
<li>Last list element.</li>
</ul>
<img src="image.png" alt="An Image">
</body>
</html>
@@ -0,0 +1,14 @@
<tool id="creates_markdown" name="creates_markdown" version="1.0.0" profile="16.04">
<command>
mkdir '$output.extra_files_path';
cp '$__tool_directory__/creates_markdown_index.md' '$output';
cp '$__tool_directory__/creates_html_image.png' '$output.extra_files_path/image.png'
</command>
<inputs>
<param name="inttest" type="integer" value="7" />
</inputs>
<outputs>
<data format="markdown" name="output" label="Output Markdown">
</data>
</outputs>
</tool>
@@ -0,0 +1,9 @@
Hello World!
Some of this sentence is **bold** and some is *italic*.
* A list element.
* Another list element.
* Last list element.
![An Image](image.png)
@@ -18,5 +18,7 @@
<datatype extension="biom1" type="galaxy.datatypes.text:Biom1" display_in_upload="True" subclass="True" mimetype="application/json"/>
<datatype extension="bed" type="galaxy.datatypes.interval:Bed" display_in_upload="true" description="BED format provides a flexible way to define the data lines that are displayed in an annotation track. BED lines have three required columns and nine additional optional columns. The three required columns are chrom, chromStart and chromEnd." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Bed">
</datatype>
<datatype extension="html" type="galaxy.datatypes.text:Html" mimetype="text/html"/>
<datatype extension="markdown" type="galaxy.datatypes.text:Markdown" mimetype="text/markdown"/>
</registration>
</datatypes>
@@ -3,6 +3,8 @@
<tool file="upload.xml"/>
<tool file="simple_constructs.xml" />
<tool file="color_param.xml" />
<tool file="creates_html.xml" />
<tool file="creates_markdown.xml" />
<tool file="inheritance_simple.xml" />
<tool file="boolean_conditional.xml" />
<tool file="composite.xml" />