summaryrefslogtreecommitdiff
path: root/helper.rb
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2010-12-06 12:19:49 +0100
committermr <mr@mrautenberg.de>2010-12-06 12:19:49 +0100
commitf5e96aba9ebf6c97d2f17f79571faf25c201b95f (patch)
treeb15d415ea97a586de3a7a00d5e8590e90e7de7f6 /helper.rb
parent04c0b50d08292f2754e1d2a6ac00a644f251f593 (diff)
parent1bcac85620afbccae1164a9a880a2290e360aa62 (diff)
merge with helma/development
Diffstat (limited to 'helper.rb')
-rw-r--r--helper.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/helper.rb b/helper.rb
new file mode 100644
index 0000000..d691103
--- /dev/null
+++ b/helper.rb
@@ -0,0 +1,50 @@
+helpers do
+
+ def hide_link(destination)
+ @link_id = 0 unless @link_id
+ @link_id += 1
+ haml :js_link, :locals => {:name => "hide", :destination => destination, :method => "hide"}, :layout => false
+ end
+
+ def toggle_link(destination,name)
+ @link_id = 0 unless @link_id
+ @link_id += 1
+ haml :js_link, :locals => {:name => name, :destination => destination, :method => "toggle"}, :layout => false
+ end
+
+ def sort(descriptors)
+ features = {:activating => [], :deactivating => []}
+
+ descriptors.each { |d| LOGGER.debug d.inspect; features[d[OT.effect].to_sym] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} }
+ LOGGER.debug features.to_yaml
+ features
+ end
+
+ def compound_image(compound,descriptors)
+ haml :compound_image, :locals => {:compound => compound, :features => sort(descriptors)}, :layout => false
+ end
+
+ def activity_markup(activity)
+ case activity.class.to_s
+ when /Float/
+ haml ".other #{sprintf('%.03g', activity)}", :layout => false
+ when /String/
+ haml ".other #{activity.to_s}", :layout => false
+ else
+ if activity #true
+ haml ".active active", :layout => false
+ elsif !activity # false
+ haml ".inactive inactive", :layout => false
+ else
+ haml ".other #{activity.to_s}", :layout => false
+ end
+ end
+ end
+
+ def neighbors_navigation
+ @page = 0 unless @page
+ haml :neighbors_navigation, :layout => false
+ end
+
+end
+