module Locomotive
module Wagon
module Liquid
module Filters
module Html
# Returns a link tag that browsers and news readers can use to auto-detect an RSS or ATOM feed.
# input: url of the feed
# example:
# {{ '/foo/bar' | auto_discovery_link_tag: 'rel:alternate', 'type:application/atom+xml', 'title:A title' }}
def auto_discovery_link_tag(input, *args)
options = args_to_options(args)
rel = options[:rel] || 'alternate'
type = options[:type] || MIME::Types.type_for('rss').first
title = options[:title] || 'RSS'
%{}
end
# Write the url of a theme stylesheet
# input: name of the css file
def stylesheet_url(input)
return '' if input.nil?
input = "/stylesheets/#{input}" unless input =~ /^(\/|https?:)/
input = "#{input}.css" unless input.ends_with?('.css')
input
end
# Write the link to a stylesheet resource
# input: url of the css file
def stylesheet_tag(input, media = 'screen')
return '' if input.nil?
input = stylesheet_url(input)
%{}
end
# Write the url to javascript resource
# input: name of the javascript file
def javascript_url(input)
return '' if input.nil?
input = "/javascripts/#{input}" unless input =~ /^(\/|https?:)/
input = "#{input}.js" unless input.ends_with?('.js')
input
end
# Write the link to javascript resource
# input: url of the javascript file
def javascript_tag(input)
return '' if input.nil?
input = javascript_url(input)
%{}
end
# Write an image tag
# input: url of the image OR asset drop
def image_tag(input, *args)
image_options = inline_options(args_to_options(args))
""
end
# Write a theme image tag
# input: name of file including folder
# example: 'about/myphoto.jpg' | theme_image #
def theme_image_tag(input, *args)
image_options = inline_options(args_to_options(args))
"
"
end
def theme_image_url(input)
return '' if input.nil?
input = "images/#{input}" unless input.starts_with?('/')
File.join('/', input)
end
def image_format(input, *args)
format = args_to_options(args).first
"#{input}.#{format}"
end
# Embed a flash movie into a page
# input: url of the flash movie OR asset drop
# width: width (in pixel or in %) of the embedded movie
# height: height (in pixel or in %) of the embedded movie
def flash_tag(input, *args)
path = get_url_from_asset(input)
embed_options = inline_options(args_to_options(args))
%{
}.gsub(/ >/, '>').strip
end
# Render the navigation for a paginated collection
def default_pagination(paginate, *args)
return '' if paginate['parts'].empty?
options = args_to_options(args)
previous_label = options[:previous_label] || I18n.t('pagination.previous')
next_label = options[:next_label] || I18n.t('pagination.next')
previous_link = (if paginate['previous'].blank?
"#{previous_label}"
else
"#{previous_label}"
end)
links = ""
paginate['parts'].each do |part|
links << (if part['is_link']
"#{part['title']}"
elsif part['hellip_break']
"#{part['title']}"
else
"#{part['title']}"
end)
end
next_link = (if paginate['next'].blank?
"#{next_label}"
else
"#{next_label}"
end)
%{