Module: Dugway::Filters::UrlFilters
- Defined in:
- lib/dugway/liquid/filters/url_filters.rb
Instance Method Summary collapse
- #constrain(url = nil, width = '-', height = '-') ⇒ Object
- #link_to(item, *args) ⇒ Object
- #product_image_url(image = nil, size = nil) ⇒ Object
- #theme_css_url(theme) ⇒ Object
- #theme_font_url(filename) ⇒ Object
- #theme_image_url(filename) ⇒ Object
- #theme_js_url(name) ⇒ Object
Instance Method Details
#constrain(url = nil, width = '-', height = '-') ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/dugway/liquid/filters/url_filters.rb', line 11 def constrain(url = nil, width = '-', height = '-') return unless url uri = URI.parse(url) query = Rack::Utils.parse_nested_query uri.query query.update('w' => width, 'h' => height) query.delete_if { |k,v| v.nil? || v == '-' } uri.query = query.to_query uri.to_s end |
#link_to(item, *args) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/dugway/liquid/filters/url_filters.rb', line 4 def link_to(item, *args) = (args) text = .delete(:text) || h(item['name']) = { :title => "View #{ text }", :href => item['url'] }.merge() content_tag :a, text, end |
#product_image_url(image = nil, size = nil) ⇒ Object
21 22 23 24 25 |
# File 'lib/dugway/liquid/filters/url_filters.rb', line 21 def product_image_url(image = nil, size = nil) url = image ? image['url'] : 'http://images.bigcartel.com/missing.png' size = legacy_size_for(size) constrain url, size, size end |
#theme_css_url(theme) ⇒ Object
37 38 39 |
# File 'lib/dugway/liquid/filters/url_filters.rb', line 37 def theme_css_url(theme) '/theme.css' end |
#theme_font_url(filename) ⇒ Object
45 46 47 |
# File 'lib/dugway/liquid/filters/url_filters.rb', line 45 def theme_font_url(filename) "/fonts/#{ filename }" end |
#theme_image_url(filename) ⇒ Object
41 42 43 |
# File 'lib/dugway/liquid/filters/url_filters.rb', line 41 def theme_image_url(filename) "/images/#{ filename }" end |