module Coupler module Helpers def error_messages_for(object) return "" if object.nil? || object.errors.empty? retval = "

Errors detected:

" retval end def javascripts @javascripts ||= %w{jquery.min.js jquery.timeago.js jquery-ui.min.js application.js} end def javascript_includes javascripts.collect do |name| %{} end.join("\n ") end def add_javascript(*names) javascripts.push(*names) end def stylesheets @stylesheets ||= %w{reset.css text.css 960.css jquery-ui.css jquery.treeview.css style.css} end def stylesheet_links stylesheets.collect do |name| %{} end.join("\n ") end def add_stylesheet(*names) stylesheets.push(*names) end def delete_link(text, url) %^#{text}^ end def breadcrumbs # This method is fun but silly. if @breadcrumbs url = "" %{
} end end def humanize(string) string.to_s.gsub(/_+/, " ").capitalize end def timeago(time, klass = nil, tag = "div") if time.nil? "Never" else dt = time.send(:to_datetime) klass = "timeago" + (klass.nil? ? "" : " #{klass}") %{<#{tag} class="#{klass}" title="#{dt.to_s}">#{time.to_s}} end end def form_tag_for(obj, options) base_url = options[:base_url] action, method = if obj.new? [base_url, ""] else ["#{base_url}/#{obj.id}", %{
}] end %{
#{method}} end def local_ip orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily UDPSocket.open do |s| s.connect '64.233.187.99', 1 s.addr.last end ensure Socket.do_not_reverse_lookup = orig end def cycle(even, odd) (@_cycle = !@_cycle) ? even : odd end def field_type(resource, field) result = field.final_type if !resource.import_id result += " (#{field.final_db_type})" end result end end end