Module: Clot::UrlFilters
- Included in:
- LinkItem, LiquidForm
- Defined in:
- lib/clot/url_filters.rb
Instance Method Summary collapse
- #delete_link(obj, text = "Delete") ⇒ Object
- #edit_link(obj, text = "Edit") ⇒ Object
-
#get_nested_edit_url(target, nested_target, class_name = "", nested_class_name = "") ⇒ Object
get url from object and nested object.
-
#get_nested_url(target, nested_target, class_name = "", nested_class_name = "") ⇒ Object
get url from object and nested object.
- #index_link(obj, text = nil) ⇒ Object
-
#object_url(target, class_name = "") ⇒ Object
get url from object.
- #stylesheet_url(sheetname) ⇒ Object
- #view_link(obj, text = nil) ⇒ Object
Instance Method Details
#delete_link(obj, text = "Delete") ⇒ Object
33 34 35 36 |
# File 'lib/clot/url_filters.rb', line 33 def delete_link(obj, text="Delete") url = ( obj.kind_of?( Liquid::Drop ) ? object_url( obj ) : obj ) "<a href=\"#{url}/delete\">#{text}</a>" end |
#edit_link(obj, text = "Edit") ⇒ Object
28 29 30 31 |
# File 'lib/clot/url_filters.rb', line 28 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
19 20 21 |
# File 'lib/clot/url_filters.rb', line 19 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
13 14 15 16 |
# File 'lib/clot/url_filters.rb', line 13 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 |
#index_link(obj, text = nil) ⇒ Object
43 44 45 46 |
# File 'lib/clot/url_filters.rb', line 43 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
5 6 7 8 9 10 |
# File 'lib/clot/url_filters.rb', line 5 def object_url(target, class_name = "") if (class_name.blank?) class_name = target.dropped_class.to_s.tableize end class_name + "/" + target.id.to_s end |
#stylesheet_url(sheetname) ⇒ Object
23 24 25 26 |
# File 'lib/clot/url_filters.rb', line 23 def stylesheet_url(sheetname) url = "/stylesheets/" + sheetname + ".css" url end |
#view_link(obj, text = nil) ⇒ Object
38 39 40 41 |
# File 'lib/clot/url_filters.rb', line 38 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 |