module Gumdrop::Util::ViewHelpers

Public Instance Methods

cache_bust(path) click to toggle source
# File lib/gumdrop/util/view_helpers.rb, line 47
def cache_bust(path)
  uri_fresh(path)
end
checksum_for(path) click to toggle source
# File lib/gumdrop/util/view_helpers.rb, line 51
def checksum_for(path)
  path= path[1..-1] if path[0] == '/'
  @_checksum_cache ||= {}
  if @_checksum_cache.has_key? path
    @_checksum_cache[path]
  else
    content= render path
    @_checksum_cache[path]= Digest::MD5.hexdigest( content )
  end
end
config() click to toggle source
# File lib/gumdrop/util/view_helpers.rb, line 62
def config
  site.config
end
data() click to toggle source
# File lib/gumdrop/util/view_helpers.rb, line 66
def data
  site.data
end
gumdrop_version() click to toggle source
# File lib/gumdrop/util/view_helpers.rb, line 70
def gumdrop_version
  ::Gumdrop::VERSION
end
hidden(&block) click to toggle source
# File lib/gumdrop/util/view_helpers.rb, line 8
def hidden(&block)
  #no-op
end
markdown(source) click to toggle source
# File lib/gumdrop/util/view_helpers.rb, line 17
def markdown(source)
  eng_class= Gumdrop::Renderer.for 'markdown'
  unless eng_class.nil?
    eng= eng_class.new { source }
    eng.render
  else
    raise StandardError, "Markdown is not available: Include a Markdown engine in your Gemfile!"
  end
end
textile(source) click to toggle source
# File lib/gumdrop/util/view_helpers.rb, line 27
def textile(source)
  eng_class= Gumdrop::Renderer.for 'textile'
  unless eng_class.nil?
    eng= eng_class.new { source }
    eng.render
  else
    raise StandardError, "Textile is not available: Include a Textile engine in your Gemfile!"
  end
end
uri_fresh(path) click to toggle source
# File lib/gumdrop/util/view_helpers.rb, line 37
def uri_fresh(path)
  if (path[0] == '/')
    internal_path= path[1..-1]
  else
    internal_path= path
    path= "/#{path}"
  end
  "#{ path }?v=#{ checksum_for internal_path }"
end
urlencode(string) click to toggle source
# File lib/gumdrop/util/view_helpers.rb, line 12
def urlencode(string)
  require "erb" unless defined? ERB
  ERB::Util.url_encode(string)
end