Module: MongoJob::WebHelpers

Defined in:
lib/mongojob/web/helpers.rb

Instance Method Summary collapse

Instance Method Details

#request_uriObject



25
26
27
# File 'lib/mongojob/web/helpers.rb', line 25

def request_uri
  request.env["REQUEST_URI"]
end

#versioned_css(stylesheet) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mongojob/web/helpers.rb', line 2

def versioned_css(stylesheet)
  # Check for css and sass files
  css_file = File.join(MongoJob::Web.public,"style", "#{stylesheet}.css")
  sass_file = File.join(MongoJob::Web.views,"style", "#{stylesheet}.sass")

  if File.exists? css_file
    mtime = File.mtime(css_file).to_i.to_s
  else
    if File.exists? sass_file
      mtime = File.mtime(sass_file).to_i.to_s
    end
  end
  mime ||= '0'
  "/style/#{stylesheet}.css?" + mtime
end

#versioned_js(js) ⇒ Object



17
18
19
# File 'lib/mongojob/web/helpers.rb', line 17

def versioned_js(js)
  "/script/#{js}.js?" + File.mtime(File.join(MongoJob::Web.public, "script", "#{js}.js")).to_i.to_s
end

#versioned_resource(resource) ⇒ Object



21
22
23
# File 'lib/mongojob/web/helpers.rb', line 21

def versioned_resource(resource)
  "/#{resource}?" + File.mtime(File.join(MongoJob::Web.public, resource)).to_i.to_s
end