From a45a8e727a23b7af637c4f495ee8494df3c708d5 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Wed, 24 Oct 2012 14:50:31 +0200 Subject: add html view for latest task --- application.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/application.rb b/application.rb index 369bf17..8d09aa5 100644 --- a/application.rb +++ b/application.rb @@ -67,7 +67,6 @@ get '/?' do end get '/latest' do - response['Content-Type'] = 'text/plain' ts = Task.all.sort running = [] ts.size.times do |i| @@ -80,7 +79,14 @@ get '/latest' do end running.reverse! running << ts[-1] if running.size==nil or running[-1]!=ts[-1] - running.collect{|t| "'#{t.uri}' --- '#{t.created_at}' --- '#{t.hasStatus}' --- '#{t.title}'"}.join("\n")+"\n" + res = running.collect{|t| "'#{t.uri}' --- '#{t.created_at}' --- '#{t.hasStatus}' --- '#{t.title}'"}.join("\n")+"\n" + if request.env['HTTP_ACCEPT'] =~ /html/ + response['Content-Type'] = 'text/html' + OpenTox.text_to_html res + else + response['Content-Type'] = 'text/plain' + res + end end # Get task representation -- cgit v1.2.3