#custom filters for Octopress module OctopressFilters def exerpt(input, url, url_text="Reade more…", permalink_text=false) if input.index(//i) input.split(//i)[0] + "

#{url_text}

" elsif permalink_text input + "

#{permalink_text}

" else input end end def full_urls(input, url='') input.gsub /(\s+(href|src)\s*=\s*["|']{1})(\/[^\"'>]+)/ do $1+url+$3 end end def smart_quotes(input) require 'rubypants' RubyPants.new(input).to_html end def titlecase(input) require 'titlecase' input.titlecase end def ordinalize(date) if date.class == String date = Time.parse(date) end "#{date.strftime('%B')} #{ordinal(date.strftime('%e').to_i)}, #{date.strftime('%Y')}" end def ordinal(number) if (11..13).include?(number.to_i % 100) "#{number}th" else case number.to_i % 10 when 1; "#{number}st" when 2; "#{number}nd" when 3; "#{number}rd" else "#{number}th" end end end end Liquid::Template.register_filter OctopressFilters