Sha256: f80799165e309d68bc07c92262d1a16ee9619460a17a3af020d699ef66ea7d0d

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

class NetzkeController < ApplicationController
  def index
    redirect_to :action => :test_widgets
  end

  # collect javascripts from all plugins that registered it in Netzke::Base.config[:javascripts]
  def netzke
    respond_to do |format|
      format.js {
        res = ""
        Netzke::Base.config[:javascripts].each do |path|
          f = File.new(path)
          res << f.read
        end
        render :text => res.strip_js_comments
      }
      
      format.css {
        res = ""
        Netzke::Base.config[:stylesheets].each do |path|
          f = File.new(path)
          res << f.read
        end
        render :text => res
      }
    end
  end
  
  def method_missing(method_name)
    widget_name, *action = method_name.to_s.split('__')
    widget_name = widget_name.to_sym
    action = !action.empty? && action.join("__").to_sym
  
    if action
      w_instance = Netzke::Base.instance_by_config(Netzke::Base.session[:netzke_widgets][widget_name])
      # only widget's actions starting with "api_" are accessible from outside (security)
      api_action = action.to_s.index('__') ? action : "api_#{action}"
      render :text => w_instance.send(api_action, params), :layout => false
    else
      super
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netzke-core-0.5.1 lib/app/controllers/netzke_controller.rb
netzke-core-0.5.0 lib/app/controllers/netzke_controller.rb