Netzke::Core::DynamicAssets

Public Class Methods

ext_css() click to toggle source
# File lib/netzke/core/dynamic_assets.rb, line 50
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) click to toggle source
# File lib/netzke/core/dynamic_assets.rb, line 33
def ext_js(form_authenticity_token)
  res = initial_dynamic_javascript(form_authenticity_token) << "\n"
  include_base_js(res)
  # Ext-specific JavaScript
  res << File.new(File.expand_path("../../../../javascripts/ext.js", __FILE__)).read
  # 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
  defined?(::Rails) && ::Rails.env.production? ? res.strip_js_comments : res
end
touch_css() click to toggle source
# File lib/netzke/core/dynamic_assets.rb, line 21
def touch_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.touch_stylesheets.each do |path|
    f = File.new(path)
    res << f.read
  end
  res
end
touch_js() click to toggle source
# File lib/netzke/core/dynamic_assets.rb, line 5
def touch_js
  res = initial_dynamic_javascript << "\n"
  include_base_js(res)
  # Touch-specific JavaScript
  res << File.new(File.expand_path("../../../../javascripts/touch.js", __FILE__)).read
  # Pluggable JavaScript (may be used by other Netzke-powered gems like netzke-basepack)
  Netzke::Core.touch_javascripts.each do |path|
    f = File.new(path)
    res << f.read
  end
  defined?(::Rails) && ::Rails.env.production? ? res.strip_js_comments : res
end

Protected Class Methods

include_base_js(arry) click to toggle source
# File lib/netzke/core/dynamic_assets.rb, line 78
def include_base_js(arry)
  # JavaScript extensions
  arry << File.new(File.expand_path("../../../../javascripts/core_extensions.js", __FILE__)).read
  # Base Netzke component JavaScript
  arry << File.new(File.expand_path("../../../../javascripts/base.js", __FILE__)).read
end
initial_dynamic_javascript(form_authenticity_token) click to toggle source

Generates initial javascript code that is dependent on Rails settings

# File lib/netzke/core/dynamic_assets.rb, line 65
def initial_dynamic_javascript(form_authenticity_token)
  res = []
  res << %(Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection)
  res << %{Ext.ns('Netzke');}
  res << %{Ext.ns('Netzke.core');}
  res << %{Netzke.RelativeUrlRoot = '#{ActionController::Base.config.relative_url_root}';}
  res << %{Netzke.RelativeExtUrl = '#{ActionController::Base.config.relative_url_root}#{Netzke::Core.ext_uri}';}
  res << %{Netzke.core.directMaxRetries = #{Netzke::Core.js_direct_max_retries};}
  res.join("\n")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.