Class: CommandDeck::AssetsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/command_deck/assets_controller.rb

Overview

Controller for serving assets

Instance Method Summary collapse

Instance Method Details

#cssObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/command_deck/assets_controller.rb', line 16

def css
  rel = params[:path].presence || "main"
  ext = params[:format].presence || "css"
  rel = "#{rel}.#{ext}" unless rel.end_with?(".#{ext}")
  path = safe_asset_path("css", rel)
  return head :not_found unless path && File.file?(path)

  send_data File.binread(path), type: "text/css; charset=utf-8", disposition: "inline"
end

#jsObject



6
7
8
9
10
11
12
13
14
# File 'app/controllers/command_deck/assets_controller.rb', line 6

def js
  rel = params[:path].presence || "main"
  ext = params[:format].presence || "js"
  rel = "#{rel}.#{ext}" unless rel.end_with?(".#{ext}")
  path = safe_asset_path("js", rel)
  return head :not_found unless path && File.file?(path)

  send_data File.binread(path), type: js_mime_for(path), disposition: "inline"
end