Module: ShopFilter
- Defined in:
- lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb
Instance Method Summary collapse
- #asset_url(input) ⇒ Object
- #default_pagination(paginate) ⇒ Object
- #global_asset_url(input) ⇒ Object
- #img_tag(url, alt = "") ⇒ Object
- #link_to(link, url, title = "") ⇒ Object
- #link_to_type(type) ⇒ Object
- #link_to_vendor(vendor) ⇒ Object
-
#pluralize(input, singular, plural) ⇒ Object
Accepts a number, and two words - one for singular, one for plural Returns the singular word if input equals 1, otherwise plural.
- #product_img_url(url, style = 'small') ⇒ Object
- #script_tag(url) ⇒ Object
- #shopify_asset_url(input) ⇒ Object
- #stylesheet_tag(url, media = "all") ⇒ Object
- #url_for_type(type_title) ⇒ Object
- #url_for_vendor(vendor_title) ⇒ Object
Instance Method Details
#asset_url(input) ⇒ Object
3 4 5 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 3 def asset_url(input) "/files/1/[shop_id]/[shop_id]/assets/#{input}" end |
#default_pagination(paginate) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 71 def default_pagination(paginate) html = [] html << %(<span class="prev">#{link_to(paginate['previous']['title'], paginate['previous']['url'])}</span>) if paginate['previous'] for part in paginate['parts'] if part['is_link'] html << %(<span class="page">#{link_to(part['title'], part['url'])}</span>) elsif part['title'].to_i == paginate['current_page'].to_i html << %(<span class="page current">#{part['title']}</span>) else html << %(<span class="deco">#{part['title']}</span>) end end html << %(<span class="next">#{link_to(paginate['next']['title'], paginate['next']['url'])}</span>) if paginate['next'] html.join(' ') end |
#global_asset_url(input) ⇒ Object
7 8 9 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 7 def global_asset_url(input) "/global/#{input}" end |
#img_tag(url, alt = "") ⇒ Object
27 28 29 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 27 def img_tag(url, alt="") %|<img src="#{url}" alt="#{alt}" />| end |
#link_to(link, url, title = "") ⇒ Object
23 24 25 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 23 def link_to(link, url, title="") %|<a href="#{url}" title="#{title}">#{link}</a>| end |
#link_to_type(type) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 39 def link_to_type(type) if type link_to type, url_for_type(type), type else 'Unknown Vendor' end end |
#link_to_vendor(vendor) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 31 def link_to_vendor(vendor) if vendor link_to vendor, url_for_vendor(vendor), vendor else 'Unknown Vendor' end end |
#pluralize(input, singular, plural) ⇒ Object
Accepts a number, and two words - one for singular, one for plural Returns the singular word if input equals 1, otherwise plural
94 95 96 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 94 def pluralize(input, singular, plural) input == 1 ? singular : plural end |
#product_img_url(url, style = 'small') ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 55 def product_img_url(url, style = 'small') unless url =~ /^products\/([\w\-\_]+)\.(\w{2,4})/ raise ArgumentError, 'filter "size" can only be called on product images' end case style when 'original' return '/files/shops/random_number/' + url when 'grande', 'large', 'medium', 'compact', 'small', 'thumb', 'icon' "/files/shops/random_number/products/#{$1}_#{style}.#{$2}" else raise ArgumentError, 'valid parameters for filter "size" are: original, grande, large, medium, compact, small, thumb and icon ' end end |
#script_tag(url) ⇒ Object
15 16 17 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 15 def script_tag(url) %(<script src="#{url}" type="text/javascript"></script>) end |
#shopify_asset_url(input) ⇒ Object
11 12 13 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 11 def shopify_asset_url(input) "/shopify/#{input}" end |
#stylesheet_tag(url, media = "all") ⇒ Object
19 20 21 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 19 def stylesheet_tag(url, media="all") %(<link href="#{url}" rel="stylesheet" type="text/css" media="#{media}" />) end |
#url_for_type(type_title) ⇒ Object
51 52 53 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 51 def url_for_type(type_title) "/collections/#{type_title.to_handle}" end |
#url_for_vendor(vendor_title) ⇒ Object
47 48 49 |
# File 'lib/generators/liquid_cms/templates/vendor/plugins/liquid/performance/shopify/shop_filter.rb', line 47 def url_for_vendor(vendor_title) "/collections/#{vendor_title.to_handle}" end |