<% end %>
<%=
res = 'var hoboParts = {};'
# FIXME: This should interrogate the model-router - not the models
unless Hobo::Model.all_models.empty?
# Tell JS code how to pluralize names, unless they follow the simple rule
names = Hobo::Model.all_models.map do |m|
m = m.name.underscore
"#{m}: '#{m.pluralize}'" unless m.pluralize == m + 's'
end.compact
res << "var pluralisations = {#{names * ', '}}; "
end
base = [base_url, subsite].compact.join("/")
res << "urlBase = '#{base}'; hoboPagePath = '#{view_name}'"
if request_forgery_protection_token
res << "; formAuthToken = { name: '#{request_forgery_protection_token}', value: '#{form_authenticity_token}' }"
end
res
%><%=
if this.nil?
nil_view unless if_present
else
name_tag = find_polymorphic_tag("name")
if name_tag != "name"
send(name_tag, attributes)
elsif this.is_a?(Array) && this.respond_to?(:proxy_reflection)
count
elsif this.is_a? Class and this < ActiveRecord::Base
this.name.pluralize.titleize
elsif (name_attr = this.class.try.name_attribute) && can_view?(this, name_attr)
if raw
this.send(name_attr)
else
view(merge_attrs(attributes, {:field => name_attr}))
end
elsif can_view?(this)
this.to_s
end
end
%><%=
type ||= (this if this.is_a?(Class)) || this.try.member_class || this.class
name = dasherize ? type.name.underscore.dasherize : type.name.titleize
name = name.pluralize if plural
name = name.downcase if lowercase
name
%><%=
if (attr = this.try.origin_attribute)
name = attr.to_s
name = dasherize ? name.underscore.dasherize : name.titleize
name = name.singularize if singular
name = name.downcase if lowercase
name
else
type_name(:plural => !singular, :lowercase => lowercase, :dasherize => dasherize)
end
%><%=
content = parameters.default
params = self.query_params.merge(params || HashWithIndifferentAccess.new) if query_params
if href || attributes[:name]
# Regular link
href += "?" + params.map { |n, v| "#{n}=#{v}" }.join('&') if !params.blank?
element(:a, attributes.update(:href => href), content)
else
target = to || this
if target.nil?
Hobo::Dryml.last_if = false
nil_view
elsif action == "new"
# Link to a new object form
new_record = target.new
new_record.set_creator(current_user)
href = object_url(target, "new", params._?.merge(:subsite => subsite))
if href && can_create?(new_record)
new_class_name = if target.respond_to?(:proxy_reflection)
target.proxy_reflection.klass.name
else
target.name
end
add_classes!(attributes, "new-#{new_class_name.underscore}-link")
content = "New #{new_class_name.titleize}" if content.blank?
Hobo::Dryml.last_if = true
element(:a, attributes.update(:href => href), content)
else
Hobo::Dryml.last_if = false
""
end
else
# Link to an existing object
content = name if content.blank?
href = object_url(target, action, (params || {}).merge(:subsite => subsite))
if href.nil?
# This target is registered with ModelRouter as not linkable
content
else
css_class = target.try.origin_attribute || target.class.name.underscore.dasherize
add_classes!(attributes, "#{css_class}-link")
href.sub!(/\?|$/, ".#{format}\\0") unless format.blank?
# Set default link text if none given
element(:a, attributes.update(:href => href), content)
end
end
end
%><%=
raise HoboError, "view of non-viewable field '#{this_field}' of #{this_parent.typed_id rescue this_parent}" unless
can_view?
res = if this.nil? && if_blank.nil?
this_type.is_a?(Class) && this_type <= String ? "" : nil_view
elsif (refl = this_field_reflection) && refl.macro == :has_many
has_many_view(attributes)
else
view_tag = find_polymorphic_tag("view")
if view_tag == "view" # i.e. it didn't find a type specific tag
if this.respond_to?(:to_html)
this.to_html(scope.xmldoctype)
else
this.to_s
end
else
attrs = add_classes(attributes, "view", type_and_field._?.dasherize, model_id_class)
view_attrs = attrs_for(view_tag)
the_view = send(view_tag, attrs & view_attrs)
the_view = if_blank if if_blank && the_view.blank?
truncate = 30 if truncate == true
the_view = self.truncate(the_view, truncate.to_i) if truncate
the_view = the_view.strip
if no_wrapper
the_view
else
wrapper = if inline
:span
elsif block || this.is_a?(HoboFields::Text)
:div
else
:span
end
element(wrapper, attrs - view_attrs, the_view)
end
end
end
Hobo::Dryml.last_if = !res.blank?
res
%><%= this.empty? ? "(none)" : context_map { a }.join(", ") %><%= this && (format ? this.strftime(format) : this.to_s(:long)) %><%= this && (format ? this.strftime(format) : this.to_s(:long)) %><%= this && (format ? this.strftime(format) : this.to_s(:long)) %><%= format ? format % this : this.to_s %><%= this.try.to_html(scope.xmldoctype) || h(this).gsub("\n", " ") %><%= this ? 'Yes' : 'No' %><%=
raise Exception.new("asked for count of a string") if this.is_a?(String)
c = this.try.to_int || this.try.total_entries || (this.try.loaded? && this.try.length) || this.try.count || this.try.length
label ||= if this.is_a?(Class)
this.name
elsif (attr = this.try.origin_attribute)
attr.to_s.singularize
else
this.member_class.name
end.titleize
label = label.downcase if lowercase
Hobo::Dryml.last_if = c > 0 if if_any
if if_any && c == 0
""
else
main = label.blank? ? c : pluralize(c, label)
if prefix.in? %w(are is)
p = c == 1 ? "is" : "are"
p + ' ' + main.to_s
else
main
end
end
%>
<% name ||= Hobo.current_theme -%>
No <%= this.member_class.name.titleize.pluralize.downcase %> to display
<% add_to = this
refl = this_type
joins = this_parent.send(refl.through_reflection.name)
add_name = refl.klass.name.titleize
action_name ||= "Add #{add_name}"
add_text ||= "To #{action_name.downcase} #{a_or_an add_name.downcase}, " +
"enter its name"
source = refl.source_reflection.name
%>
<%= "#{titleize ? 'Y' : 'y'}ou#{' have' if have}#{' are' if are}#{' do' if do_}" %><%= "#{' has' if have}#{' is' if are}#{' does' if do_}" %>your<%= n = name; n.ends_with?('s') ? "#{n}'" : "#{n}'s" %>Your<%= n = name; n.ends_with?('s') ? "#{n}'" : "#{n}'s" %>
Search Results
close
<%=
(word =~ /^[aeiou]/i ? "an " : "a ") + word
%><%=
(word =~ /^[aeiou]/i ? "An " : "A ") + word
%>
<% no_filter ||= "All" %>
<%= this.join(separator || ", ") %>