class Locomotive::Steam::Liquid::Tags::Editable::File
Public Instance Methods
parse(tokens)
click to toggle source
Calls superclass method
Locomotive::Steam::Liquid::Tags::Editable::Base#parse
# File lib/locomotive/steam/liquid/tags/editable/file.rb, line 8 def parse(tokens) super.tap do @path = [current_inherited_block_name, slug].compact.join('--').gsub('/', '--') end end
render(context)
click to toggle source
Calls superclass method
Locomotive::Steam::Liquid::Tags::Editable::Base#render
# File lib/locomotive/steam/liquid/tags/editable/file.rb, line 14 def render(context) apply_transformation(super, context) end
Protected Instance Methods
apply_transformation(url, context)
click to toggle source
# File lib/locomotive/steam/liquid/tags/editable/file.rb, line 55 def apply_transformation(url, context) # resize image with the image_resizer service? if (format = attributes[:resize]).present? options = [] attributes.each do |key, value| options << case key.to_sym when :quality "-quality #{value}" when :optimize # Shortcut helper to set quality, progressive and strip "-quality #{value} -strip -interlace Plane" when :auto_orient "-auto-orient" if value when :strip "-strip" if value when :progressive "-interlace Plane" if value when :filters value else next end end url = context.registers[:services].image_resizer.resize(url, format, options.join(' ')) || url end # in the live editing mode, tag all the images with their editable path (block + slug) if editable?(context) && !url.blank? url = url + (url.include?('?') ? '&' : '?') + 'editable-path=' + @path end url end
default_element_attributes()
click to toggle source
Calls superclass method
Locomotive::Steam::Liquid::Tags::Editable::Base#default_element_attributes
# File lib/locomotive/steam/liquid/tags/editable/file.rb, line 20 def default_element_attributes super.merge({ default_source_url: render_default_content.strip, resize_format: attributes[:resize] }) end
render_element(context, element)
click to toggle source
# File lib/locomotive/steam/liquid/tags/editable/file.rb, line 27 def render_element(context, element) url, timestamp = url_with_timestamp(context, element) context.registers[:services].asset_host.compute(url, timestamp) end
source_url(element)
click to toggle source
# File lib/locomotive/steam/liquid/tags/editable/file.rb, line 46 def source_url(element) if element.source =~ /^https?/ element.source else _url = element.source.start_with?('/') ? element.source : "/#{element.source}" "#{element.base_url}#{_url}" end end
url_with_timestamp(context, element)
click to toggle source
# File lib/locomotive/steam/liquid/tags/editable/file.rb, line 32 def url_with_timestamp(context, element) default_timestamp = context.registers[:page].updated_at.to_i url, timestamp = (if element.source [source_url(element), default_timestamp] else if element.default_source_url.present? [element.default_source_url, default_timestamp] else [render_default_content, nil] end end) end