Parent

Methods

Files

Thoth::MinifyController

Public Instance Methods

css(*args) click to toggle source
# File lib/thoth/controller/minify.rb, line 35
def css(*args)
  path = 'css/' << args.join('/')
  file = process(path)

  Ramaze::Session.current.drop! if Ramaze::Session.current

  response['Content-Type'] = 'text/css'

  # If the filename has a -min suffix, assume that it's already minified and
  # serve it as is.
  if (File.basename(path, '.css') =~ /-min$/)
    response.body = File.open(file, 'rb')
    throw(:respond)
  end

  if Config.server.enable_cache
    response.body = value_cache[path] ||
        value_cache[path] = CSSMin.minify(File.open(file, 'rb'))
  else
    response.body = CSSMin.minify(File.open(file, 'rb'))
  end

  throw(:respond)
end
js(*args) click to toggle source
# File lib/thoth/controller/minify.rb, line 60
def js(*args)
  path = 'js/' << args.join('/')
  file = process(path)

  Ramaze::Session.current.drop! if Ramaze::Session.current

  response['Content-Type'] = 'text/javascript'

  # If the filename has a -min suffix, assume that it's already minified and
  # serve it as is.
  if (File.basename(path, '.js') =~ /-min$/)
    response.body = File.open(file, 'rb')
    throw(:respond)
  end

  if Config.server.enable_cache
    response.body = value_cache[path] ||
        value_cache[path] = JSMin.minify(File.open(file, 'rb'))
  else
    response.body = JSMin.minify(File.open(file, 'rb'))
  end

  throw(:respond)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.