summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2011-01-21 12:11:01 +0100
committermguetlein <martin.guetlein@gmail.com>2011-01-21 12:11:01 +0100
commit4ab0164d5295e5d9665e205a221edfa977997a58 (patch)
tree56c8fb9b808f5b5ad5da0170db12456fe35b15e2
parentb7a88400107c1985f60060499e0e28b156d91a33 (diff)
html support for tasks
-rw-r--r--application.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/application.rb b/application.rb
index 917a6f1..1cd32e0 100644
--- a/application.rb
+++ b/application.rb
@@ -40,8 +40,13 @@ DataMapper.auto_upgrade!
# @return [text/uri-list] List of all tasks
get '/?' do
LOGGER.debug "list all tasks "+params.inspect
- response['Content-Type'] = 'text/uri-list'
- Task.all(params).collect{|t| t.uri}.join("\n") + "\n"
+ if request.env['HTTP_ACCEPT'] =~ /html/
+ response['Content-Type'] = 'text/html'
+ OpenTox.text_to_html Task.all(params).collect{|t| t.uri}.join("\n") + "\n"
+ else
+ response['Content-Type'] = 'text/uri-list'
+ Task.all(params).collect{|t| t.uri}.join("\n") + "\n"
+ end
end
# Get task representation
@@ -56,6 +61,9 @@ get '/:id/?' do
when /yaml/
response['Content-Type'] = 'application/x-yaml'
halt code, task.metadata.to_yaml
+ when /html/
+ response['Content-Type'] = 'text/html'
+ halt code, OpenTox.text_to_html(task.metadata.to_yaml)
when /application\/rdf\+xml|\*\/\*/ # matches 'application/x-yaml', '*/*'
response['Content-Type'] = 'application/rdf+xml'
t = OpenTox::Task.new task.uri