Module: Netzke::Core::DynamicAssets

Defined in:
lib/netzke/core/dynamic_assets.rb

Constant Summary collapse

CORE_FILES =
%w[js_extensions core notifications remoting_provider base routing]

Class Method Summary collapse

Class Method Details

.ext_cssObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/netzke/core/dynamic_assets.rb', line 23

def ext_css
  res = File.new(File.expand_path("../../../../stylesheets/core.css", __FILE__)).read

  # Pluggable stylesheets (may be used by other Netzke-powered gems like netzke-basepack)
  Netzke::Core.ext_stylesheets.each do |path|
    f = File.new(path)
    res << f.read
  end

  res
end

.ext_js(form_authenticity_token) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/netzke/core/dynamic_assets.rb', line 9

def ext_js(form_authenticity_token)
  res = initial_dynamic_javascript(form_authenticity_token) << "\n"

  include_core_js(res)

  # Pluggable JavaScript (used by other Netzke-powered gems like netzke-basepack)
  Netzke::Core.ext_javascripts.each do |path|
    f = File.new(path)
    res << f.read
  end

  minify_js(res)
end

.minify_js(js_string) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/netzke/core/dynamic_assets.rb', line 35

def minify_js(js_string)
  if ::Rails.env.test? || ::Rails.env.development?
    js_string.gsub(/\/\*\*[^*]*\*+(?:[^*\/][^*]*\*+)*\//, '') # strip docs
  else
    Uglifier.compile(js_string)
  end
end