diff options
-rw-r--r-- | application.rb | 17 | ||||
-rw-r--r-- | config.ru | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/application.rb b/application.rb index 3c21d3b..61889c1 100644 --- a/application.rb +++ b/application.rb @@ -11,12 +11,11 @@ class Dataset property :created_at, DateTime attr_accessor :subjectid - @subjectid = nil after :save, :check_policy def load(params,request) - + data = request.env["rack.input"].read content_type = request.content_type content_type = "application/rdf+xml" if content_type.nil? @@ -94,7 +93,7 @@ class Dataset private def check_policy - OpenTox::Authorization.check_policy(uri, subjectid) + OpenTox::Authorization.check_policy(uri, subjectid) if id end end @@ -125,6 +124,8 @@ get '/:id' do unless extension.empty? params[:id].sub!(/\.#{extension}$/,'') case extension + when "html" + @accept = 'text/html' when "yaml" @accept = 'application/x-yaml' when "csv" @@ -153,7 +154,11 @@ get '/:id' do when /yaml/ response['Content-Type'] = 'application/x-yaml' dataset.to_yaml - + + when /html/ + response['Content-Type'] = 'text/html' + OpenTox.text_to_html dataset.to_yaml + when "text/csv" response['Content-Type'] = 'text/csv' dataset.to_csv @@ -196,7 +201,7 @@ get %r{/(\d+)/feature/(.*)$} do |id,feature| #feature_uri = url_for("/#{params[:id]}/feature/#{URI.encode(params[:feature_name])}",:full) # work around racks internal uri decoding #dataset = YAML.load(Dataset.get(params[:id]).yaml) - feature_uri = url_for("/#{id}/feature/#{URI.encode(feature)}",:full) # work around racks internal uri decoding + feature_uri = url_for("/#{id}/feature/#{URI.encode(feature)}",:full) # work around racks internal uri decoding dataset = YAML.load(Dataset.get(id).yaml) metadata = dataset.features[feature_uri] @@ -256,6 +261,7 @@ end # @param [optional] file, for file uploads, Content-type should be multipart/form-data, please specify the file type `application/rdf+xml, application-x-yaml, text/csv, application/ms-excel` # @return [text/uri-list] Task URI or Dataset URI (empty datasets) post '/?' do + @dataset = Dataset.create response['Content-Type'] = 'text/uri-list' @dataset.subjectid = @subjectid @@ -302,6 +308,7 @@ end # Delete a dataset # @return [text/plain] Status message delete '/:id' do + LOGGER.debug "deleting dataset with id "+params[:id].to_s begin dataset = Dataset.get(params[:id]) uri = dataset.uri @@ -2,3 +2,5 @@ require 'rubygems' require 'opentox-ruby' require 'config/config_ru' run Sinatra::Application +set :raise_errors, false +set :show_exceptions, false
\ No newline at end of file |