diff options
author | mguetlein <martin.guetlein@gmail.com> | 2011-05-26 12:19:50 +0200 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2011-05-26 12:19:50 +0200 |
commit | 645045dc2afe3323d5bf9968ffe842665398bd67 (patch) | |
tree | 7246273ef081b392fec00f196eba935afc38dd9d | |
parent | 4dac8a5e47a4cc85c4bafc805cd3e52be2a53669 (diff) |
fix html for algorithms
-rw-r--r-- | application.rb | 11 | ||||
-rw-r--r-- | fminer.rb | 36 | ||||
-rw-r--r-- | lazar.rb | 13 |
3 files changed, 51 insertions, 9 deletions
diff --git a/application.rb b/application.rb index 55a8ea4..32fea95 100644 --- a/application.rb +++ b/application.rb @@ -22,6 +22,13 @@ end # # @return [text/uri-list] algorithm URIs get '/?' do - response['Content-Type'] = 'text/uri-list' - [ url_for('/lazar', :full), url_for('/fminer/bbrc', :full), url_for('/fminer/last', :full) ].join("\n") + "\n" + list = [ url_for('/lazar', :full), url_for('/fminer/bbrc', :full), url_for('/fminer/last', :full) ].join("\n") + "\n" + case request.env['HTTP_ACCEPT'] + when /text\/html/ + content_type "text/html" + OpenTox.text_to_html list + else + content_type 'text/uri-list' + list + end end @@ -10,14 +10,20 @@ ENV['FMINER_SILENT'] = 'true' # # @return [text/uri-list] URIs of fminer algorithms get '/fminer/?' do - response['Content-Type'] = 'text/uri-list' - [ url_for('/fminer/bbrc', :full), url_for('/fminer/last', :full) ].join("\n") + "\n" + list = [ url_for('/fminer/bbrc', :full), url_for('/fminer/last', :full) ].join("\n") + "\n" + case request.env['HTTP_ACCEPT'] + when /text\/html/ + content_type "text/html" + OpenTox.text_to_html list + else + content_type 'text/uri-list' + list + end end # Get RDF/XML representation of fminer bbrc algorithm # @return [application/rdf+xml] OWL-DL representation of fminer bbrc algorithm get "/fminer/bbrc/?" do - response['Content-Type'] = 'application/rdf+xml' algorithm = OpenTox::Algorithm::Generic.new(url_for('/fminer/bbrc',:full)) algorithm.metadata = { DC.title => 'fminer backbone refinement class representatives', @@ -33,7 +39,17 @@ get "/fminer/bbrc/?" do { DC.description => "Significance threshold (between 0 and 1)", OT.paramScope => "optional", DC.title => "min_chisq_significance" }, ] } - algorithm.to_rdfxml + case request.env['HTTP_ACCEPT'] + when /text\/html/ + content_type "text/html" + OpenTox.text_to_html algorithm.to_yaml + when /application\/x-yaml/ + content_type "application/x-yaml" + algorithm.to_yaml + else + response['Content-Type'] = 'application/rdf+xml' + algorithm.to_rdfxml + end end # Get RDF/XML representation of fminer last algorithm @@ -53,7 +69,17 @@ get "/fminer/last/?" do { DC.description => "Maximum number of hops", OT.paramScope => "optional", DC.title => "hops" }, ] } - algorithm.to_rdfxml + case request.env['HTTP_ACCEPT'] + when /text\/html/ + content_type "text/html" + OpenTox.text_to_html algorithm.to_yaml + when /application\/x-yaml/ + content_type "application/x-yaml" + algorithm.to_yaml + else + response['Content-Type'] = 'application/rdf+xml' + algorithm.to_rdfxml + end end # Run bbrc algorithm on dataset @@ -3,7 +3,6 @@ # Get RDF/XML representation of the lazar algorithm # @return [application/rdf+xml] OWL-DL representation of the lazar algorithm get '/lazar/?' do - response['Content-Type'] = 'application/rdf+xml' algorithm = OpenTox::Algorithm::Generic.new(url_for('/lazar',:full)) algorithm.metadata = { DC.title => 'lazar', @@ -17,7 +16,17 @@ get '/lazar/?' do { DC.description => "Further parameters for the feaature generation service", OT.paramScope => "optional" } ] } - algorithm.to_rdfxml + case request.env['HTTP_ACCEPT'] + when /text\/html/ + content_type "text/html" + OpenTox.text_to_html algorithm.to_yaml + when /application\/x-yaml/ + content_type "application/x-yaml" + algorithm.to_yaml + else + response['Content-Type'] = 'application/rdf+xml' + algorithm.to_rdfxml + end end # Create a lazar prediction model |