Module: Clot::UrlFilters

Included in:
LinkItem, LiquidForm
Defined in:
lib/clot/url_filters.rb

Instance Method Summary collapse

Instance Method Details



35
36
37
38
# File 'lib/clot/url_filters.rb', line 35

def delete_link(obj, text="Delete")
  url = ( obj.kind_of?( Liquid::Drop ) ? object_url( obj ) : obj )
  "<a href=\"#{url}/delete\">#{text}</a>"
end


30
31
32
33
# File 'lib/clot/url_filters.rb', line 30

def edit_link(obj, text="Edit")
  url = ( obj.kind_of?( Liquid::Drop ) ? object_url( obj ) : obj )
  "<a href=\"#{url}/edit\">#{text}</a>"
end

#get_nested_edit_url(target, nested_target, class_name = "", nested_class_name = "") ⇒ Object

get url from object and nested object



21
22
23
# File 'lib/clot/url_filters.rb', line 21

def get_nested_edit_url(target, nested_target, class_name = "", nested_class_name = "")
  object_url(target, class_name) + object_url(nested_target, nested_class_name) + "/edit"
end

#get_nested_url(target, nested_target, class_name = "", nested_class_name = "") ⇒ Object

get url from object and nested object



15
16
17
18
# File 'lib/clot/url_filters.rb', line 15

def get_nested_url(target, nested_target, class_name = "", nested_class_name = "")
  child_url = (nested_target.kind_of? String) ? nested_target : object_url(nested_target, nested_class_name)
  object_url(target, class_name) + child_url
end


45
46
47
48
# File 'lib/clot/url_filters.rb', line 45

def index_link(obj, text=nil)
  url = ( obj.kind_of?( Liquid::Drop ) ? object_url( obj ) : obj )
  "<a href=\"/#{url}\">#{text ? text : url.capitalize+' Index'}</a>"
end

#object_url(target, class_name = "") ⇒ Object

get url from object



7
8
9
10
11
12
# File 'lib/clot/url_filters.rb', line 7

def object_url(target, class_name = "")
  if (class_name.blank?)
    class_name = target.dropped_class.to_s.tableize
  end
  '/forms/' + class_name + "/" + target.id.to_s
end

#stylesheet_url(sheetname) ⇒ Object



25
26
27
28
# File 'lib/clot/url_filters.rb', line 25

def stylesheet_url(sheetname)
  url =  "/stylesheets/" + sheetname + ".css"
  url
end


40
41
42
43
# File 'lib/clot/url_filters.rb', line 40

def view_link(obj, text=nil)
  url = ( obj.kind_of?( Liquid::Drop ) ? object_url( obj ) : obj )
  "<a href=\"#{url}\">#{text ? text : url.capitalize}</a>"
end