From 038c4563032f65f935f38ef6bffe426b2dd14c0c Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 14 Sep 2011 10:05:47 +0200 Subject: Endpoint selection from ontology server with cache --- helper.rb | 21 ++++++++++++++++++++- views/create.haml | 2 ++ views/endpoint.haml | 2 +- views/model_echa.haml | 2 ++ views/style.sass | 10 ++++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 views/model_echa.haml diff --git a/helper.rb b/helper.rb index 799135b..9b47142 100644 --- a/helper.rb +++ b/helper.rb @@ -96,5 +96,24 @@ helpers do haml :models_navigation, :layout => false end + def endpoint_option_list(max_time=3600) + out = "" + tmpfile = File.join(TMP_DIR, "endpoint_option_list") + if File.exists? tmpfile + if Time.now-File.mtime(tmpfile) <= max_time + f = File.open(tmpfile, 'r+') + f.each{|line| out << line} + return out + else + File.unlink(tmpfile) + end + end + result = OpenTox::Ontology::Echa.endpoint_option_list() + if result.lines.count > 3 + f = File.new(tmpfile,"w") + f.print result + f.close + end + return result + end end - diff --git a/views/create.haml b/views/create.haml index 5dbd71d..da85382 100644 --- a/views/create.haml +++ b/views/create.haml @@ -24,6 +24,8 @@ = link_to "SDF", '/help' format: %input{:type => 'file', :name => 'file', :id => 'file', :size => '41'} + %br + -# = haml :model_echa, :layout => false %input{ :type => "submit", :value => "Create model"} =# link_to "Cancel", '/create' diff --git a/views/endpoint.haml b/views/endpoint.haml index af06b80..9c250ca 100644 --- a/views/endpoint.haml +++ b/views/endpoint.haml @@ -9,4 +9,4 @@ %em in-vitro, or %em in-vivo - expriment, clinical trial or epidemiological study + experiment, clinical trial or epidemiological study diff --git a/views/model_echa.haml b/views/model_echa.haml new file mode 100644 index 0000000..257a28a --- /dev/null +++ b/views/model_echa.haml @@ -0,0 +1,2 @@ +Select an endpoint: += endpoint_option_list \ No newline at end of file diff --git a/views/style.sass b/views/style.sass index 23b157a..c2a74cb 100644 --- a/views/style.sass +++ b/views/style.sass @@ -287,3 +287,13 @@ dl font-weight: bold .thin font-weight: 100 + +.level_1 + padding-left: 10px + font-weight: bold +.level_2 + padding-left: 20px +.level_3 + padding-left: 30px +.level_4 + padding-left: 40px -- cgit v1.2.3