From 70eb08075622b23e128010f64b8e7143bd96fefb Mon Sep 17 00:00:00 2001 From: mguetlein Date: Wed, 28 Jul 2010 10:17:19 +0200 Subject: add text/uri-list support --- application.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/application.rb b/application.rb index 5cebe37..92d350c 100644 --- a/application.rb +++ b/application.rb @@ -34,9 +34,9 @@ get '/:id/?' do task = Task.get(params[:id]) halt 404, "Task '#{params[:id]}' not found." unless task - task_content = {:creator => task.creator, :title => task.title, :date => task.created_at.to_s, :hasStatus => task.hasStatus, + task_content = {:creator => task.creator, :title => task.title, :date => task.created_at, :hasStatus => task.hasStatus, :resultURI => task.resultURI, :percentageCompleted => task.percentageCompleted, :description => task.description, - :due_to_time => task.due_to_time.to_s} + :due_to_time => task.due_to_time } code = task.hasStatus == "Running" ? 202 : 200 @@ -50,6 +50,9 @@ get '/:id/?' do owl = OpenTox::Owl.create 'Task', task.uri task_content.each{ |k,v| owl.set(k.to_s,v)} halt code, owl.rdf + when /text\/uri\-list/ + response['Content-Type'] = 'text/uri-list' + halt code, task.resultURI else halt 400, "MIME type '"+request.env['HTTP_ACCEPT'].to_s+"' not supported, valid Accept-Headers are \"application/rdf+xml\" and \"application/x-yaml\"." end -- cgit v1.2.3 From 4911d9a1fc677dc70287b11ba1f26b425ddc3b09 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Thu, 19 Aug 2010 11:23:18 +0200 Subject: take params into account when create new task --- application.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/application.rb b/application.rb index 57e9ecb..b177e3c 100644 --- a/application.rb +++ b/application.rb @@ -65,14 +65,15 @@ get '/:id/:property/?' do end post '/?' do - LOGGER.debug "Creating new task ..." - task = Task.new - task.save # needed to create id - task.uri = url_for("/#{task.id}", :full) - task.due_to_time = DateTime.parse((Time.parse(task.created_at.to_s) + params[:max_duration].to_f).to_s) if params[:max_duration] - raise "could not save" unless task.save - response['Content-Type'] = 'text/uri-list' - task.uri + "\n" + LOGGER.debug "Creating new task with params "+params.inspect + max_duration = params.delete(:max_duration.to_s) if params.has_key?(:max_duration.to_s) + task = Task.new(params) + task.save # needed to create id + task.uri = url_for("/#{task.id}", :full) + task.due_to_time = DateTime.parse((Time.parse(task.created_at.to_s) + max_duration.to_f).to_s) if max_duration + raise "could not save" unless task.save + response['Content-Type'] = 'text/uri-list' + task.uri + "\n" end put '/:id/:hasStatus/?' do -- cgit v1.2.3