module SanteyBlog module ViewHelper include ActionView::Helpers # HTML sanitizer configuration SANITIZER_CONFIG = { :elements => [ 'a', 'b', 'blockquote', 'br', 'hr', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'i', 'img', 'li', 'ol', 'p', 'pre', 'q', 'small', 'strike', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'u', 'ul'], :attributes => { 'a' => ['href', 'title'], 'blockquote' => ['cite'], 'col' => ['span', 'width'], 'colgroup' => ['span', 'width'], 'img' => ['align', 'alt', 'height', 'src', 'title', 'width'], 'ol' => ['start', 'type'], 'q' => ['cite'], 'table' => ['summary', 'width'], 'td' => ['abbr', 'axis', 'colspan', 'rowspan', 'width'], 'th' => ['abbr', 'axis', 'colspan', 'rowspan', 'scope', 'width'], 'ul' => ['type'] }, :add_attributes => { 'a' => {'rel' => 'nofollow'} }, :protocols => { 'a' => {'href' => ['ftp', 'http', 'https', 'mailto', :relative]}, 'blockquote' => {'cite' => ['http', 'https', :relative]}, 'img' => {'src' => ['http', 'https', :relative]}, 'q' => {'cite' => ['http', 'https', :relative]} } } def santey_title titles = SanteyBlog.meta_titles t = titles[params[:controller].to_sym] ? titles[params[:controller].to_sym][params[:action].to_sym] ? titles[params[:controller].to_sym][params[:action].to_sym] : titles[params[:controller].to_sym][:default] : titles[:default] case t when /%post_title%/ t = t.gsub(/%post_title%/, @post.title) when /%tag%/ t = t.gsub(/%tag%/, @tag) end content_for :title do t end end def path_to_content content case content.class.name when "Post" root_url + "#{content.created_at.strftime("%Y/%m/%d")}/#{content.slug}" end end def dates_path_helper y=nil, m=nil, d=nil "/#{Time.parse("#{y || "01"}-#{m || "01"}-#{d || "01"}").strftime("#{"%Y#{"/%m#{"/%d" if d}" if m}" if y}")}" end def tag_path_helper tag "/tag/#{tag}" end def posted_at_helper content case content.class.name when "Post" "
posted on #{content.created_at.strftime("%A, %B %d, %Y")}
" end end def cut_text text, full_url, length=500 if(m = /